[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Question regarding namespaces
I have a stylesheet which I use to normalize various versions of a
DTD. Some old XML documents created against this DTD do not include
a default namespace declaration on the root element but the newer
ones do, and I think the way I have to handle this is to have two
templates in my stylesheet, one of which selects root elements
without a namespace and one which does:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mynamespace="namespaceURI" version="2.0"> <xsl:template match="rootElement"> <!-- do stuff when no namespace declaration present: older documents --> </xsl:template> <xsl:template match="mynamespace:rootElement"> <!-- do stuff when there is a namespace declaration present: newer documents --> </xsl:template> ... </xsl:stylesheet> Documents which have a namespace declaration specify it as <rootElement xmlns="namespaceURI">. I'm noticing that the stylesheet works fine when run under a debugger such as Oxygen. However, when I compile this stylesheet under Saxon- B 9-0-0-4j and run it as the first filter of a JAXP filter chain, the template with the namespace prefix gets invoked regardless of whether the XML document specifies a namespace on its root element or not. I put in some <xsl:message> statements to dump the in-scope namespaces, and the only one I see is the XML namespace - no reference to "namespaceURI". Any thoughts on what's going on here, or where my logic is faulty? Thanks Chris
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|