xsl-list
[Top] [All Lists]

Re: [xsl] Question regarding namespaces

2008-04-07 22:19:21
Never mind.  I answered my own question.

The filter chain in question actually has two Saxon compiled stylesheets in it. I discovered that when I run with only one of the two (the normalizer stylesheet) everything runs as expected, but when I insert the second Saxon-compiled stylesheet everything goes wonky. I'm guessing that this is because something in the execution of the second stylesheet is stomping on something needed by the first, which gets the two of them mixed up.

Apologies to the list.


Cheers
Chris

On Apr 7, 2008, at 9:12 PM, Chris von See wrote:

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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>