Hi, I seem to have a problem with a document where a default namespace is declared, but not used, on the root element. I am unable to find any trace of the declaration, and so is getNamespaceForPrefix(null) on elements in the document.
Example document: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:wapforum:devicesheet" xmlns="urn:wapforum:devicesheet"> ... </xsd:schema> I think the problem is in SaxContentHandler (see below), where namespaces are added to elements. If the prefix has size=0 it is not added to the list of declared namespaces. I think this works in other documents because the root element is almost always in the default namespace, if any. protected void addDeclaredNamespaces(Element element) { Namespace elementNamespace = element.getNamespace(); for ( int size = namespaceStack.size(); declaredNamespaceIndex < size; declaredNamespaceIndex++ ) { Namespace namespace = namespaceStack.getNamespace(declaredNamespaceIndex); if ( namespace != elementNamespace ) { String prefix = namespace.getPrefix(); if ( prefix != null && prefix.length() > 0 ) { element.add( namespace ); } } } } I would fix this myself (remove the requirement that length() > 0) but would appreciate input on whether this really is an issue first. Cheers, -- Steen /** * Steen Lehmann - <mailto:[EMAIL PROTECTED]> * Senior Software Engineer (R&D), SilverStream Software * <http://www.silverstream.com> */ _______________________________________________ dom4j-dev mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-dev