Working on JAXP 1.4 support.
This commit is contained in:
@@ -25,8 +25,9 @@ import org.w3c.dom.Node;
|
||||
import org.w3c.dom.ProcessingInstruction;
|
||||
import org.w3c.dom.Text;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.Locator;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -37,7 +38,7 @@ import org.springframework.util.Assert;
|
||||
* @see org.w3c.dom.Node
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class DomContentHandler extends DefaultHandler {
|
||||
public class DomContentHandler implements ContentHandler {
|
||||
|
||||
private final Document document;
|
||||
|
||||
@@ -109,4 +110,28 @@ public class DomContentHandler extends DefaultHandler {
|
||||
elements.add(element);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unsupported
|
||||
*/
|
||||
|
||||
public void setDocumentLocator(Locator locator) {
|
||||
}
|
||||
|
||||
public void startDocument() throws SAXException {
|
||||
}
|
||||
|
||||
public void endDocument() throws SAXException {
|
||||
}
|
||||
|
||||
public void startPrefixMapping(String prefix, String uri) throws SAXException {
|
||||
}
|
||||
|
||||
public void endPrefixMapping(String prefix) throws SAXException {
|
||||
}
|
||||
|
||||
public void ignorableWhitespace(char ch[], int start, int length) throws SAXException {
|
||||
}
|
||||
|
||||
public void skippedEntity(String name) throws SAXException {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,15 +51,23 @@ public class DomContentHandlerTest extends XMLTestCase {
|
||||
private DocumentBuilder documentBuilder;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
xmlReader = XMLReaderFactory.createXMLReader();
|
||||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
documentBuilderFactory.setNamespaceAware(true);
|
||||
documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||
result = documentBuilder.newDocument();
|
||||
xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
|
||||
xmlReader = XMLReaderFactory.createXMLReader();
|
||||
}
|
||||
|
||||
public void testContentHandlerDocument() throws Exception {
|
||||
public void testContentHandlerDocumentNamespacePrefixes() throws Exception {
|
||||
xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
|
||||
handler = new DomContentHandler(result);
|
||||
expected = documentBuilder.parse(new InputSource(new StringReader(XML_1)));
|
||||
xmlReader.setContentHandler(handler);
|
||||
xmlReader.parse(new InputSource(new StringReader(XML_1)));
|
||||
assertXMLEqual("Invalid result", expected, result);
|
||||
}
|
||||
|
||||
public void testContentHandlerDocumentNoNamespacePrefixes() throws Exception {
|
||||
handler = new DomContentHandler(result);
|
||||
expected = documentBuilder.parse(new InputSource(new StringReader(XML_1)));
|
||||
xmlReader.setContentHandler(handler);
|
||||
|
||||
Reference in New Issue
Block a user