Subject: Re: [xsl] XSLT 2.0: When to use xsl:sequence, when to use xsl:value-of, and why?|
From: "M. David Peterson" <m.david@xxxxxxxxxxxxx>
Date: Sat, 16 Jun 2007 15:45:49 -0600
Well, in this particular example, that doesn't change a lot.
But there are cases where the generated content will not be the same, depending on the content of the sequence itself. Read through the B'5.7 "Sequence Constructors", this is very useful, interesting and well, required to write XSLT
For an example: <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output indent="yes" omit-xml-declaration="yes"/> <xsl:variable name="v" as="element()+"> <elem>1</elem> </xsl:variable> <xsl:variable name="s" select=" $v/text(), 'a', $v/text()"/> <xsl:template match="/"> <sequence> <xsl:sequence select="$s"/> </sequence> <value-of> <xsl:value-of select="$s"/> </value-of> </xsl:template> </xsl:transform> should produce: <sequence>1a1</sequence> <value-of>1 a 1</value-of>
I say "should" because I've really evaluated the example with Saxon and got instead: <sequence>1a1</sequence> <value-of>1 a1</value-of> So I reread B'5.7.2 and I can't understand how this result is build. Seems like a bug to me, while it would be very surprising to still find this kind of bug in Saxon. Michael?