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

Re: xsl:sequence

Subject: Re: xsl:sequence
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 7 Aug 2006 11:20:55 +0100
Re:  xsl:sequence
> 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

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.