Hi Steen

I think this sounds like a correct analysis of the bug to me. Wanna right a
little JUnit test case to prove its a bug, then when it gets fixed we know
its really fixed and that we won't break it again? If not let me know and
I'll dive in and help.

Thanks

James
----- Original Message -----
From: "Lehmann, Steen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 11, 2002 12:51 PM
Subject: [dom4j-dev] Issue with default namespace declaration on element in
other ns


> 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
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to