[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
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
|