[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Constructing complex xs:string in variable
On Thu, 2019-10-10 at 12:45 +0000, Piez, Wendell A. (Fed) wendell.piez@xxxxxxxx wrote: > Also let's not forget > > <xsl:variable name="var" select="''prefix' || $somevar || 'part'"/> Or one of the examples from my XSLT 3 course - fold-left( ("boy", "with", "blue", "socks" ), (), function ($base, $new) { if (empty($base)) then $new else ($base || ' ' || $new) } ) which is starting to look like JavaScript. You have to keep in mind the backgrounds of the people who will be mantaining what you write, though. Using fold-left and a lambda function is a little silly in an example of this size, and needlessly complex, but in a larger example may make sense. The string joining operator, expecially when combined with other new operators such as -> and !, can also make XSLT veer away from being document-oriented and crash head-long with the old vine-covered stone wall of Perl or the modern concrete of Python. So generally i prefer to use concat() and string-join if the people reading the expressions will likely be document/text processing people. But a bmodernb JavaScript programmer (say) would be entirely at home with the example i just gave. > I agree that the distinction between strings and text nodes is a fine > one, but useful and important to understand. It represents one of the > boundaries between the regimented world of the tree and the open > world of XPath. It also is a frequent problem for newcomers, who often expect text() to be a function that returns the string value of a sub-tree. I wish it had been called textnode() instead. Liam -- Liam Quin, 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: 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
|