I'm writing an XSLT template that need to output a valid xml file for an xml Sitemap.
<url>
<loc>
<xsl:value-of select="umbraco.library:NiceUrl($node/@id)"/>
</loc>
<lastmod>
<xsl:value-of select="concat($node/@updateDate,'+00:00')"/>
</lastmod>
</url>
Unfortunately, Url that is output contains an apostrophe - /what's-new.aspx
I need to escape the ' to '
for google Sitemap. Unfortunately every attempt I've tried treats the string ''
' as if it was ''' which is invalid - frustrating. XSLT can drive me mad sometimes.
Any ideas for a technique? (Assume I can find my way around XSLT 1.0 templates and functions)
Have you tried setting disable-output-escaping to yes for your xsl:value-of element:
Actually - this is probably the opposite of what you want.
How about wrapping the xsl:value-of in an xsl:text element?
Perhaps you should try to translate
'
to&apos;
The simple way to remove unwanted characters from your URL is to change the rules umbraco uses when it generates the NiceUrl.
Edit the config/umbracoSettings.config
add a rule to remove all apostrophes from NiceUrls like so:
Note: The contents of the "org" attribute is replaced with the contents of the element, here's another example:
This will work, you just need to change TWO params as given below
So you have
'
in your input, but you need the string
in your output?In your XSL file, replace
'
with&apos;
, using this find/replace implementation (unless you are using XSLT 2.0):Call it this way:
The problem is
'
is interpreted by XSL as'
.&apos;
will be interpreted as'
.