URGENT: XSLT transformer ignoring XML namespaces
843834Oct 2 2002 — edited Oct 3 2002Hi!
I'm trying to render an XML file, but my XSL stylesheet does not match tags containing namespaces prefixes, while it works perfectly with non prefixed tags!
I'm quite sure the stylesheet is correct because I tried to merge the same documents with another XSLT transformer (Marrowsoft Xselerator) and it works fine...
Do I have to set the transformer to be namespace-aware or something similar? How can I do that? I searched this formu up and down but still I couldn't find an answer...
My XML (printed just before rendering) is:
<?xml version="1.0" encoding="UTF-8"?>
<xml xmlns:d="it.whatever.data" xmlns:ds="it.whatever.dataSchema">
<ds:schema id="WMAFile">
<ds:elementType content="textOnly" id="File" name="src">
<ds:elementDescr>Path di un file</ds:elementDescr>
</ds:elementType>
</ds:schema>
<d:data>
<d:src>myfile.pdf</d:src>
</d:data>
</xml>
while the XSL looks like:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ds="it.whatever.dataSchema"
xmlns:d="it.whatever.content">
<xsl:output method="html" indent="yes"/>
<xsl:template match="xml">
<xsl:apply-templates select="d:data"/>
</xsl:template>
<xsl:template match="d:data">
<html>
<body>
<a target="_blank">
<xsl:attribute name="href">
<xsl:value-of select="d:src"/>
</xsl:attribute>
<b>Open PDF</b>
</a>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The XML is passed to the transformer in DOM format with the following code:
File xsl = new File(XSLfile);
File html = new File(HTMLfile);
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new StreamSource( xsl));
transformer.transform(new DOMSource(myXmlDomDocument), new StreamResult(new FileOutputStream(html)));
I'm using only standard interfaces in javax.xml.transform packages, so I don't know which implementation is used in facts.
My application is deployed on Bea Weblogic 7.0 application server.
Any help is more than welcomed!!! My task is due very soon...
Thanks in advance,
Enrico