[xsl] JSON strings in XML attributes

Subject: [xsl] JSON strings in XML attributes
From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx>
Date: Wed, 29 Aug 2012 19:23:14 +0200
The hipsters at Amazon had the brilliant idea to cram JSON into HTML attributes in their KF8 format, such as in
<a class="app-amzn-magnify" data-app-amzn-magnify='{targetId:"fs1-txt2-magTarget", sourceId:"fs1-2-txt", ordinal:1}'>


(Using a distinct custom attribute for each property in the flat JSON structure apparently wasnt an option for them.)

Since
 we are using XSLT to generate the HTML,
 strings in JSON have to be double-quote-delimited,
 the KF8 renderer apparently doesnt parse &#34; to ",
 our XSLT processor uses double quotes as attribute delimiters by default:

Is there a way to tell an XSLT 2 processor to serialize attribute delimiters as single quotes and keep double quotes unescaped in attribute values? Otherwise, wed have to resort to some string postprocessing of the serialized XML.

Gerrit

Current Thread