@Override public final void endElement( final String namespaceURI, final String localName, final String qName) throws SAXException { if (subdocument) { subdocumentHandler.endElement(namespaceURI, localName, qName); if (localName.equals(subdocumentRoot)) { subdocumentHandler.endDocument(); subdocument = false; } } else if (rootHandler != null) { rootHandler.endElement(namespaceURI, localName, qName); } }
/** * Perform a pre-order traversal non-recursive style. * * Note that TreeWalker assumes that the subtree is intended to represent * a complete (though not necessarily well-formed) document and, during a * traversal, startDocument and endDocument will always be issued to the * SAX listener. * * @param pos Node in the tree where to start traversal * * @throws TransformerException */ public void traverse(Node pos) throws org.xml.sax.SAXException { this.m_contentHandler.startDocument(); traverseFragment(pos); this.m_contentHandler.endDocument(); }
@Test public void partial() throws Exception { XMLInputFactory inputFactory = XMLInputFactory.newInstance(); XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(CONTENT)); eventReader.nextTag(); // skip to root StaxEventXMLReader xmlReader = new StaxEventXMLReader(eventReader); ContentHandler contentHandler = mock(ContentHandler.class); xmlReader.setContentHandler(contentHandler); xmlReader.parse(new InputSource()); verify(contentHandler).startDocument(); verify(contentHandler).startElement(eq("http://springframework.org/spring-ws"), eq("child"), eq("child"), any(Attributes.class)); verify(contentHandler).endElement("http://springframework.org/spring-ws", "child", "child"); verify(contentHandler).endDocument(); }
@Test public void partial() throws Exception { XMLInputFactory inputFactory = XMLInputFactory.newInstance(); XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(CONTENT)); streamReader.nextTag(); // skip to root assertEquals("Invalid element", new QName("http://springframework.org/spring-ws", "root"), streamReader.getName()); streamReader.nextTag(); // skip to child assertEquals("Invalid element", new QName("http://springframework.org/spring-ws", "child"), streamReader.getName()); StaxStreamXMLReader xmlReader = new StaxStreamXMLReader(streamReader); ContentHandler contentHandler = mock(ContentHandler.class); xmlReader.setContentHandler(contentHandler); xmlReader.parse(new InputSource()); verify(contentHandler).setDocumentLocator(any(Locator.class)); verify(contentHandler).startDocument(); verify(contentHandler).startElement(eq("http://springframework.org/spring-ws"), eq("child"), eq("child"), any(Attributes.class)); verify(contentHandler).endElement("http://springframework.org/spring-ws", "child", "child"); verify(contentHandler).endDocument(); }
/** * Perform a pre-order traversal non-recursive style. * * Note that TreeWalker assumes that the subtree is intended to represent * a complete (though not necessarily well-formed) document and, during a * traversal, startDocument and endDocument will always be issued to the * SAX listener. * * @param pos Node in the tree where to start traversal * * @throws TransformerException */ public void traverse(Node pos) throws org.xml.sax.SAXException { this.m_contentHandler.startDocument(); traverseFragment(pos); this.m_contentHandler.endDocument(); }
@Override public final void endElement( final String namespaceURI, final String localName, final String qName) throws SAXException { if (subdocument) { subdocumentHandler.endElement(namespaceURI, localName, qName); if (localName.equals(subdocumentRoot)) { subdocumentHandler.endDocument(); subdocument = false; try { entryElement.closeEntry(); } catch (IOException ex) { throw new SAXException(ex.toString(), ex); } } } }
/** * Called by the transformer to parse the "input source". We ignore the input source and, instead, * generate SAX events to the {@link #setContentHandler ContentHandler}. */ @Override public void parse(InputSource input) throws SAXException { Assert.assertTrue(this.handler != null); handler.startDocument(); AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "", ID, "", String.valueOf(this.system.getConfig().getSystemId())); handler.startElement("", DISTRIBUTED_SYSTEM, DISTRIBUTED_SYSTEM, atts); // Add generation methods here try { generateRemoteCommand(); generateDiscovery(); generateSSL(); generateCacheServers(); } catch (AdminException ex) { throw new SAXException( "An AdminException was thrown while generating XML.", ex); } handler.endElement("", DISTRIBUTED_SYSTEM, DISTRIBUTED_SYSTEM); handler.endDocument(); }
/** * {@inheritDoc} */ public void parse(XMLWritable xml) throws IOException, SAXException { if (xml == null) throw new NullPointerException("Parameter projectTeam must not be null"); if (this.handler == null) throw new IllegalStateException("ContentHandler not set"); // start handling the document this.handler.startDocument(); XMLWriter xw = new XMLWriterSAX(this.handler); xml.toXML(xw); this.handler.endDocument(); }
this.m_contentHandler.endDocument(); break; case DTM.ELEMENT_NODE : if(null == ns) ns = ""; this.m_contentHandler.endElement(ns, m_dtm.getLocalName(node), m_dtm.getNodeName(node));
@Test public void marshalSaxResult() throws Exception { ContentHandler contentHandler = mock(ContentHandler.class); SAXResult result = new SAXResult(contentHandler); marshaller.marshal(flight, result); InOrder ordered = inOrder(contentHandler); ordered.verify(contentHandler).startDocument(); ordered.verify(contentHandler).startElement(eq(""), eq("flight"), eq("flight"), isA(Attributes.class)); ordered.verify(contentHandler).startElement(eq(""), eq("flightNumber"), eq("flightNumber"), isA(Attributes.class)); ordered.verify(contentHandler).characters(isA(char[].class), eq(0), eq(2)); ordered.verify(contentHandler).endElement("", "flightNumber", "flightNumber"); ordered.verify(contentHandler).endElement("", "flight", "flight"); ordered.verify(contentHandler).endDocument(); }
public void parse() throws IOException, SAXException { if (_dom != null) { boolean isIncomplete = (_dom.getNodeType() != org.w3c.dom.Node.DOCUMENT_NODE); if (isIncomplete) { _sax.startDocument(); parse(_dom); _sax.endDocument(); } else { parse(_dom); } } }
this.m_contentHandler.endDocument(); break; case DTM.ELEMENT_NODE : if(null == ns) ns = ""; this.m_contentHandler.endElement(ns, m_dtm.getLocalName(node), m_dtm.getNodeName(node));
@Test public void marshalSAXResult() throws Exception { ContentHandler contentHandler = mock(ContentHandler.class); SAXResult result = new SAXResult(contentHandler); marshaller.marshal(flights, result); InOrder ordered = inOrder(contentHandler); ordered.verify(contentHandler).setDocumentLocator(isA(Locator.class)); ordered.verify(contentHandler).startDocument(); ordered.verify(contentHandler).startPrefixMapping("", "http://samples.springframework.org/flight"); ordered.verify(contentHandler).startElement(eq("http://samples.springframework.org/flight"), eq("flights"), eq("flights"), isA(Attributes.class)); ordered.verify(contentHandler).startElement(eq("http://samples.springframework.org/flight"), eq("flight"), eq("flight"), isA(Attributes.class)); ordered.verify(contentHandler).startElement(eq("http://samples.springframework.org/flight"), eq("number"), eq("number"), isA(Attributes.class)); ordered.verify(contentHandler).characters(isA(char[].class), eq(0), eq(2)); ordered.verify(contentHandler).endElement("http://samples.springframework.org/flight", "number", "number"); ordered.verify(contentHandler).endElement("http://samples.springframework.org/flight", "flight", "flight"); ordered.verify(contentHandler).endElement("http://samples.springframework.org/flight", "flights", "flights"); ordered.verify(contentHandler).endPrefixMapping(""); ordered.verify(contentHandler).endDocument(); }
this.m_contentHandler.startDocument(); this.m_contentHandler.endDocument();
/** * Finish visitor */ @Override public void close(Throwable error) throws IOException { try { contentHandler.endElement("", "", "EDITS"); if (error != null) { String msg = error.getMessage(); XMLUtils.addSaxString(contentHandler, "ERROR", (msg == null) ? "null" : msg); } contentHandler.endDocument(); } catch (SAXException e) { throw new IOException("SAX error: " + e.getMessage()); } out.close(); }
_sax.setDocumentLocator(this); _sax.startDocument(); Node next = node.getFirstChild(); while (next != null) { next = next.getNextSibling(); _sax.endDocument(); break; _sax.endElement(uri, localName, qname);
this.m_contentHandler.startDocument(); this.m_contentHandler.endDocument();
delegate.endElement(element.getUri(), element.getLocalName(), element.getQName()); break; char[] chars = block.getText().toCharArray(); delegate.characters(chars, 0, chars.length); delegate.endElement(XHTMLContentHandler.XHTML, "p", "p"); delegate.ignorableWhitespace(NL, 0, NL.length); delegate.endElement(XHTMLContentHandler.XHTML, "body", "body"); delegate.endElement(XHTMLContentHandler.XHTML, "html", "html"); delegate.endDocument();
inDocHandler.startDocument(); inDocHandler.startElement("", "classes", "classes", new AttributesImpl()); inDocHandler.endElement("", "classes", "classes"); inDocHandler.endDocument();
/** * Parses a subtree starting from the element e and * reports SAX2 events to the specified handler. * * @deprecated in JAXB 2.0 * Use {@link #scan(Element)} */ public void parse( Element e, ContentHandler handler ) throws SAXException { // it might be better to set receiver at the constructor. receiver = handler; setCurrentLocation( e ); receiver.startDocument(); receiver.setDocumentLocator(locator); visit(e); setCurrentLocation( e ); receiver.endDocument(); }