xsl-list
[Top] [All Lists]

Re: [xsl] Constructing complex xs:string in variable

2019-10-10 07:44:34
Also let's not forget

<xsl:variable name="var" select="''prefix' || $somevar || 'part'"/>

(as long as we are on the topic)

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.

Cheers, Wendell

-----Original Message-----
From: Liam R. E. Quin liam(_at_)fromoldbooks(_dot_)org 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> 
Sent: Wednesday, October 9, 2019 10:57 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Constructing complex xs:string in variable

On Wed, 2019-10-09 at 13:28 +0000, Christian Roth mulberrytech- 
lists(_at_)kriro(_dot_)de wrote:
<xsl:variable name="var" as="xs:string">
  <xsl:text>prefix</xsl:text>
  <xsl:value-of select="'part1'"/>
  <!-- follows more complex code producing further fragments of 
desired result string --> </xsl:variable>


This gives me the error message

Yes - I'd probably write,
<xsl:variable name="var" as="xs:string"
  select="concat('prefix, 'part1', ....) "/>

In XSLT 3 you could also do,
<xsl:variable name="var"
as="xs:string">prefix{'part1'}....</xsl:variable>

Assuming some XSL ancestor has expand-text="yes"

Liam

--
Liam Quin, 
https://gcc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.delightfulcomputing.com%2F&amp;data=02%7C01%7Cwendell.piez%40nist.gov%7Cf20bdc8b741e40a1b2e908d74cc8e72f%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637062298077477279&amp;sdata=pv1dH6GdCW9MN1YblJAsuuF5p5vKemb%2B4qQwRWXy2lg%3D&amp;reserved=0
Available for XML/Document/Information Architecture/XSLT/ XSL/XQuery/Web/Text 
Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations:  
https://gcc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.fromoldbooks.org&amp;data=02%7C01%7Cwendell.piez%40nist.gov%7Cf20bdc8b741e40a1b2e908d74cc8e72f%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637062298077477279&amp;sdata=7lZSwqUXp95SSaY14fGCr26cFa%2F%2FgZw6%2FVddfINz%2Boc%3D&amp;reserved=0

--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>