Skip to content

Element.setNamespace() can produce Namespace Conflicts #48

Closed
rolfl opened this Issue Oct 5, 2011 · 0 comments

1 participant

@rolfl
Collaborator
rolfl commented Oct 5, 2011

Namespace Conflicts happen when a Namespace is introduced that has the same prefix, but different URI as an existing Namespace.

For example, the following is illegal:

        Namespace nsa = Namespace.getNamespace("pfx","URIA");
        Namespace nsb = Namespace.getNamespace("pfx","URIB");

        Element emt = new Element("emt", nsa);
        emt.addNamespaceDeclaration(nsb); // should fail, and it *does*

but, the reverse should be true too, but it isn't:

        Namespace nsa = Namespace.getNamespace("pfx","URIA");
        Namespace nsb = Namespace.getNamespace("pfx","URIB");

        Element emt = new Element("emt");
        emt.addNamespaceDeclaration(nsb);
        emt.setNamespace(nsa);  // should fail, but does not.
@rolfl rolfl added a commit that closed this issue Oct 5, 2011
@rolfl rolfl Fixes #48 - Element.setNamespace() does not check for Namespace
Collisions.
Add bunch of JavaDoc to Element
Optimize the addNamespaceDeclaration a little bit.
Add tests to validate the fix
Increase test coverage for a few other things too.
c2167d7
@rolfl rolfl closed this in c2167d7 Oct 5, 2011
@rolfl rolfl added a commit that referenced this issue Oct 7, 2011
@rolfl rolfl Backport fixes for issue #48 and issue #2 from JDOM2
Bring back a bunch of JDOM2 jUnit test cases too to check the fixes.
6ee1279
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.