xslt - How to setup LibXslt in PHP to render some attributes with single quotes -


this in continuing need assign attribute value in single quote xslt.

the problem: surround attribute value single quote ' instead of double ".

use case: store json in attributes passed settings plugins etc. eg:

<div id="plugin-instance" data-plugin-options='{"opt1":"foo", "opt2": "baz\'s bar"}'/> 

g. ken holman answered:

unless vendor of xslt processor gives extension request this, out of hands. such serialization choices made processor , cannot specified in xslt stylesheet using standardized mechanisms. processor may offer this, haven't seen (not i've gone looking ... xml perspective, resulting information set unchanged regardless of attribute delimiter chosen).

q1: possible output single quotes libxslt in php?

q2: if q1 yes, possible output per-attribute basis? (eg: want attributes rendered single quotes).

thank time.

no, isn't possible libxslt. libxslt output double quotes &quot; inside attributes:

<div data-plugin-options="{&quot;opt1&quot;:&quot;foo&quot;, &quot;opt2&quot;: &quot;baz\'s bar&quot;}"></div> 

accessing contents of attribute javascript should yield correct json string.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

javascript - Backbone.js getting target attribute -

html - Repeat image to extend header to fill screen -