Subject: Re: [xsl] Re: Benefits of xsl.sequence From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 30 Sep 2008 09:22:48 +0100 |
> but is the benefits something we can measure in any meaningful sense? In some cases xsl:sequence may or may not be more efficient than using value-of, but that's not really the point. In most cases if you need to return a sequence from a template or function, xsl:sequence is the only option, if no other instruction can generate the same result, then efficiency doesn't really come into it. For example consider a function that concatenates two sequences which you don't really need to write as it is the comma operator <xsl:function name="f:concat"> <xsl:param name="a"/> <xsl:param name="a"/> <xsl:sequence select="$a,$b"/> </xsl:function> so f:concat( (1,2,3) , (4,5,6) ) is (1,2,3,4,5,6) If you replaced xsl:sequence by xsl:value-of then the result would not be a sequence of six items, but instead a sequence of one item, a text node with string value "1 2 3 4 5 6" which isn't the same thing at all. For sequenes of attomic values as here, you could use xsl:copy-of which which would be identical to xsl:sequence, but for sequences of nodes copy-of implies a copy which is (conceptually) a copy. Actually the efficicency quextion may be hard to answer as systems may go to some lengths to avoid actually copying nodes, so copy-of may be as efficient as sequence of, but the behaviour is different. Condider an identity function <xsl:finction name="f:ident"> <xsl:param name="x"/> <xsl:sequence select="$x"/> </xsl:function> f:ident($node) is the same node as $node, it has the same parent (if $node has a $parent), siblings, etc f:ident($node)/following-sibling::* is the same as $node/following-sibling::* If you replace xsl:sequence by xsl:value-of in the above then xsl:ident($node) would be a textnode with the string value of $node, and if you replace xsl:sequence by xsl:copy-of then $ident($node) would _look_ like $node but it would be a new node, with no parents or siblings. David ________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Re: Benefits of xsl.seque, Andrew Welch | Thread | RE: [xsl] Re: Benefits of xsl.seque, Michael Kay |
Re: [xsl] connection error, Andrew Welch | Date | RE: [xsl] Re: Benefits of xsl.seque, Michael Kay |
Month |