Reputation: 55
Can an XSLT variable value be passed to a JavaScript variable. If so how it can be done? I have the following xml file:
<b:blog-items>
<b:blog-item author="A124" dateTime="11/10/2013 14:00">
<b:title>This is a text title</b:title>
<b:text>
<b:paragraph>This is a paragraph</b:paragraph>
</b:text>
</b:blog-item>
</b:blog-items>
<a:authors>
<a:author id="A124">
<a:name>John</a:name>
<a:surname>Doe</a:surname>
<a:dob>13/12/1980</a:dob>
</a:author>
</a:authors>
With XSLT I am transforming it into an HTML and I am accessing all the values. Now I need to use JavaScript in order to link the author id from blog-items to authors. Does anyone have any ideas?
Upvotes: 0
Views: 145
Reputation: 2578
You can pass arbitrary data as non-HTML elements/attributes along with the generated DOM. Possibilities:
If HTML is not strict, just add arbitrary non-HTML element to HTML/HEAD.
If HTML is strict (checked against XML schema), you'll have to add xmlns attribute to the root element and non-HTML element should belong to that xmlns. You still pass it in HTML/HEAD.
if you are allowed to use HTML5, you can use HTML5 custom data attributes
Upvotes: 1