/** * Returns a SAX {@code ContentHandler} that transforms callback calls to DOM {@code Node}s. * @param node the node to publish events to * @return the content handler */ public static ContentHandler createContentHandler(Node node) { return new DomContentHandler(node); }
/** * Returns a SAX {@code ContentHandler} that transforms callback calls to DOM {@code Node}s. * @param node the node to publish events to * @return the content handler */ public static ContentHandler createContentHandler(Node node) { return new DomContentHandler(node); }
@Test public void contentHandlerDocumentNamespacePrefixes() 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))); assertThat("Invalid result", result, isSimilarTo(expected)); }
@Test public void contentHandlerDocumentNoNamespacePrefixes() throws Exception { handler = new DomContentHandler(result); expected = documentBuilder.parse(new InputSource(new StringReader(XML_1))); xmlReader.setContentHandler(handler); xmlReader.parse(new InputSource(new StringReader(XML_1))); assertThat("Invalid result", result, isSimilarTo(expected)); }
@Test public void contentHandlerElement() throws Exception { Element rootElement = result.createElementNS("namespace", "root"); result.appendChild(rootElement); handler = new DomContentHandler(rootElement); expected = documentBuilder.parse(new InputSource(new StringReader(XML_2_EXPECTED))); xmlReader.setContentHandler(handler); xmlReader.parse(new InputSource(new StringReader(XML_2_SNIPPET))); assertThat("Invalid result", result, isSimilarTo(expected)); }
/** * Returns a SAX <code>ContentHandler</code> that transforms callback calls to DOM <code>Node</code>s. * * @param node the node to publish events to * @return the content handler */ public static ContentHandler createContentHandler(Node node) { return new DomContentHandler(node); }
/** * Returns a SAX {@code ContentHandler} that transforms callback calls to DOM {@code Node}s. * @param node the node to publish events to * @return the content handler */ public static ContentHandler createContentHandler(Node node) { return new DomContentHandler(node); }
/** * Returns a SAX {@code ContentHandler} that transforms callback calls to DOM {@code Node}s. * @param node the node to publish events to * @return the content handler */ public static ContentHandler createContentHandler(Node node) { return new DomContentHandler(node); }