Mittwoch, 18. Juli 2012

passing javascript trough xsl, saxon, cocoon

passing javascript trough xsl goes like this:
<xsl:output method="xml" encoding="UTF-8" cdata-section-elements="js"/>


<template match "script" />
 <xsl:copy>/*<js>*/<value-select="." />/*</js>*/</xsl:copy>
</template>

..
using the saxon xhtml serializer, this produces a CDATA section within comments
   <script>/*<js><![CDATA[ */ .....script code ... /* ]]><js></script>
send this with content-type: text/html; charset=UTF-8 and script cdata content will be not html encoded in a coccon pieline the above solution does not help, as the cdata section will be "removed" by the next transformer. therefore in the cocoon sitemap.xmap file serializers area specify as follows: {http://www.w3.org/1999/xhtml}js {..} is the James Clark notation to specify the namespace of the tag...
<map:serializer mime-type="text/html; charset="UTF-8"src="my.XHTMLSerializer">
   <cdata-section-elements>{http://www.w3.org/1999/xhtml}js</cdata-section-elements>
   <doctype-public>html</doctype-public>
   <encoding>UTF-8</encoding>
</map:serializer>
<(code>

Keine Kommentare:

Kommentar veröffentlichen