Subject: Re: [xsl] Creating strings with apos and replacing From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 13 May 2025 18:50:55 -0000 |
My main question is the correct way to use replace() to remove special characters and spaces that appear in document titles. Some I just want to remove and others I want to translate to something else.
I have this much working
<xsl:function name="ping:gen_id"> B B B B <xsl:param name="INSTRING"/> B B B B <xsl:value-of select="translate(replace(lower-case($INSTRING), ' ', '_'), B B B B ':()','')"/> </xsl:function>
To the replace I wanted to add the ' character to replace with nothing. I tried adding \' \\' &apo; '' to no avail.
In XPath 2.0 and later you can use two single quotes inside a single quoted string e.g. ':()''' or ''''.
B 'This is a string with a single quote: ''example'''
This iss a sample of a string I'm trying to modify:
"Step 9: Create the application's resource access grant"
So I asked coPilot what should be done and it came up with:
<xsl:template match="/"> B B B <xsl:variable name="inputString" select="'This is a string with a single quote: 'example''" /> B B B <xsl:variable name="outputString" select="translate($inputString, '', '')" /> B B B <xsl:value-of select="$outputString" /> </xsl:template>
This throws a different error around creating the inputString.
Unexpected token name "example" beyond end of expression
Which leads to the other part of my question about how you would create a string variable with an ' in the content. I imagine it will be the same answer, but wanted to post this for completion of the question.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Creating strings with apos an, dvint@xxxxxxxxx | Thread | Re: [xsl] Creating strings with apo, dvint dvint@xxxxxxxx |
[xsl] Creating strings with apos an, dvint@xxxxxxxxx | Date | Re: [xsl] Creating strings with apo, dvint dvint@xxxxxxxx |
Month |