[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSLT 2.0: When to use xsl:sequence, when to use x

Subject: Re: 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
Re:  XSLT 2.0: When to use xsl:sequence
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.