Pierrick Brihaye wrote:
> 
> That's it :
> if there's an xreflabel, I want to see this label.
> if there's none, I want to see the pointed element, with a possible stop
> on an endterm
> if there is no linkend, an "unresolved xref" message would be nice...
> 
> Well, that's just the "Processing Expectations" for xref :
> http://www.docbook.org/tdg/en/html/xref.html
> 
> > If you want to do this, please confirm and I'll send you the piece of
> > BeanShell or JavaScript (tell me what you prefer) script that must be
> > added to the style sheet in order to implement this.
> 
> Thanks. In fact I wonder whether XXE should *natively* support Docbook's
> processing expectations. I've well understood that XXE is*highly*
> customizable :-)

XXE supports whatever you want to make it support if you take the time
to customize it. The bundled configurations are simply a starting point.

Here is how to implement a simplified version of what you want:
[1] Download and install the BeanShell plug-in.

[2] in xxe_distrib/config/sdocbook/css/sdocbook.incl, after first
@script{}, add a second @script{}

-----------------------------
@script "text/beanshell" {
import com.xmlmind.xmledit.xmlutil.*;
import com.xmlmind.xmledit.doc.*;

Name LINKEND = Name.get("linkend");
Name ID = Name.get("id");

String xreflabel() {
    Element link = (Element) contextNode;
    String label = "";

    String linkend = link.getAttribute(LINKEND);
    if (linkend != null) {
        linkend = linkend.trim();

        // XXE only supports a very small subset of XPath.
        Document doc = link.getDocument();
        Path path = Path.fromString("//@xreflabel", doc);
        Object[] list = path.select(doc);

        for (int i = 0; i < list.length; ++i) {
            Attribute attribute = (Attribute) list[i];

            String id = attribute.element.getAttribute(ID);
            if (id != null && linkend.equals(id.trim())) {
               label = " [" + attribute.value.trim() + "]";
               break;
            }
        }
    }

    // Quote the result or it will not be parsed as a CSS string.
    return "'" + label + "'";
}
-----------------------------

[3] At the end of this file, replace:

---------------
xref {
    content: icon(right-link) attr(linkend) " "; 
    vertical-align: text-top; 
    color: navy; 
}
---------------

by:

---------------
xref {
    content: icon(right-link) attr(linkend) evaluate("xreflabel();") "
"; 
    vertical-align: text-top; 
    color: navy; 
}
---------------





> >>Do you think it would be possible to make links active (possibly with
> >>the right mouse button) ?
> >
> > The right mouse button is already used to display the Edit popup menu
> Does it make sense to add a menu item for "links-like" elements ?

Currently, command editMenu (which displays the Edit popup menu) is not
contextual. That is, it cannot be parametrized to display a menu which
depends on the node being clicked upon.




> >>In "Edition" tab, would it be possible to have grayed, possibly stroked,
> >>elements ? i.e. elements that are theorically pertinent in the current
> >>element but are not in the current *position* ? Of course, this should
> >>be cutomizable : people that have a good knowledge of Docbook (or
> >>whatever) shouldn't need this feature...
> >
> >
> > Sorry. I don't understand this. Please give me an example.
> 
> Well. With default configuration, I can create an (empty) article that
> looks like this :
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
> "http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd";>
> <article>
>    <title></title>
>    <sect1>
>      <title></title>
>      <para></para>
>    </sect1>
> </article>
> 
> Now, I select the whole sect1 element in order to use the "insert"
> command to create a sect1info element. Unfortunately, this element is
> *not* listed because I think that XXE assumes that the content model is
> valid as it is.

This content model *is* valid.




> If I want to insert this sect1info element, I have to
> select the title element and the "insert before" command. This behaviour
> seems a little odd to me...
>
> So, what I'd like is either :
> Offer the sect1info in the "insert command"
> Offer a grayed sect1info in the "insert command" that would mean in this
> case : "you have to select the first child element and use the 'insert
> before' command"...

We are not fully satisfied with current semantics of the "insert into"
command:
* insert an element at caret position (even if an ancestor of ``caret
container'' is explicitly selected);
* OR, only if selected element is empty, add a child to this element.

We will probably rethink the "insert into" command but not on the short
term.



> Now, a bug report :
> 
> 1) open 2 documents
> 2) there's no "close all" command in the "file" menu. Never mind...
> 3) use "file/close" in order to close the first document
> 4) if you want to use the same menu item to close the second document,
> you can't : it is grayed.

Almost *all* menu items are grayed because after closing first document,
second one has not automatically been made ``active'' (notice that its
title bar is gray instead of being blue). In such case, simply click
anywhere in the remaining document to make its window ``active''. After
that, you can do whatever you want with it, including closing it.

This being said, we'll fix this minor bug.

Reply via email to