xsl-list
[Top] [All Lists]

[xsl] JSON strings in XML attributes

2012-08-29 12:23:42
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 wasn’t 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 doesn’t 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, we’d have to resort to some string postprocessing of the serialized XML.

Gerrit

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>