[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: xsl:sequence
> If a variable value is a > reference rather than a copy what advantages does that provide? Firstly, it saves the cost of doing a copy (actually Saxon makes a virtual copy, but it still has a cost). Secondly it means you can still navigate from the node to its original parent, ancestors, and siblings. Thirdly it means you can do identity-related operations such as union and "<<". Michael Kay http://www.saxonica.com/ > > > > > 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. > > I was thinking that an attribute node contains a text node. > Reading up on it an attribute node seems to *be* both the > attribute name and its value. When it is co-erced to an > atomic xs:double value it somehow loses the attribute name > part and just takes on the value - this is what I was > referring to as waste. > > > >From: David Carlisle <davidc@xxxxxxxxx> > >Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > >To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > >Subject: Re: xsl:sequence > >Date: Mon, 7 Aug 2006 11:20:55 +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. > > > >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 > > > > _________________________________________________________________ > Don't just search. Find. Check out the new MSN Search! > http://search.msn.click-url.com/go/onm00200636ave/direct/01/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|