could you please tell me how to set value in object property using xslt?
i try like this
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="html" doctype-public="XSLT-compat" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<script type="text/javascript">
<![CDATA[
var obj ={
a:"mm",
catalog:<xsl:value-of select="catalog"/>
}
]]>
</script>
<xsl:value-of select="catalog"/>
</xsl:template>
</xsl:transform>
http://xsltransform.net/6rewNyu
i want to create a object where i want to set its value in catalog
property
why it is not working ?
catalog:<xsl:value-of select="catalog"/>
You can't put XSLT code you want to execute into a CDATA section, so simply use
<script type="text/javascript">
var obj ={
a:"mm",
catalog: '<xsl:value-of select="normalize-space(catalog)"/>'
}
</script>
if you want to generate Javascript code where part of the code is computed by XSLT.