[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Question regarding namespaces

Subject: Question regarding namespaces
From: Chris von See <chris@xxxxxxxxxxxxx>
Date: Mon, 7 Apr 2008 21:12:52 -0700
 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.