/** * Deep-clone a document, including fixing ownerDoc for the cloned * children. Note that this requires bypassing the WRONG_DOCUMENT_ERR * protection. I've chosen to implement it by calling importNode * which is DOM Level 2. * * @return org.w3c.dom.Node * @param deep boolean, iff true replicate children */ public Node cloneNode(boolean deep) { CoreDocumentImpl newdoc = new CoreDocumentImpl(); callUserDataHandlers(this, newdoc, UserDataHandler.NODE_CLONED); cloneNode(newdoc, deep); return newdoc; } // cloneNode(boolean):Node
public MathML(String qualifiedName, String publicID, String systemID) { this(new CoreDocumentImpl()); CoreDocumentImpl document = (CoreDocumentImpl) document(); document.setXmlEncoding("utf-8"); document.appendChild(new DocumentTypeImpl(document, qualifiedName, publicID, systemID)); }
/** * @deprecated This method is internal and only exists for * compatibility with older applications. New applications * should never call this method. */ public String getVersion() { return getXmlVersion(); }
if (needsSyncChildren()) { synchronizeChildren(); newdoc.appendChild(newdoc.importNode(kid, true, true, reversedIdentifiers));
newElement = createElement(source.getNodeName()); else newElement = createElementNS(source.getNamespaceURI(), source.getNodeName()); Attr newAttr = (Attr)importNode(attr, true, cloningDoc, reversedIdentifiers); newnode = createAttribute(source.getNodeName()); } else { newnode = createAttributeNS(source.getNamespaceURI(), source.getNodeName()); newnode = createAttribute(source.getNodeName()); newnode = createTextNode(source.getNodeValue()); break; newnode = createCDATASection(source.getNodeValue()); break; newnode = createEntityReference(source.getNodeName()); Entity srcentity = (Entity)source; EntityImpl newentity = (EntityImpl)createEntity(source.getNodeName()); newentity.setPublicId(srcentity.getPublicId()); newentity.setSystemId(srcentity.getSystemId());
ElementImpl el = (ElementImpl) n; if (el instanceof ElementNSImpl) { if (canRenameElements(namespaceURI, name, el)) { ((ElementNSImpl) el).rename(namespaceURI, name); callUserDataHandlers(el, null, UserDataHandler.NODE_RENAMED); el = replaceRenameElement(el, namespaceURI, name); if (namespaceURI == null && canRenameElements(null, name, el)) { el.rename(name); callUserDataHandlers(el, null, UserDataHandler.NODE_RENAMED); el = replaceRenameElement(el, namespaceURI, name); renamedElement((Element) n, el); return el; callUserDataHandlers(at, null, UserDataHandler.NODE_RENAMED); callUserDataHandlers(at, null, UserDataHandler.NODE_RENAMED); AttrNSImpl nat = (AttrNSImpl) createAttributeNS(namespaceURI, name); copyEventListeners(at, nat); Hashtable data = removeUserDataTable(at);
private ElementImpl replaceRenameElement(ElementImpl el, String namespaceURI, String name) { ElementNSImpl nel = (ElementNSImpl)createElementNS(namespaceURI, name); copyEventListeners(el, nel); Hashtable data = removeUserDataTable(el); setUserDataTable(nel, data); callUserDataHandlers(el, nel, UserDataHandler.NODE_RENAMED);
fNamespaceValidation = false; String xmlVersion = fDocument.getXmlVersion(); String schemaType = null; String [] schemaLocations = null; fDocument.clearIdentifiers(); new SimpleLocator(fDocument.fDocumentURI, fDocument.fDocumentURI, -1, -1 ), fDocument.encoding, fNamespaceContext, null); fValidationHandler.xmlDecl(fDocument.getXmlVersion(), fDocument.getXmlEncoding(), fDocument.getXmlStandalone() ? "yes" : "no", null); for (kid = fDocument.getFirstChild(); kid != null; kid = next) { next = kid.getNextSibling(); kid = normalizeNode(kid);
DOMImplementation thisImpl = this.getImplementation(); DOMImplementation otherImpl = source.getOwnerDocument().getImplementation(); otherImpl instanceof org.apache.xerces.dom.DeferredDOMImplementationImpl) { undeferChildren (node); undeferChildren (node); setUserDataTable(node,userData); break; setUserDataTable(node,userData); setUserDataTable(node,userData); setUserDataTable(node,userData); callUserDataHandlers(source, null, UserDataHandler.NODE_ADOPTED,userData);
fDocumentImpl.setXmlVersion (version); fDocumentImpl.setXmlEncoding (encoding); fDocumentImpl.setXmlStandalone ("yes".equals (standalone));
protected CoreDocumentImpl createDocument(DocumentType doctype) { return new CoreDocumentImpl(doctype); }
Element e = doc.createElementNS(namespaceURI, qualifiedName); doc.appendChild(e);
if(!getXmlVersion().equals(value)){ xmlVersionChanged = true ; isNormalized(false); version = value; if((getXmlVersion()).equals("1.1")){ xml11Version = true;
/** * Call user data handlers when a node is deleted (finalized) * @param n The node this operation applies to. * @param c The copy node or null. * @param operation The operation - import, clone, or delete. */ protected void callUserDataHandlers(Node n, Node c, short operation) { if (userData == null) { return; } //Hashtable t = (Hashtable) userData.get(n); if(n instanceof NodeImpl){ Hashtable t = ((NodeImpl)n).getUserDataRecord(); if (t == null || t.isEmpty()) { return; } callUserDataHandlers(n, c, operation,t); } }
/** * @deprecated This method is internal and only exists for * compatibility with older applications. New applications * should never call this method. */ public void setEncoding(String value) { setXmlEncoding(value); }
/** * Returns the number of changes to this node. */ protected int changes() { // we do not actually store this information on every node, we only // have a global indicator on the Document. Doing otherwise cost us too // much for little gain. return ownerDocument().changes(); }
public void addEventListener(String type, EventListener listener, boolean useCapture) { // simply forward to Document ownerDocument().addEventListener(this, type, listener, useCapture); }
/** * Denotes that this node has changed. */ protected void changed() { // we do not actually store this information on every node, we only // have a global indicator on the Document. Doing otherwise cost us too // much for little gain. ownerDocument().changed(); }
/** For DOM2 support. */ public CoreDocumentImpl(DocumentType doctype, boolean grammarAccess) { this(grammarAccess); if (doctype != null) { DocumentTypeImpl doctypeImpl; try { doctypeImpl = (DocumentTypeImpl) doctype; } catch (ClassCastException e) { String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null); throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg); } doctypeImpl.ownerDocument = this; appendChild(doctype); } }
/** * Writes the Kalumet agent XML log file using in-memory DOM. */ public synchronized void writeXMLFile() { try { OutputFormat format = new OutputFormat(); format.setLineWidth( 72 ); format.setIndenting( true ); format.setIndent( 3 ); format.setEncoding( "ISO-8859-1" ); XMLSerializer serializer = new XMLSerializer( new FileOutputStream( this.basedir + "/" + MAIN_LOG_FILE ), format ); serializer.serialize( this.toDOMElement( new CoreDocumentImpl( true ) ) ); } catch ( Exception e ) { LOG.error( "Can't write update log file.", e ); } }