Re: [xsl] XSLT 2.0: When to use xsl:sequence, when to use xsl:value-of, and why?

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 11:03:25 -0600
On Sat, 16 Jun 2007 10:18:45 -0600, Florent Georges
<darkman_spam@xxxxxxxx> wrote:

    <xsl:stylesheet
        xmlns:xsl="http://www.w3c.org/1999/XSL/Transform";
        version="2.0">
     <xsl:variable name="elem" as="element()">
        <elem a="value"/>
      </xsl:variable>
     <xsl:template match="/">
        <xsl:sequence select="$elem/@a"/>
      </xsl:template>
   </xsl:stylesheet>

Thanks for this, Florent! I guess more of what I was asking was along the lines of given two scenarios where, as far as a human is concerned, the output is the same, would it be preferable to use xsl:sequence or xsl:value-of? For example,

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="2.0">

    <xsl:variable name="elem" as="element()">
        <elem>foo</elem>
    </xsl:variable>

    <xsl:template match="/">
        <xsl:sequence select="$elem/text()" />
    </xsl:template>

</xsl:stylesheet>

and

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="2.0">

    <xsl:variable name="elem" as="element()">
        <elem>foo</elem>
    </xsl:variable>

    <xsl:template match="/">
        <xsl:value-of select="$elem/text()" />
    </xsl:template>

</xsl:stylesheet>

will both produce 'foo' in the final serialized output.  In this regard,
is there a reason why one might use xsl:sequence over xsl:value-of or
vice-versa?

--
/M:D

M. David Peterson
http://mdavid.name | http://www.oreillynet.com/pub/au/2354 |
http://dev.aol.com/blog/3155

Current Thread