Marsoner Stephan wrote:
> I tried to write a macro which should fill a dialog box with values of
> elements of the same name like the implicit selected element but failed
> miserably!
>
>
> <cfg:command name="pick-this">
> <cfg:macro>
> <cfg:sequence>
> <cfg:get
> context="//*[local-name(.)=local-name($implicitElement)]
> expression="."/>
> <cfg:command name="pick" parameter="Choose false %_"/>
> <cfg:command name="alert" parameter="%_"/>
> </cfg:sequence>
> </cfg:macro>
> </cfg:command>
>
> Other promising get-constructs, which didn't work either:
>
> <cfg:get context="//$implicitNode" expression="."/>
>
> <cfg:get context="//$implicitElement" expression="*"/>
>
> <cfg:get context="//{$implicitElement}" expression="."/>
>
> ...
>
> Is it possible at all?
I have tested this with the XHTML document below:
---
<cfg:command name="pick-this">
<cfg:macro>
<cfg:sequence>
<cfg:get expression="//li"/>
<cfg:command name="pick" parameter="Choose false %_"/>
<cfg:command name="alert" parameter="%_"/>
</cfg:sequence>
</cfg:macro>
</cfg:command>
<binding>
<keyPressed code="F5" />
<command name="pick-this" />
</binding>
---
(Specify expression such as "//foo" in the expression attribute, not in
the context attribute. The default context is the document, which is
fine for absolute expressions.)
---
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>xxxx</title>
</head>
<body>
<p>xxxx</p>
<p>yyy</p>
<p>xxxx</p>
<ul>
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
<p>The end.</p>
</body>
</html>
---
It works as expected. It displays a list containing just A (and not A, B
and C).
Explanation:
* //li returns a node-set.
* a node-set is converted to a string by returning the string value of
the node of the node-set which is first in document order.
To make this work, you need to use a ``join function'': join(//li, ' ').
Unfortunately, there is no standard join function in XPath, so you need
to write it yourself in Java.
An alternative is to use a process command (cached, with no feedback) as
the first item of your macro-command. See
http://www.xmlmind.com/xmleditor/_distrib/docs/commands/ch05.html
This process command will write a text file containing quoted string
which will be loaded using a <read> process command item.
> Similarily, is it possible to add a css-rule for an element with a
> combo-box filled with unique values which are already used for this
> element, somehow with xpath/label ???
>
> Example:
>
> <test>
> <x>a</x>
> <x>d</x>
> <x>b</x>
> <x>b</x>
> </test>
>
> In element x I would like to have a combo-box with [a b d] as values.
Yes, this should be possible because you can use XPath expressions to
parameterize the combo-box but, here too, a ``join function'' is needed.
---
PS: With XXE, almost everything is possible if you write it in Java.