Subject: Re: [xsl] variable outside a for-each loop From: Abel Braaksma <abel.online@xxxxxxxxx> Date: Thu, 20 Sep 2007 15:39:01 +0200 |
<!-- this goes on wherever you currently have for-each --> <xsl:apply-templates select="row" />
<xsl:template match="entry"> <xs:attribute name="{format-number(position(), '[Nn]')}" select="." /> </
HTH, Cheers, -- Abel Braaksma
Hello,
this is clearly a question that has been asked many times on this mailing list. But I simply cannot find anything smart to do for my issue:
I have the following XML (docbook):
<informaltable> <row> <entry> <para>ABC</para> </entry> <entry> <para>DEF</para> </entry> </row> <row> <entry> <para/> </entry> <entry> <para>DEF 2</para> </entry> </row> </informaltable>
My goal is to produce:
<table> <entry one="ABC" two="DEF"/> <entry one="ABC" two="DEF 2"/> </table>
In C/C++ this is trivial at each step whenever row/entry is empty I would use some local variable instead. But in XSL I am stuck with:
<xsl:for-each select="row"> <xsl:variable name="one" select="normalize-space(string-join(entry[1]/para,' '))"/> <xsl:variable name="two" select="normalize-space(string-join(entry[2]/para,' '))"/> <entry one="{$one}" two="{$two}"/> </xsl:for-each>
Could someone please let me know what the correct solution is when using XSL ?
Thanks so much;
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] variable outside a for-ea, G. Ken Holman | Thread | RE: [xsl] variable outside a for-ea, Bjorndahl, Brad |
RE: [xsl] variable outside a for-ea, cknell | Date | Re: [xsl] Using for-each w/ page-se, Sharon_Harris |
Month |