[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: Florent Georges <darkman_spam@xxxxxxxx>
Date: Sat, 16 Jun 2007 22:55:24 +0200 (CEST)
Re:  XSLT 2.0: When to use xsl:sequence
"M. David Peterson" wrote:


> 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:template match="/">
>          <xsl:sequence select="$elem/text()" />
>      </xsl:template>

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

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

  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 '5.7 "Sequence Constructors", this
is very useful, interesting and well, required to write
XSLT ;-)

  For an example:


      <xsl:output indent="yes" omit-xml-declaration="yes"/>

      <xsl:variable name="v" as="element()+">

      <xsl:variable name="s" select="
          $v/text(), 'a', $v/text()"/>

      <xsl:template match="/">
          <xsl:sequence select="$s"/>
          <xsl:value-of select="$s"/>


should produce:

    <value-of>1 a 1</value-of>

  I say "should" because I've really evaluated the example
with Saxon and got instead:

    <value-of>1 a1</value-of>

  So I reread '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.



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

Current Thread


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.
First Name
Last Name
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.