[Top] [All Lists]

[xsl] Constructing complex xs:string in variable

2019-10-09 08:27:26
[re-sending - initial one didn't make it to the list…?]


I'm using XSLT2.

I need to construct a complex string in a variable. I wanted to use XSLT 
instructions for this, not pure XPath. I'm struggling with coercing the result 
of the <xsl:variable> body to a single xs:string, not a sequence of xs:string:

<xsl:variable name="var" as="xs:string">
  <xsl:value-of select="'part1'"/>
  <!-- follows more complex code producing further fragments of desired result 
string -->

This gives me the error message (Saxon HE 9): "A sequence of more than one item 
is not allowed as the value of variable $var ("prefix", "part1")"

Of course, I could declare the variable as xs:string+ and then use string-join( 
$var, '' ) on every use of $var, or create another variable that holds the 
concatenated result of $var.

Is there a better way to do this?

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>