Subject: Re: [xsl] variable outside a for-each loop: second try From: "Mathieu Malaterre" <mathieu.malaterre@xxxxxxxxx> Date: Thu, 20 Sep 2007 17:41:18 +0200 |
On 9/20/07, Abel Braaksma <abel.online@xxxxxxxxx> wrote: > Mathieu Malaterre wrote: > > > > If I copy paste it I am getting: > > > > Error at xsl:value-of on line 21 of file:/tmp/dummy.xsl: > > Required type of second operand of '/' is node(); supplied value has > > type xs:string > > Transformation failed: Failed to compile stylesheet. 1 error detected. > > > > Where line 21 is: > > > > <xsl:value-of select="../preceding-sibling::row/entry[position() eq > > $position][1]/normalize-space(string-join(para,' '))" /> > > > > What does this mean ? > > > > It means that line that the compiler is pointing you at is not the line > where the error occurs, because the line that you show here does not > have a string as the left-hand side of the / operator. > > Oh, sorry. I see now: this error seems to come from an XSLT 1.0 > processor. But you are using string-join in your original post. Which is > a Xpath 2.0 function. What processor are you using? Or do you operate in > backward compatibility mode? $ java -jar /usr/share/Dart/Source/Server/saxon/saxon8.jar -t Saxon 8.0 from Saxonica Java version 1.6.0_01 No source file name When I tried your solution here is what I get:. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes" encoding="UTF-8"/> <!-- this goes on the root level of the stylesheet --> <xsl:template match="row"> <entry ie="{(entry[1]/para[. != ''] | preceding-sibling::row[entry[1]/para != ''][1])[1]}" module="{entry[2]/para}" reference="{entry[3]/para}" usage="{entry[4]/para}"/> </xsl:template> <xsl:template match="/"> <xsl:for-each select="//informaltable"> <xsl:apply-templates select="row"/> </xsl:for-each> </xsl:template> </xsl:stylesheet> Gives: <?xml version="1.0" encoding="UTF-8"?> <entry ie="Col1 A" module="Col2 A" reference="" usage=""/> <entry ie="
 
 Col1 A
 
 
 Col2 A
 
 " module="Col2 B" reference="" usage=""/> <entry ie="
 
 Col1 A
 
 
 Col2 A
 
 " module="Col2 C" reference="" usage=""/> <entry ie="
 
 Col1 A
 
 
 Col2 A
 
 " module="Col2 D" reference="" usage=""/> on <?xml version="1.0"?> <informaltable> <row> <entry> <para>Col1 A</para> </entry> <entry> <para>Col2 A</para> </entry> </row> <row> <entry> <para/> </entry> <entry> <para>Col2 B</para> </entry> </row> <row> <entry> <para/> </entry> <entry> <para>Col2 C</para> </entry> </row> <row> <entry> <para>Col1 D</para> </entry> <entry> <para>Col2 D</para> </entry> </row> </informaltable> -- Mathieu
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] variable outside a for-ea, Abel Braaksma | Thread | Re: [xsl] variable outside a for-ea, David Carlisle |
Re: [xsl] variable outside a for-ea, Abel Braaksma | Date | Re: [xsl] Using for-each w/ page-se, Tony Graham |
Month |