[xsl] xsl:sequence

Subject: [xsl] xsl:sequence
From: "tom tom" <tomxsllist@xxxxxxxxxxx>
Date: Mon, 07 Aug 2006 10:34:08 +0100
Apologies for these seemingly random questions but I have read numerous resources and am still struggling to understand why xsl:sequence is so important.

1. What is meant when the XSLT 2 spec states:

xsl:sequence can return a sequence containing existing nodes, rather than constructing new nodes.

<xsl:sequence select="." /> is constructing new nodes in the output that is, in effect, a copy-of the context node. Is this particular construct not a good example of what the XSLT 2 spec above is referring to?

2. I also understand sequence allows you to construct a sequence of different datatypes in one expression,

What, then, is the point of the concat function in XSLT 2? ie could

<xsl:sequence select="concat(meta/brand/text(), ' | ', genre/text())"/>

be rewritten:

<xsl:sequence select="meta/brand/text(), ' | ', genre/text()"/>


3. The XSLT 2 spec provides the following example code:

<xsl:variable name="prices" as="xs:decimal*">
           <xsl:for-each select="//product">
                   <xsl:when test="@price">
                       <xsl:sequence select="@price"/>
                       <xsl:sequence select="@cost * 1.5"/>
       <xsl:value-of select="avg($prices)"/>

Does <xsl:sequence select="@price"/> not assign an attribute node to the variable $prices? If so surely this is wasteful?

Thanks in advance


Be the first to hear what's new at MSN - sign up to our free newsletters! http://www.msn.co.uk/newsletters

Current Thread