/** * Serializes the specified <code>Document</code>, writing it to the given * <code>Writer</code>. */ public static void writeDocument(Document doc, Writer w) throws IOException { AbstractDocument d = (AbstractDocument) doc; if (doc.getDocumentElement() == null) { throw new IOException("No document element"); } NSMap m = NSMap.create(); for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { writeNode(n, w, m, "1.1".equals(d.getXmlVersion())); } }
if (name.startsWith("xmlns")) { if (name.length() == 5) { m = m.declare("", a.getNodeValue()); } else { String prefix = name.substring(6); m = m.declare(prefix, a.getNodeValue()); tagName = n.getNodeName(); w.write(tagName); if (!"".equals(m.getNamespace(""))) { w.write(" xmlns=\"\""); m = m.declare("", ""); if (ns.equals(m.getNamespace(prefix))) { tagName = n.getNodeName(); w.write(tagName); } else { prefix = m.getPrefixForElement(ns); if (prefix == null) { prefix = m.getNewPrefix(); tagName = prefix + ':' + n.getLocalName(); w.write(tagName + " xmlns:" + prefix + "=\"" + contentToString(ns, isXML11) + '"'); m = m.declare(prefix, ns); } else { if (prefix.equals("")) { !("xmlns".equals(prefix) || name.equals("xmlns"))) { if (prefix != null
if (name.startsWith("xmlns")) { if (name.length() == 5) { m = m.declare("", a.getNodeValue()); } else { String prefix = name.substring(6); m = m.declare(prefix, a.getNodeValue()); tagName = n.getNodeName(); w.write(tagName); if (!"".equals(m.getNamespace(""))) { w.write(" xmlns=\"\""); m = m.declare("", ""); if (ns.equals(m.getNamespace(prefix))) { tagName = n.getNodeName(); w.write(tagName); } else { prefix = m.getPrefixForElement(ns); if (prefix == null) { prefix = m.getNewPrefix(); tagName = prefix + ':' + n.getLocalName(); w.write(tagName + " xmlns:" + prefix + "=\"" + contentToString(ns, isXML11) + '"'); m = m.declare(prefix, ns); } else { if (prefix.equals("")) { !("xmlns".equals(prefix) || name.equals("xmlns"))) { if (prefix != null
if (name.startsWith("xmlns")) { if (name.length() == 5) { m = m.declare("", a.getNodeValue()); } else { String prefix = name.substring(6); m = m.declare(prefix, a.getNodeValue()); tagName = n.getNodeName(); w.write(tagName); if (!"".equals(m.getNamespace(""))) { w.write(" xmlns=\"\""); m = m.declare("", ""); if (ns.equals(m.getNamespace(prefix))) { tagName = n.getNodeName(); w.write(tagName); } else { prefix = m.getPrefixForElement(ns); if (prefix == null) { prefix = m.getNewPrefix(); tagName = prefix + ':' + n.getLocalName(); w.write(tagName + " xmlns:" + prefix + "=\"" + contentToString(ns, isXML11) + '"'); m = m.declare(prefix, ns); } else { if (prefix.equals("")) { !("xmlns".equals(prefix) || name.equals("xmlns"))) { if (prefix != null
/** * Serializes the specified <code>Document</code>, writing it to the given * <code>Writer</code>. */ public static void writeDocument(Document doc, Writer w) throws IOException { AbstractDocument d = (AbstractDocument) doc; if (doc.getDocumentElement() == null) { throw new IOException("No document element"); } NSMap m = NSMap.create(); for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { writeNode(n, w, m, "1.1".equals(d.getXmlVersion())); } }
/** * Serializes the specified <code>Document</code>, writing it to the given * <code>Writer</code>. */ public static void writeDocument(Document doc, Writer w) throws IOException { AbstractDocument d = (AbstractDocument) doc; if (doc.getDocumentElement() == null) { throw new IOException("No document element"); } NSMap m = NSMap.create(); for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) { writeNode(n, w, m, "1.1".equals(d.getXmlVersion())); } }
/** * Declares a new prefix mapping by returning a new * <code>NSMap</code> object that links to this one. */ public NSMap declare(String prefix, String ns) { NSMap m = new NSMap(); m.prefix = prefix; m.ns = ns; m.next = this; m.nextPrefixNumber = this.nextPrefixNumber; return m; }
/** * Writes a node using the given writer. */ public static void writeNode(Node n, Writer w) throws IOException { if (n.getNodeType() == Node.DOCUMENT_NODE) { writeDocument((Document) n, w); } else { AbstractDocument d = (AbstractDocument) n.getOwnerDocument(); writeNode(n, w, NSMap.create(), d == null ? false : "1.1".equals(d.getXmlVersion())); } }
/** * Declares a new prefix mapping by returning a new * <code>NSMap</code> object that links to this one. */ public NSMap declare(String prefix, String ns) { NSMap m = new NSMap(); m.prefix = prefix; m.ns = ns; m.next = this; m.nextPrefixNumber = this.nextPrefixNumber; return m; }
/** * Declares a new prefix mapping by returning a new * <code>NSMap</code> object that links to this one. */ public NSMap declare(String prefix, String ns) { NSMap m = new NSMap(); m.prefix = prefix; m.ns = ns; m.next = this; m.nextPrefixNumber = this.nextPrefixNumber; return m; }
/** * Returns a new, generated namespace prefix. */ public String getNewPrefix() { String prefix; do { prefix = "a" + nextPrefixNumber++; } while (getNamespace(prefix) != null); return prefix; }
/** * Returns a new, generated namespace prefix. */ public String getNewPrefix() { String prefix; do { prefix = "a" + nextPrefixNumber++; } while (getNamespace(prefix) != null); return prefix; }
/** * Writes a node using the given writer. */ public static void writeNode(Node n, Writer w) throws IOException { if (n.getNodeType() == Node.DOCUMENT_NODE) { writeDocument((Document) n, w); } else { AbstractDocument d = (AbstractDocument) n.getOwnerDocument(); writeNode(n, w, NSMap.create(), d == null ? false : "1.1".equals(d.getXmlVersion())); } }
/** * Writes a node using the given writer. */ public static void writeNode(Node n, Writer w) throws IOException { if (n.getNodeType() == Node.DOCUMENT_NODE) { writeDocument((Document) n, w); } else { AbstractDocument d = (AbstractDocument) n.getOwnerDocument(); writeNode(n, w, NSMap.create(), d == null ? false : "1.1".equals(d.getXmlVersion())); } }
/** * Returns a new, generated namespace prefix. */ public String getNewPrefix() { String prefix; do { prefix = "a" + nextPrefixNumber++; } while (getNamespace(prefix) != null); return prefix; }