On 03/11/2011 12:08 PM, Philippe Nobili wrote: > 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>.
You should test that using <command name="alert" parameter="%_" /> > 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 ? No it's OK to use <cfg:transform>. > 2. If there something wrong in taking the '%_' variable after transform ? > No. In the above code, * concat(concat(geov:nativeDescript/@name,' '),@id) could be replaced by concat(geov:nativeDescript/@name, ' ', @id) Note that if string(@name) contains whitespace then you must quote it. * Your stylesheet generates text but has no <xsl:output method="text"/> element. I'm not sure that this could work. * It's: <cfg:command name="pick" parameter="'Choose the default Attribute' true %_" /> and not: <cfg:command name="pick" parameter="'Choose the default Attribute' false %_" /> * Adding trace="true" to the macro would print useful diagnostics on the console. -- XMLmind XML Editor Support List [email protected] http://www.xmlmind.com/mailman/listinfo/xmleditor-support

