If your need to escape something like this will help
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match ="signature">
<xsl:variable name="escape">
<xsl:call-template name="escape_quot">
<xsl:with-param name="replace" select="@name"/>
</xsl:call-template>
</xsl:variable>
"name":"<xsl:value-of select="$escape" />",
</xsl:template>
<xsl:template name="escape_quot">
<xsl:param name="replace"/>
<xsl:choose>
<xsl:when test="contains($replace,'"')">
<xsl:value-of select="substring-before($replace,'"')"/>
<!-- escape quot-->
<xsl:text>\"</xsl:text>
<xsl:call-template name="escape_quot">
<xsl:with-param name="replace" select="substring-after($replace,'"')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$replace"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
This will generate the wonted output.
"name":"My \"case\"",
Update:
But would it not be sufficient to change the outward quot to an apostrophe.
with:
"name":'<xsl:value-of select="@name" />',
to get:
"name":'My "case"',
(This should be valid JSON)
"name":"xxxxx"
or\"name":\"xxxxx\"
. Or should the content of@name
be changed? โ hr_117"name":
My "case"ยด,` (This should be valid jason) โ hr_117