Re: [xsl] learned a lesson about XPath variable evaluations sorting in document order

Subject: Re: [xsl] 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
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