Working on JAXP 1.4 support.

This commit is contained in:
Arjen Poutsma
2007-12-21 01:40:28 +00:00
parent 64278f0842
commit 99f8f7299e
2 changed files with 6 additions and 3 deletions

View File

@@ -19,7 +19,6 @@ package org.springframework.xml.dom;
import java.util.ArrayList;
import java.util.List;
import org.springframework.util.Assert;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -29,6 +28,8 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import org.springframework.util.Assert;
/**
* SAX <code>ContentHandler</code> that transforms callback calls to DOM <code>Node</code>s.
*
@@ -100,7 +101,9 @@ public class DomContentHandler extends DefaultHandler {
String attrUri = attributes.getURI(i);
String attrQname = attributes.getQName(i);
String value = attributes.getValue(i);
element.setAttributeNS(attrUri, attrQname, value);
if (!attrQname.startsWith("xmlns")) {
element.setAttributeNS(attrUri, attrQname, value);
}
}
parent.appendChild(element);
elements.add(element);

View File

@@ -56,7 +56,7 @@ public class DomContentHandlerTest extends XMLTestCase {
documentBuilderFactory.setNamespaceAware(true);
documentBuilder = documentBuilderFactory.newDocumentBuilder();
result = documentBuilder.newDocument();
xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
}
public void testContentHandlerDocument() throws Exception {