coredocumentimpl.java
来自「JAVA 所有包」· Java 代码 · 共 1,776 行 · 第 1/5 页
JAVA
1,776 行
} // fire user data NODE_RENAMED event callUserDataHandlers(at, null, UserDataHandler.NODE_RENAMED); } else { // we need to create a new object AttrNSImpl nat = new AttrNSImpl(this, namespaceURI, name); // register event listeners on new node copyEventListeners(at, nat); // remove user data from old node Hashtable data = removeUserDataTable(at); // move children to new node Node child = at.getFirstChild(); while (child != null) { at.removeChild(child); nat.appendChild(child); child = at.getFirstChild(); } // attach user data to new node setUserDataTable(nat, data); // and fire user data NODE_RENAMED event callUserDataHandlers(at, nat, UserDataHandler.NODE_RENAMED); // reattach attr to element if (el != null) { el.setAttributeNode(nat); } at = nat; } } // fire AttributeNameChanged event renamedAttrNode((Attr) n, at); return at; } default: { String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null); throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg); } } } /** * DOM Level 3 WD - Experimental * Normalize document. */ public void normalizeDocument(){ // No need to normalize if already normalized. if (isNormalized() && !isNormalizeDocRequired()) { return; } if (needsSyncChildren()) { synchronizeChildren(); } if (domNormalizer == null) { domNormalizer = new DOMNormalizer(); } if (fConfiguration == null) { fConfiguration = new DOMConfigurationImpl(); } else { fConfiguration.reset(); } domNormalizer.normalizeDocument(this, fConfiguration); isNormalized(true); //set the XMLversion changed value to false -- once we have finished //doing normalization xmlVersionChanged = false ; } /** * DOM Level 3 CR - Experimental * * The configuration used when <code>Document.normalizeDocument</code> is * invoked. * @since DOM Level 3 */ public DOMConfiguration getDomConfig(){ if (fConfiguration == null) { fConfiguration = new DOMConfigurationImpl(); } return fConfiguration; } /** * Returns the absolute base URI of this node or null if the implementation * wasn't able to obtain an absolute URI. Note: If the URI is malformed, a * null is returned. * * @return The absolute base URI of this node or null. * @since DOM Level 3 */ public String getBaseURI() { if (fDocumentURI != null && fDocumentURI.length() != 0 ) {// attribute value is always empty string try { return new URI(fDocumentURI).toString(); } catch (com.sun.org.apache.xerces.internal.util.URI.MalformedURIException e){ // REVISIT: what should happen in this case? return null; } } return fDocumentURI; } /** * DOM Level 3 WD - Experimental. */ public void setDocumentURI(String documentURI){ fDocumentURI = documentURI; } // // DOM L3 LS // /** * DOM Level 3 WD - Experimental. * Indicates whether the method load should be synchronous or * asynchronous. When the async attribute is set to <code>true</code> * the load method returns control to the caller before the document has * completed loading. The default value of this property is * <code>false</code>. * <br>Setting the value of this attribute might throw NOT_SUPPORTED_ERR * if the implementation doesn't support the mode the attribute is being * set to. Should the DOM spec define the default value of this * property? What if implementing both async and sync IO is impractical * in some systems? 2001-09-14. default is <code>false</code> but we * need to check with Mozilla and IE. */ public boolean getAsync() { return false; } /** * DOM Level 3 WD - Experimental. * Indicates whether the method load should be synchronous or * asynchronous. When the async attribute is set to <code>true</code> * the load method returns control to the caller before the document has * completed loading. The default value of this property is * <code>false</code>. * <br>Setting the value of this attribute might throw NOT_SUPPORTED_ERR * if the implementation doesn't support the mode the attribute is being * set to. Should the DOM spec define the default value of this * property? What if implementing both async and sync IO is impractical * in some systems? 2001-09-14. default is <code>false</code> but we * need to check with Mozilla and IE. */ public void setAsync(boolean async) { if (async) { String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null); throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg); } } /** * DOM Level 3 WD - Experimental. * If the document is currently being loaded as a result of the method * <code>load</code> being invoked the loading and parsing is * immediately aborted. The possibly partial result of parsing the * document is discarded and the document is cleared. */ public void abort() { } /** * DOM Level 3 WD - Experimental. * * Replaces the content of the document with the result of parsing the * given URI. Invoking this method will either block the caller or * return to the caller immediately depending on the value of the async * attribute. Once the document is fully loaded a "load" event (as * defined in [<a href='http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331'>DOM Level 3 Events</a>] * , except that the <code>Event.targetNode</code> will be the document, * not an element) will be dispatched on the document. If an error * occurs, an implementation dependent "error" event will be dispatched * on the document. If this method is called on a document that is * currently loading, the current load is interrupted and the new URI * load is initiated. * <br> When invoking this method the parameters used in the * <code>DOMParser</code> interface are assumed to have their default * values with the exception that the parameters <code>"entities"</code> * , <code>"normalize-characters"</code>, * <code>"check-character-normalization"</code> are set to * <code>"false"</code>. * <br> The result of a call to this method is the same the result of a * call to <code>DOMParser.parseWithContext</code> with an input stream * referencing the URI that was passed to this call, the document as the * context node, and the action <code>ACTION_REPLACE_CHILDREN</code>. * @param uri The URI reference for the XML file to be loaded. If this is * a relative URI, the base URI used by the implementation is * implementation dependent. * @return If async is set to <code>true</code> <code>load</code> returns * <code>true</code> if the document load was successfully initiated. * If an error occurred when initiating the document load, * <code>load</code> returns <code>false</code>.If async is set to * <code>false</code> <code>load</code> returns <code>true</code> if * the document was successfully loaded and parsed. If an error * occurred when either loading or parsing the URI, <code>load</code> * returns <code>false</code>. */ public boolean load(String uri) { return false; } /** * DOM Level 3 WD - Experimental. * Replace the content of the document with the result of parsing the * input string, this method is always synchronous. * @param source A string containing an XML document. * @return <code>true</code> if parsing the input string succeeded * without errors, otherwise <code>false</code>. */ public boolean loadXML(String source) { return false; } /** * DOM Level 3 WD - Experimental. * Save the document or the given node and all its descendants to a string * (i.e. serialize the document or node). * <br>The parameters used in the <code>LSSerializer</code> interface are * assumed to have their default values when invoking this method. * <br> The result of a call to this method is the same the result of a * call to <code>LSSerializer.writeToString</code> with the document as * the node to write. * @param node Specifies what to serialize, if this parameter is * <code>null</code> the whole document is serialized, if it's * non-null the given node is serialized. * @return The serialized document or <code>null</code> in case an error * occurred. * @exception DOMException * WRONG_DOCUMENT_ERR: Raised if the node passed in as the node * parameter is from an other document. */ public String saveXML(Node node) throws DOMException { if ( errorChecking && node != null && this != node.getOwnerDocument() ) { String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null); throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg); } DOMImplementationLS domImplLS = (DOMImplementationLS)DOMImplementationImpl.getDOMImplementation(); LSSerializer xmlWriter = domImplLS.createLSSerializer(); if (node == null) { node = this; } return xmlWriter.writeToString(node); } /** * Sets whether the DOM implementation generates mutation events * upon operations. */ void setMutationEvents(boolean set) { // does nothing by default - overidden in subclass } /** * Returns true if the DOM implementation generates mutation events. */ boolean getMutationEvents() { // does nothing by default - overriden in subclass return false; } // non-DOM factory methods /** * NON-DOM * Factory method; creates a DocumentType having this Document * as its OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building * DTD information unspecified.) * * @param name The name of the Entity we wish to provide a value for. * * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents, where * DTDs are not permitted. (HTML not yet implemented.) */ public DocumentType createDocumentType(String qualifiedName, String publicID, String systemID) throws DOMException { return new DocumentTypeImpl(this, qualifiedName, publicID, systemID); } // createDocumentType(String):DocumentType /** * NON-DOM * Factory method; creates an Entity having this Document * as its OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building * DTD information unspecified.) * * @param name The name of the Entity we wish to provide a value for. * * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents, where * nonstandard entities are not permitted. (HTML not yet * implemented.) */ public Entity createEntity(String name) throws DOMException { if (errorChecking && !isXMLName(name,xml11Version)) { String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null); throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg); } return new EntityImpl(this, name); } // createEntity(String):Entity /** * NON-DOM * Factory method; creates a Notation having this Document * as its OwnerDoc. (REC-DOM-Level-1-19981001 left the process of building * DTD information unspecified.) * * @param name The name of the Notation we wish to describe * * @throws DOMException(NOT_SUPPORTED_ERR) for HTML documents, where * notations are not permitted. (HTML not yet * implemented.) */ public Notation createNotation(String name) throws DOMException { if (errorChecking && !isXMLName(name,xml11Version)) { String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null); throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg); } return new NotationImpl(this, name); } // createNotation(String):Notation /** * NON-DOM Factory method: creates an element definition. Element * definitions hold default attribute values. */ public ElementDefinitionImpl createElementDefinition(String name) throws DOMException {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?