XML to JSP using XSL, namespace problem
843834Feb 6 2003 — edited Feb 7 2003I'm trying to convert an XML file with content data into a JSP that uses some custom tags, but can't seem to get the XSL transformer to stop printing out namespace declarations. I've also tried using the xsl:exclude-result-prefix attribute in the XSL literal element to stop the addition of xmlns:web in the output JSP, but it won't work. Any ideas?
How can I exclude the "xmlns:web=..." within the <web:section> tag?
******** Here's the output JSP (cleaned up a little):
<jsp:root xmlns:web="urn:jsptld:WEB-INF/tld/web.tld"
xmlns:jsp="http://java.sun.com/JSP/Page">
<jsp:directive.page errorPage="error-page.jsp" import="...">
<web:section xmlns:web="http://.../web" title="name">
<jsp:text>
Paragraph content
</jsp:text>
</web:section>
</jsp:root>
******** The XML file looks like:
<content>
<section name="Section">
<sub-section name="Sub-Section">
<paragraph>
Paragraph content
</paragraph>
</sub-section>
</section>
</content>
******** The XSL is:
<xsl:stylesheet version="1.0"
xmlns:xalan="http://xml.apache.org/xslt"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:web="http://.../web"
exclude-result-prefixes="#default http://.../web"
>
<xsl:output method="xml"
encoding="UTF-8"
indent="yes"
xalan:indent-amount="2"
omit-xml-declaration="yes"/>
<!-- Match document root -->
<xsl:template match="content">
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:web="urn:jsptld:WEB-INF/tld/web.tld">
<jsp:directive.page import="..."/>
<xsl:apply-templates select="*" />
</jsp:root>
</xsl:template>
<!-- Match section -->
<xsl:template match="section">
<web:section title="name">
<jsp:text>
<xsl:apply-templates select="*" />
</jsp:text>
</web:section>
</xsl:template>
</xsl:stylesheet>