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

Re: learned a lesson about XPath variable evaluations

Subject: Re: learned a lesson about XPath variable evaluations sorting in document order
From: "Liam R. E. Quin liam@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 17 Feb 2023 01:46:45 -0000
Re:  learned a lesson about XPath variable evaluations
On Thu, 2023-02-16 at 23:34 +0000, Chris Papademetrious
christopher.papademetrious@xxxxxxxxxxxx wrote:
>
> But if I move the text() evaluation from the <xsl:variable> to the
> <xsl:value-of>, then I get "123" instead:

As an aside, watch that many people (i don't know if this applies to
you) think text() is a function that returns teh string-value of a
node. In fact, it's anode test, that matches all text nodes in its
context, so given
  <chapter><p>So <em>very</em> happy!</p>></chapter>
then chapter/p/text() returns a sequence of two nodes whose string
values are "So " and " happy!" respectively.

In a context where strings are needed, elements will be converted to
strings automatically, or use data() as a function to do that.

End of aside :)

Useful to note how it can be useful that ! doesn't put nodes back into
document order :)

Note also that if you do xslt 3 streaming it becomes super important to
keep track of when you put nodes into variables as opposed to copies of
nodes (and sub-trees).

liam

--
Liam Quin,B https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations: B http://www.fromoldbooks.org

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.