|
Subject: [xsl] What is a bulletproof way to assign a variable this value: single quote, value of an element, single quote? From: "Roger L Costello costello@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 13 May 2024 13:05:27 -0000 |
Hi Folks,
The value of $legacy-elmt is this element:
<test>Hello, world</test>
Create a variable which holds between single quotes the value of the element
that $legacy-elmt holds. Do this using a two-step process:
<xsl:variable name="tmp-legacy-elmt-value" as="xs:string+">
<xsl:text>'</xsl:text>
<xsl:value-of select="string($legacy-elmt)"/>
<xsl:text>'</xsl:text>
</xsl:variable>
<xsl:variable name="legacy-elmt-name" as="xs:string">
<xsl:value-of select="$tmp-legacy-elmt-value" separator=""/>
</xsl:variable>
$legacy-elmt-value = 'Hello, world'
That appears to work flawlessly, right?
Not so fast.
Suppose the value of $legacy-elmt is this element:
<test>O'Neil</test>
$legacy-elmt-value = 'O'Neil'
That is an error (unmatched single quote).
What is the best way to fix this error?
/Roger
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Is a Java program more li, Michael Kay mike@xxx | Thread | Re: [xsl] What is a bulletproof way, Martin Honnen martin |
| Re: [xsl] Is a Java program more li, Michael Kay mike@xxx | Date | Re: [xsl] What is a bulletproof way, Martin Honnen martin |
| Month |