Transform using XSL 2.0 with JAXP
Hi,
I am transforming a xml file to a jsp using xsl. I am shifting from xsl 1.0 to 2.0.
I tried to use the "character-maps" functionality available in xsl "2.0".
I expected the below xsl code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes">
<xsl:output method="html" encoding="UTF-16" indent="yes" use-character-maps="cMaps"/>
<xsl:character-map name="cMaps">
<xsl:output-character character="? string="<%"/>
<xsl:output-character character="? string="%>"/>
</xsl:character-map>
<xsl:template match="/">
<xsl:text>?lt;/xsl:text>
</xsl:template>
</xsl:stylesheet>
To generate the following:
<% %>
The expected transformation of character-maps does not work when I use "javax.xml.transform" package for transformation.
Following is the piece of code which I use for transformation
try {
javax.xml.transform.TransformerFactory tFactory = javax.xml.transform.TransformerFactory.newInstance();
javax.xml.transform.Transformer transformer = tFactory.newTransformer(stXsl);
transformer.transform(stInput, srOutput);
catch (Exception ex) {
}
The above transformation generates?/i>
The xsl seems to be correct as I get the expected output when I use XML Spy.
Do I need to something more in my java code for using xsl 2.0.
Regards
Anup

