If I remember correctly you get a syntax error because you're trying to use the apostrophe in some of the content you're trying to replace. What happens if you try to replace ' instead of ' ? (this should be the entity number for the apostrophe).
How to escape single quotes on converting Richtext Editor into JSON Data
from Chriztian Steinmeier answer the \n are normalized into
so I would replace like this:
How would I conver a single quote into \'
so my JSON Data would not be broken?
my current JSON Description (that's a Richtext control) XSLT is:
<xsl:variable name="varDescription" select="normalize-space(htmlContent)"/>
description: '<xsl:value-of select="$varDescription" disable-output-escaping="yes" />'
and I wanted to have something like:
<xsl:value-of select="Exslt.ExsltStrings:replace($varDescription, '\'', '\\\'')"
disable-output-escaping="yes" />
but I get a syntax error...
Hi Bruno
If I remember correctly you get a syntax error because you're trying to use the apostrophe in some of the content you're trying to replace. What happens if you try to replace ' instead of ' ? (this should be the entity number for the apostrophe).
<xsl:value-of select="Exslt.ExsltStrings:replace($varDescription, ''', '\\'')" disable-output-escaping="yes" />
Could this work or do I misunderstand what you're trying to do?
/Jan
Hej Jan,
I did try but I get syntax error :-/
http://www.balexandre.com/temp/2011-07-12_1137.png
Hi Bruno
Could you try this snippet:
I'm pretty sure this will replace the ' with a \'
/Kim A
Hej Kim,
works like a charm, thought I prefered to convert to ’ (open single quote)
Exslt.ExsltStrings:replace($varDescription, $string1, '’')
Thank you.
Cool. Yeah, you could do that as well - that's up to you :)
I know it's maybe not the most beautiful code to do it this way, but in some cases you just need to do what it takes to make it work right ;)
/Kim A
yeah, as long as it works :)
I'm missing some JSON converters from Umbraco.library, as JSON is now the ultimate data transfer type.
Would be a great adition.
:o)
is working on a reply...