On 03/10/2011 08:32 PM, Hussein Shafie wrote:
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>
---
Many thanks; we managed to get this work , but our problem is actually
slightly more complex.
It can certainly be solved easily, but we are currently running in
circles.... Allow me to take a little bit more of your time; again
thank you for your help, here it is:
What we need is the second form of *pick*, where we specify a string
mixing labels and items (we want the label to be displayed, but the
items to be selected eventually). Building the selection string using
XSL code, is pretty simple, we did not see how to build it with join
So we decided (but maybe this is a completely bad choice), to use an XSL
transformation fragment in our macro-command. This looks like:
(geov:menu is the selected element):
<cfg:get expression="serialize($implicitElement)"/>
<cfg:transform source="%_">
<xsl:stylesheet version="1.0"
xmlns:geov="http://www.cggveritas.com/geovation/module/2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/geov:menu">
<xsl:for-each select="geov:item">
<xsl:value-of select="concat(concat(geov:nativeDescript/@name,' '),@id)"/>
<xsl:if test="not(position() = last())">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
</cfg:transform>
And then:
<cfg:command name="pick"
parameter="'Choose the default Attribute' false %_" />
No menu is created, which seems to indicate that macro variable '%_' is
empty after the <transform>. However, the XSL transformation is correct
and works on our XML fragment.
So just two questions:
1. Is this something reasonable, or should we proceed differently ?
2. If there something wrong in taking the '%_' variable after transform ?
Many thanks again,
Philippe.
--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support