public DocumentResult() { this(new SAXContentHandler()); }
contentHandler.setEntityResolver(thatEntityResolver); contentHandler.setInputSource(in); contentHandler.setIncludeInternalDTDDeclarations(internal); contentHandler.setIncludeExternalDTDDeclarations(external); contentHandler.setMergeAdjacentText(isMergeAdjacentText()); contentHandler.setStripWhitespaceText(isStripWhitespaceText()); contentHandler.setIgnoreComments(isIgnoreComments()); reader.setContentHandler(contentHandler); return contentHandler.getDocument(); } catch (Exception e) { if (e instanceof SAXParseException) {
public void endDocument() throws SAXException { super.endDocument(); if (xmlWriter != null) { xmlWriter.endDocument(); } }
public void processingInstruction(String target, String data) throws SAXException { if (mergeAdjacentText && textInTextBuffer) { completeCurrentTextNode(); } if (currentElement != null) { currentElement.addProcessingInstruction(target, data); } else { getDocument().addProcessingInstruction(target, data); } }
addDTDDeclaration(declaration); addExternalDTDDeclaration(declaration);
public void startElement(String namespaceURI, String localName, String qualifiedName, Attributes attributes) throws SAXException { if (mergeAdjacentText && textInTextBuffer) { completeCurrentTextNode(); } QName qName = namespaceStack.getQName(namespaceURI, localName, qualifiedName); Branch branch = currentElement; if (branch == null) { branch = getDocument(); } Element element = branch.addElement(qName); // add all declared namespaces addDeclaredNamespaces(element); // now lets add all attribute values addAttributes(element, attributes); elementStack.pushElement(element); currentElement = element; entity = null; // fixes bug527062 if (elementHandler != null) { elementHandler.onStart(elementStack); } }
/** * Parses the body of this tag and returns the parsed document */ protected Document parseBody(XMLOutput output) throws JellyTagException { SAXContentHandler handler = new SAXContentHandler(); XMLOutput newOutput = new XMLOutput(handler); try { handler.startDocument(); invokeBody( newOutput); handler.endDocument(); return handler.getDocument(); } catch (SAXException e) { throw new JellyTagException(e); } }
/** * DOCUMENT ME! * * @return the Document created by the transformation */ public Document getDocument() { return contentHandler.getDocument(); }
/** * Captures the XML fragment generated by the given closure into dom4j DOM tree * and return the root element. * * @return null * if nothing was generated. */ public Element redirectToDom(Closure c) { SAXContentHandler sc = new SAXContentHandler(); with(new XMLOutput(sc),c); return sc.getDocument().getRootElement(); }
public void startDocument() throws SAXException { super.startDocument(); if (xmlWriter != null) { xmlWriter.startDocument(); } }
public void characters(char[] parm1, int parm2, int parm3) throws SAXException { super.characters(parm1, parm2, parm3); if (!activeHandlers() && (xmlWriter != null)) { xmlWriter.characters(parm1, parm2, parm3); } }
((SAXContentHandler) contentHandler).setMergeAdjacentText(true);
public void startElement(String namespaceURI, String localName, String qualifiedName, Attributes attributes) throws SAXException { if (mergeAdjacentText && textInTextBuffer) { completeCurrentTextNode(); } QName qName = namespaceStack.getQName(namespaceURI, localName, qualifiedName); Branch branch = currentElement; if (branch == null) { branch = getDocument(); } Element element = branch.addElement(qName); // add all declared namespaces addDeclaredNamespaces(element); // now lets add all attribute values addAttributes(element, attributes); elementStack.pushElement(element); currentElement = element; entity = null; // fixes bug527062 if (elementHandler != null) { elementHandler.onStart(elementStack); } }
if (internalDTDsubset) { if (includeInternalDTDDeclarations) { addDTDDeclaration(new InternalEntityDecl(name, value)); addExternalDTDDeclaration(new InternalEntityDecl(name, value));
public void comment(char[] ch, int start, int end) throws SAXException { if (!ignoreComments) { if (mergeAdjacentText && textInTextBuffer) { completeCurrentTextNode(); } String text = new String(ch, start, end); if (!insideDTDSection && (text.length() > 0)) { if (currentElement != null) { currentElement.addComment(text); } else { getDocument().addComment(text); } } } }
public void startDTD(String name, String publicId, String systemId) throws SAXException { getDocument().addDocType(name, publicId, systemId); insideDTDSection = true; internalDTDsubset = true; }
protected Document roundTripSAX(Document document) throws Exception { // now lets write it back as SAX events to // a SAX ContentHandler which should build up a new document SAXContentHandler contentHandler = new SAXContentHandler(); SAXWriter saxWriter = new SAXWriter(contentHandler, contentHandler, contentHandler); saxWriter.write(document); Document newDocument = contentHandler.getDocument(); // lets ensure names are same newDocument.setName(document.getName()); assertDocumentsEqual(document, newDocument); return newDocument; }
public void startDocument() throws SAXException { super.startDocument(); if (xmlWriter != null) { xmlWriter.startDocument(); } }
public void characters(char[] parm1, int parm2, int parm3) throws SAXException { super.characters(parm1, parm2, parm3); if (!activeHandlers() && (xmlWriter != null)) { xmlWriter.characters(parm1, parm2, parm3); } }
contentHandler.setEntityResolver(thatEntityResolver); contentHandler.setInputSource(in); contentHandler.setIncludeInternalDTDDeclarations(internal); contentHandler.setIncludeExternalDTDDeclarations(external); contentHandler.setMergeAdjacentText(isMergeAdjacentText()); contentHandler.setStripWhitespaceText(isStripWhitespaceText()); contentHandler.setIgnoreComments(isIgnoreComments()); reader.setContentHandler(contentHandler); return contentHandler.getDocument(); } catch (Exception e) { if (e instanceof SAXParseException) {