|
Subject: Re: [xsl] What is a bulletproof way to assign a variable this value: single quote, value of an element, single quote? From: "Piez, Wendell A. (Fed) wendell.piez@xxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 13 May 2024 14:49:49 -0000 |
Roger,
Use a character map so the apos character in "O'Neil" is rewritten into some
escaped form?
But Peter's solution is the best, assuming all your apos are actually rsquo.
Cheers, Wendell
-----Original Message-----
From: Roger L Costello costello@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Monday, May 13, 2024 9:06 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] What is a bulletproof way to assign a variable this value:
single quote, value of an element, single quote?
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] What is a bulletproof way, Peter Flynn peter@xx | Thread | Re: [xsl] What is a bulletproof way, Martin Honnen martin |
| Re: [xsl] What is a bulletproof way, Peter Flynn peter@xx | Date | Re: [xsl] What is a bulletproof way, Martin Honnen martin |
| Month |