There is a bug that can arise when sorting namespace nodes in a DOM tree into document order. I will document the bug (and a patch) on the sourceforge site. Thanks for reporting it.
Michael Kay

From: [] On Behalf Of Milan Trninic
Sent: 07 October 2004 17:49
Subject: RE: [saxon] is namespace axis supported?

Michael - thanks for the quick answer.
I was using xerces and saxon 7.9 and 8.1.
Here is some more info, note that this was done with saxon 8.1
Also note that I was using the exampleDOMtoDOMAlien method from saxon examples. The method is slightly modified because I was trying some other things - not related to this particular issue. The method is also listed below.
1. Failure:
<Root xmlns="">
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform  xmlns:xsl=""
 <xsl:template match="/">
  <xsl:element name="resultRoot" >
   <xsl:for-each select="//namespace::*[local-name() != '' ]">
It throws the ClassCastException in NodeWrapper in the method:
    public int compareOrder(NodeInfo other) {
        // TODO: use the DOM Level-3 compareDocumentPosition() method if available
        return Navigator.compareOrder(this, (SiblingCountingNode)other);
2. Works well:
If I use the following instance, without the child Property, there is no error:
<Root xmlns="">
The method:
  public void exampleDOMtoDOMAlien(String sourceID, String xslID)
          throws TransformerException, TransformerConfigurationException,
                 SAXException, IOException, ParserConfigurationException,
   //System.setProperty("javax.xml.parsers.DocumentBuilderFactory", factory);
   TransformerFactory tfactory = TransformerFactory.newInstance();
   //tfactory.setAttribute(FeatureKeys.TREE_MODEL, new Integer(Builder.STANDARD_TREE));
   Templates templates;
    DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
    System.err.println("Using DocumentBuilderFactory " + dfactory.getClass());
    System.err.println("Using DocumentBuilder " + docBuilder.getClass());
    Node doc = docBuilder.parse(new InputSource(new File(xslID).toURL().toString()));
    System.err.println("Stylesheet document built OK");
    DOMSource dsource = new DOMSource(doc);
    // If we don't do this, the transformer won't know how to
    // resolve relative URLs in the stylesheet.
    dsource.setSystemId(new File(xslID).toURL().toString());
    templates = tfactory.newTemplates(dsource);
   Transformer transformer = templates.newTransformer();
   DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
   DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
   Document doc = docBuilder.parse(new InputSource(new File(sourceID).toURL().toString()));
   Node bar = doc.getDocumentElement();
   System.err.println("Source document built OK");
    // added by MHK
   DOMSource ds = new DOMSource(doc);
   ds.setSystemId(new File(sourceID).toURL().toString());
    // end of addition
    // create a skeleton output document, to which
    // the transformation results will be added
   Document out = docBuilder.newDocument();
   Element a = out.getDocumentElement();
   Element extra = out.createElement("svg");
   DOMResult result = new DOMResult(extra);
   transformer.transform(ds, result);
   out.replaceChild(extra.getFirstChild(), extra);
   System.err.println("Transformation done OK");
   // Serialize the output so we can see the transformation actually worked
   Transformer serializer = tfactory.newTransformer();
   serializer.transform(new DOMSource(out), new StreamResult(System.out));

-----Original Message-----
From: [] On Behalf Of Michael Kay
Sent: Wednesday, October 06, 2004 16:06
Subject: RE: [saxon] is namespace axis supported?

The namespace axis should work with all kinds of Source. Which version of Saxon are you using, and which DOM implementation?
If there's a failure with a DOMSource then I'm not entirely surprised, because DOM allows all sorts of inconsistency to arise in the tree that can't be properly represented in the XPath data model, and there are lots of differences between different implementatons. But I'd like to know the details.
Michael Kay

From: [] On Behalf Of Milan Trninic
Sent: 06 October 2004 23:14
Subject: [saxon] is namespace axis supported?

I couldn't figure out whether Saxon (non-commercial) supports the namespace axis. The documentation (XPath syntax section) doesn't list it among the supported axis. However, it seems to be working ok if I use StreamSource, but not if I use DOMSource (reports an error in the latter case).
The expression I used is simple
<xsl:for-each select="//namespace::*">