O. Relot wrote:
>
> i'm still working on xxe-pro-5_3_0 and i would like to generate in my
> own document a combo-box dynamically implemented from java...
> it's easy when i know the value and the key list in the css file =>
>
> content: combo-box(labels, "Green\A Blue\A Red",
> values, "green\A blue\A red");
>
> but i have to find my list in a database...
> i tried to implement a java code (getList.java) which return my list in
> a string, and i declared a command getList in my .xxe file =>
> <command name="getList">
> <class>commands.getList</class>
> </command>
>
> ... and in my css i hoped i could do that =>
> content: combo-box(labels, command-button(command, "getList"),
> values, command-button(command, "getList"));
>
> ... but unfortunately it doesn't work!
>
> do you know a way to do what i'm looking for?

[NOT TESTED BUT SHOULD WORK FINE]

I would suggest to replace command getList by a plain static java method.

Let's call this method com.acme.xxe.CSSExtension.getList. Let's suppose 
this method as 2 parameters:

[a] A boolean which specifies whether it should return a string (tokens 
separated by '\n') containing labels or a string containing values 
(other tokens separated by '\n').

[b] The element which is the subject of the CSS rule. (May be useful as 
a context for building your database query. However this is hypothetical.)

---
import com.xmlmind.xml.xpath.NodeIterator;

public static String getList(boolean getLabels,
                              NodeIterator context) {
    Element element = (Element) context.next();
    ...
}
---

The CSS is now:

---
@namespace ce "java:com.acme.xxe.CSSExtension.getList";

...

content: combo-box(labels, xpath("ce:getList(true(), .)"),
                    values, xpath("ce:getList(false(), .)"));
---

How to use static java methods as XPath extension functions is explained 
here:

http://www.xmlmind.com/xmleditor/_distrib/doc/commands/xpathextfunc_java.html

See also:

http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xml/xpath/NodeIterator.html
 
--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to