protected void writeXMLDeclaration() throws IOException { writeRaw("<?xml version=\"1.0\" encoding=\""); writeRaw(getEncoding()); writeRaw("\"?>"); // breakLine(); // subtle but important: omit newline }
private static Map getNamespacePrefixesInScope(Element element) { // if (isXom11Plus) { // fast path // try { // return getNamespacePrefixesInScopePublic(element); // } catch (Error e) { // isXom11Plus = false; // } // } // slow path return getNamespacePrefixesInScopeNonPublic(element); }
/** * Returns a string representation for debugging purposes. * * @return a string representation */ public String toString() { return "[" + "algorithm=" + getAlgorithm() + ", encoding=" + getEncoding() + ", indent=" + getIndent() + ", unicodeNormalizationFormC=" + getUnicodeNormalizationFormC() + "]"; }
/** * Serializes the given result sequence onto the given output stream. * This method does not auto-close the output stream. * * @param nodes * the result sequence to serialize * @param out * the stream to write to * @throws IOException * if an I/O error occured */ public void write(Nodes nodes, OutputStream out) throws IOException { SequenceSerializer ser; if (W3C_ALGORITHM.equals(getAlgorithm())) { ser = new W3CSerializer(out, getEncoding()); } else { ser = new WrapSerializer(out, getEncoding()); } ser.setIndent(getIndent()); ser.setUnicodeNormalizationFormC(getUnicodeNormalizationFormC()); // ser.setLineSeparator(getLineSeparator()); // ser.setMaxLength(getMaxLength()); // ser.setPreserveBaseURI(getPreserveBaseURI()); ser.write(nodes); }
public void write(Nodes nodes) throws IOException { Document doc = wrapSequence(nodes); write(doc); }
if (this.writeNamespaceDeclarationsInScope) { this.writeNamespaceDeclarationsInScope = false; writeNamespaceDeclarationsInScope(element); } else { super.writeNamespaceDeclarations(element);
public Nodes finishMakingElement(Element elem) { // if (DEBUG) System.err.println("finishlevel=" + level + ", name="+ elem.getLocalName()); if (level == 0) { // root element must always be present; // a document without root element is illegal in XOM mismatch = null; // help gc level--; return super.finishMakingElement(elem); } if (elem == mismatch) { // reset state mismatch = null; level--; return NONE; } if (level == localNames.length - 1) { // we've found an element matching the full path expression return transformMatch(elem); } level--; if (level < localNames.length - 1 && !hasChildElements(elem)) { // prune tree if mismatch or empty return NONE; } return super.finishMakingElement(elem); }
public Nodes makeText(String data) { // return mismatch == null ? child.makeText(data) : NONE; if (mismatch == null) { if (level == 0 && isWhitespaceOnly(data)) return NONE; // avoid accumulating whitespace garbage in root element (i.e. avoid hidden memory leak) else return child.makeText(data); } return NONE; }
private static boolean isWhitespaceOnly(String str) { for (int i=str.length(); --i >= 0; ) { if (!isWhitespace(str.charAt(i))) return false; } return true; }
public Element startMakingElement(String qname, String namespaceURI) { level++; // if (DEBUG) System.err.println("startlevel=" + level + ", name="+ qname); // check against path, if needed if (mismatch == null && level < localNames.length) { if (!isMatch(qname, namespaceURI)) { // build this element despite mismatch; // so we can reset state in finishMakingElement() mismatch = super.startMakingElement(qname, namespaceURI); return mismatch; } } if (mismatch == null) { // no mismatch so far, build this element return super.startMakingElement(qname, namespaceURI); } else { // mismatch; no need to build this element level--; return null; } }
/** * Serializes the given result sequence onto the given output stream. * This method does not auto-close the output stream. * * @param nodes * the result sequence to serialize * @param out * the stream to write to * @throws IOException * if an I/O error occured */ public void write(Nodes nodes, OutputStream out) throws IOException { SequenceSerializer ser; if (W3C_ALGORITHM.equals(getAlgorithm())) { ser = new W3CSerializer(out, getEncoding()); } else { ser = new WrapSerializer(out, getEncoding()); } ser.setIndent(getIndent()); ser.setUnicodeNormalizationFormC(getUnicodeNormalizationFormC()); // ser.setLineSeparator(getLineSeparator()); // ser.setMaxLength(getMaxLength()); // ser.setPreserveBaseURI(getPreserveBaseURI()); ser.write(nodes); }
/** * Returns a string representation for debugging purposes. * * @return a string representation */ public String toString() { return "[" + "algorithm=" + getAlgorithm() + ", encoding=" + getEncoding() + ", indent=" + getIndent() + ", unicodeNormalizationFormC=" + getUnicodeNormalizationFormC() + "]"; }
protected void writeXMLDeclaration() throws IOException { writeRaw("<?xml version=\"1.0\" encoding=\""); writeRaw(getEncoding()); writeRaw("\"?>"); // breakLine(); // subtle but important: omit newline }
public void write(Nodes nodes) throws IOException { Document doc = wrapSequence(nodes); write(doc); }
if (this.writeNamespaceDeclarationsInScope) { this.writeNamespaceDeclarationsInScope = false; writeNamespaceDeclarationsInScope(element); } else { super.writeNamespaceDeclarations(element);
public Nodes finishMakingElement(Element elem) { // if (DEBUG) System.err.println("finishlevel=" + level + ", name="+ elem.getLocalName()); if (level == 0) { // root element must always be present; // a document without root element is illegal in XOM mismatch = null; // help gc level--; return super.finishMakingElement(elem); } if (elem == mismatch) { // reset state mismatch = null; level--; return NONE; } if (level == localNames.length - 1) { // we've found an element matching the full path expression return transformMatch(elem); } level--; if (level < localNames.length - 1 && !hasChildElements(elem)) { // prune tree if mismatch or empty return NONE; } return super.finishMakingElement(elem); }
private static Map getNamespacePrefixesInScope(Element element) { // if (isXom11Plus) { // fast path // try { // return getNamespacePrefixesInScopePublic(element); // } catch (Error e) { // isXom11Plus = false; // } // } // slow path return getNamespacePrefixesInScopeNonPublic(element); }
public Nodes makeText(String data) { // return mismatch == null ? child.makeText(data) : NONE; if (mismatch == null) { if (level == 0 && isWhitespaceOnly(data)) return NONE; // avoid accumulating whitespace garbage in root element (i.e. avoid hidden memory leak) else return child.makeText(data); } return NONE; }
private static boolean isWhitespaceOnly(String str) { for (int i=str.length(); --i >= 0; ) { if (!isWhitespace(str.charAt(i))) return false; } return true; }
public Element startMakingElement(String qname, String namespaceURI) { level++; // if (DEBUG) System.err.println("startlevel=" + level + ", name="+ qname); // check against path, if needed if (mismatch == null && level < localNames.length) { if (!isMatch(qname, namespaceURI)) { // build this element despite mismatch; // so we can reset state in finishMakingElement() mismatch = super.startMakingElement(qname, namespaceURI); return mismatch; } } if (mismatch == null) { // no mismatch so far, build this element return super.startMakingElement(qname, namespaceURI); } else { // mismatch; no need to build this element level--; return null; } }