Permalink
Browse files

Issue #60 - put in a check to confirm JDOM2 is compliant.

It is... by virtue of the new NamespaceStack which does 'the right thing'.
  • Loading branch information...
1 parent 440d0a6 commit fd2182feea2598ce0ea53ffc1efc44c855cc6db9 @rolfl rolfl committed Jan 25, 2012
Showing with 33 additions and 0 deletions.
  1. +33 −0 test/src/java/org/jdom2/test/cases/output/TestSAXOutputter.java
@@ -1109,4 +1109,37 @@ public void testOutputDocumentOmitDeclaration() {
// Cannot test for formatting outside of root element
}
+ @Test
+ public void testNoNamespaceIssue60 () throws JDOMException {
+ Document doc = new Document();
+ Namespace ns = Namespace.getNamespace("myurl");
+ Element root = new Element("root", ns);
+ Element child = new Element("child", ns);
+ root.addContent(child);
+ doc.setRootElement(root);
+ final String[] count = new String[1];
+
+ child.setAttribute("att", "val");
+
+ ContentHandler ch = new DefaultHandler2() {
+ @Override
+ public void startPrefixMapping(String pfx, String uri)
+ throws SAXException {
+ if ("".equals(pfx) && "".equals(uri)) {
+ fail("Should not be firing xmlns=\"\"");
+ }
+ if (!"".equals(pfx)) {
+ fail("we should not have prefix " + pfx);
+ }
+ if (count[0] != null) {
+ fail("we should not have multiple mappings " + pfx + " -> " + uri);
+ }
+ count[0] = uri;
+ }
+ };
+ SAXOutputter saxout = new SAXOutputter(ch);
+ saxout.output(doc);
+ assertTrue("myurl".equals(count[0]));
+ }
+
}

0 comments on commit fd2182f

Please sign in to comment.