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: Florent Georges <darkman_spam@xxxxxxxx>
Date: Sat, 16 Jun 2007 18:18:45 +0200 (CEST)
"M. David Peterson" wrote:

  Hi David

> In XSLT 2.0, when should I use xsl:sequence, when should I use  
> xsl:value-of, and why?

  The difference is quite simple: xsl:sequence returns the result of
the evaluation of an XPath expression (that is, a sequence), while
xsl:value-of creates one new fresh text node from a sequence.  The
exact rules to build the text node value from a sequence of item()* are
described there:

    http://www.w3.org/TR/xslt20/#value-of
    http://www.w3.org/TR/xslt20/#constructing-simple-content

  You can also trying the following stylesheet, then replace
xsl:value-of by xsl:sequence:

    <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>

  Regards,

--drkm



















      _____________________________________________________________________________ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 

Current Thread