xsl-list
[Top] [All Lists]

Re: [xsl] xsl:sequence

2006-08-07 03:21:16


Apologies for these seemingly random questions but I have read numerous 
resources and am still struggling to understand why xsl:sequence is so 
important.

It's important, especially in variable and function definitions, as it
allows the return of _existing_ nodes rather than copies of nodes.


<xsl:sequence select="." /> is constructing new nodes in the output that is, 
in effect, a copy-of the context node. 

No, it selects the current node. (unlike <xsl:copy-of which would
construct a copy). If the xsl:sequence is being used to generate
an output result tree, then the difference is slight, as there is an
implied copying anyway in that construction, but if the current template
is being used to construct the value of a variable.there is a big
difference. In one case the variable will have a reference to teh
current node, and in teh other it will have a reference to a copy.

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

concat serves a completely different purpose, it concatenates strings,
producing a single string.

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()"/>

The first one makes a sequence of one item, a string.

The second one makes a sequence of three items, a text node, a string and
a text node

Compare

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

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



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

it references an _existing_ attribute node, but this is coerced to an
atomic xsl:double value because of the as attribute which specifies the
variable holds a sequence of doubles. I'm not clear where you see the
waste.

David


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>