On 03/10/2011 03:31 PM, Philippe Nobili wrote:
> Dear M. Shafie,
>
> Sorry to bother you with this type of question, but we find it difficult
> (please, do not take this as a criticism) to find clear examples on how
> to do it in the documentation...
>
> What we want to do is pretty simple actually:
>
> 1. We add a command button in some elements; the command works on the
> implicitElement (the element selected when the user clicks on the button)
>
> 2. In this command, we want to
>
> a) retrieve all Ids of children elements, e.g. (Xpath) child::*/@id
> b) use pick to display this list to the use so that he can choose one
> c) Uses this to modify one give attribute of the implicit element,
> e.g.:
> <cfg:command name="putAttribute"
> parameter="[implicitElement] defaultValue %_" />
>
> Seems that the we know all the spare parts, but we miss the glue...
> Could you point us to some hints, especially on point a) (how to collect
> data using Xpath)
>
Here it is (I've used DocBook's linkend to test the following macro):
---
<command name="setLinkend">
<macro>
<sequence>
<pass><command name="putAttribute"
parameter="[implicitElement] linkend"/></pass>
<get context="$implicitElement"
expression="join(*/@id, ' ')" />
<command name="pick"
parameter="'Choose an ID' false %_" />
<command name="putAttribute"
parameter="[implicitElement] linkend %_"/>
</sequence>
</macro>
</command>
<binding>
<keyPressed code="F4" />
<command name="setLinkend" />
</binding>
---
References:
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/putAttribute.html
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/xpath_get.html
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/xpath_vars.html
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/xpathextfunc.html
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/pick.html
--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support