Hi,
I run an xslt target in mu build.xml using xalan.
The input code of:
<![CDATA[<!-- $Id: about.jsp,v 1.12 2004/02/24 21:10:30 gturner Exp $ -->]]>
gets transformed into:
<!-- $Id: about.jsp,v 1.12 2004/02/24 21:10:30 gturner Exp $ -->
How do I prevent the CDATA from being transformed into spaces ? I need to
preserve my CDATA as it is in the input file for each *.jsp.
My ant target uses the foll taskdef :
<xslt style="src/metadata/transform/jsp.xsl"
basedir="src/web"
includes="*.jsp"
destdir="build/phoenix-war-jsp"
extension=".jsp"
force="true">
<factory>
<attribute name="http://xml.apache.org/xalan/properties/source-location"
value="true"/>
</factory>
<xmlcatalog refid="project.xmlcatalog"/>
</xslt>
1.jsp.xsl code:
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: jsp.xsl,v 1.1 2004/02/24 00:08:06 gturner Exp $ -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--<xsl:output method="xml" version="1.0" encoding="ISO-8859-1" />-->
<xsl:import href="jsp-output.xsl"/>
<xsl:import href="jsp-jamon.xsl"/>
</xsl:stylesheet>
2. jsp-jamon.xsl code:
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: jsp-jamon.xsl,v 1.1 2004/02/24 00:08:07 gturner Exp $ -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:ni="xalan://org.apache.xalan.lib.NodeInfo"
exclude-result-prefixes="xalan ni">
<!--<xsl:output method="xml" version="1.0" encoding="ISO-8859-1" />-->
<xsl:template match="jsp:root">
<xsl:copy>
<!-- Evil work-around for Xalan warning message about not being able to
copy the jsp:root version attribute which is mandatory for JSP -->
<xsl:attribute name="version">1.2</xsl:attribute>
<jsp:directive.page import="com.jamonapi.*"/>
<jsp:scriptlet>
<xsl:text>Monitor mon=MonitorFactory.start("</xsl:text>
<xsl:value-of select="substring-after(ni:systemId(), 'src/web/')"/>
<xsl:text>");</xsl:text>
</jsp:scriptlet>
<xsl:apply-templates select="node()|@*"/>
<jsp:scriptlet>
<xsl:text>mon.stop();</xsl:text>
</jsp:scriptlet>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
3. jsp-output.xsl code:
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: jsp-output.xsl,v 1.1 2004/02/24 00:08:07 gturner Exp $ -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xslt">
<xsl:output method="xml"
encoding="ISO-8859-1"
indent="yes"
xalan:indent-amount="2"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
TIA,
Vijay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list