[xsl] Creating strings with apos and replacing

Subject: [xsl] Creating strings with apos and replacing
From: "dvint@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 13 May 2025 18:40:35 -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">
<xsl:param name="INSTRING"/>
<xsl:value-of select="translate(replace(lower-case($INSTRING), ' ', '_'),
':()','')"/>
</xsl:function>


To the replace I wanted to add the ' character to replace with nothing. I tried adding \' \\' &apo; &apos;&apos; to no avail.

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="/">
<xsl:variable name="inputString" select="'This is a string with a single quote: 'example''" />
<xsl:variable name="outputString" select="translate($inputString, &apos;&apos;, '')" />
<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 &apos; in the content. I imagine it will be the same answer, but wanted to post this for completion of the question.

..dan

Current Thread