Java Code Examples for org.w3c.dom.NamedNodeMap#setNamedItem()
The following examples show how to use
org.w3c.dom.NamedNodeMap#setNamedItem() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractXmlNode.java From JVoiceXML with GNU Lesser General Public License v2.1 | 6 votes |
/** * {@inheritDoc} */ public final void setAttribute(final String name, final String value) { final NamedNodeMap attributes = node.getAttributes(); if (attributes == null) { return; } if (value == null) { // Remove the attribute if no value was specified. if (attributes.getNamedItem(name) != null) { attributes.removeNamedItem(name); } } else { // Remove a possibly existing attribute if (attributes.getNamedItem(name) != null) { attributes.removeNamedItem(name); } // Create a new attribute. final Document owner = node.getOwnerDocument(); final Node item = owner.createAttribute(name); item.setNodeValue(value); attributes.setNamedItem(item); } }
Example 2
Source File: DeferredElementImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** Synchronizes the data (name and value) for fast nodes. */ protected final void synchronizeData() { // no need to sync in the future needsSyncData(false); // fluff data DeferredDocumentImpl ownerDocument = (DeferredDocumentImpl)this.ownerDocument; // we don't want to generate any event for this so turn them off boolean orig = ownerDocument.mutationEvents; ownerDocument.mutationEvents = false; name = ownerDocument.getNodeName(fNodeIndex); // attributes setupDefaultAttributes(); int index = ownerDocument.getNodeExtra(fNodeIndex); if (index != -1) { NamedNodeMap attrs = getAttributes(); do { NodeImpl attr = (NodeImpl)ownerDocument.getNodeObject(index); attrs.setNamedItem(attr); index = ownerDocument.getPrevSibling(index); } while (index != -1); } // set mutation events flag back to its original value ownerDocument.mutationEvents = orig; }
Example 3
Source File: DOMResultBuilder.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
public void doctypeDecl(DocumentType node) throws XNIException { /** Create new DocumentType node for the target. */ if (fDocumentImpl != null) { DocumentType docType = fDocumentImpl.createDocumentType(node.getName(), node.getPublicId(), node.getSystemId()); final String internalSubset = node.getInternalSubset(); /** Copy internal subset. */ if (internalSubset != null) { ((DocumentTypeImpl) docType).setInternalSubset(internalSubset); } /** Copy entities. */ NamedNodeMap oldMap = node.getEntities(); NamedNodeMap newMap = docType.getEntities(); int length = oldMap.getLength(); for (int i = 0; i < length; ++i) { Entity oldEntity = (Entity) oldMap.item(i); EntityImpl newEntity = (EntityImpl) fDocumentImpl.createEntity(oldEntity.getNodeName()); newEntity.setPublicId(oldEntity.getPublicId()); newEntity.setSystemId(oldEntity.getSystemId()); newEntity.setNotationName(oldEntity.getNotationName()); newMap.setNamedItem(newEntity); } /** Copy notations. */ oldMap = node.getNotations(); newMap = docType.getNotations(); length = oldMap.getLength(); for (int i = 0; i < length; ++i) { Notation oldNotation = (Notation) oldMap.item(i); NotationImpl newNotation = (NotationImpl) fDocumentImpl.createNotation(oldNotation.getNodeName()); newNotation.setPublicId(oldNotation.getPublicId()); newNotation.setSystemId(oldNotation.getSystemId()); newMap.setNamedItem(newNotation); } append(docType); } }
Example 4
Source File: XmlUtils.java From semafor-semantic-parser with GNU General Public License v3.0 | 5 votes |
public static void addAttribute(Document doc, String name, Element e, String value) { Node attrNode = doc.createAttribute(name); attrNode.setNodeValue(value); NamedNodeMap attrs = e.getAttributes(); attrs.setNamedItem(attrNode); }
Example 5
Source File: DOMResultBuilder.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public void doctypeDecl(DocumentType node) throws XNIException { /** Create new DocumentType node for the target. */ if (fDocumentImpl != null) { DocumentType docType = fDocumentImpl.createDocumentType(node.getName(), node.getPublicId(), node.getSystemId()); final String internalSubset = node.getInternalSubset(); /** Copy internal subset. */ if (internalSubset != null) { ((DocumentTypeImpl) docType).setInternalSubset(internalSubset); } /** Copy entities. */ NamedNodeMap oldMap = node.getEntities(); NamedNodeMap newMap = docType.getEntities(); int length = oldMap.getLength(); for (int i = 0; i < length; ++i) { Entity oldEntity = (Entity) oldMap.item(i); EntityImpl newEntity = (EntityImpl) fDocumentImpl.createEntity(oldEntity.getNodeName()); newEntity.setPublicId(oldEntity.getPublicId()); newEntity.setSystemId(oldEntity.getSystemId()); newEntity.setNotationName(oldEntity.getNotationName()); newMap.setNamedItem(newEntity); } /** Copy notations. */ oldMap = node.getNotations(); newMap = docType.getNotations(); length = oldMap.getLength(); for (int i = 0; i < length; ++i) { Notation oldNotation = (Notation) oldMap.item(i); NotationImpl newNotation = (NotationImpl) fDocumentImpl.createNotation(oldNotation.getNodeName()); newNotation.setPublicId(oldNotation.getPublicId()); newNotation.setSystemId(oldNotation.getSystemId()); newMap.setNamedItem(newNotation); } append(docType); } }
Example 6
Source File: Hk2DatasourceManager.java From netbeans with Apache License 2.0 | 5 votes |
private static void appendAttr(Document doc, Node node, String name, String value, boolean force) { if(force || (name != null && name.length() > 0)) { Attr attr = doc.createAttribute(name); attr.setValue(value); NamedNodeMap attrs = node.getAttributes(); attrs.setNamedItem(attr); } }
Example 7
Source File: DeferredElementImpl.java From hottub with GNU General Public License v2.0 | 5 votes |
/** Synchronizes the data (name and value) for fast nodes. */ protected final void synchronizeData() { // no need to sync in the future needsSyncData(false); // fluff data DeferredDocumentImpl ownerDocument = (DeferredDocumentImpl)this.ownerDocument; // we don't want to generate any event for this so turn them off boolean orig = ownerDocument.mutationEvents; ownerDocument.mutationEvents = false; name = ownerDocument.getNodeName(fNodeIndex); // attributes setupDefaultAttributes(); int index = ownerDocument.getNodeExtra(fNodeIndex); if (index != -1) { NamedNodeMap attrs = getAttributes(); do { NodeImpl attr = (NodeImpl)ownerDocument.getNodeObject(index); attrs.setNamedItem(attr); index = ownerDocument.getPrevSibling(index); } while (index != -1); } // set mutation events flag back to its original value ownerDocument.mutationEvents = orig; }
Example 8
Source File: DeferredElementImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** Synchronizes the data (name and value) for fast nodes. */ protected final void synchronizeData() { // no need to sync in the future needsSyncData(false); // fluff data DeferredDocumentImpl ownerDocument = (DeferredDocumentImpl)this.ownerDocument; // we don't want to generate any event for this so turn them off boolean orig = ownerDocument.mutationEvents; ownerDocument.mutationEvents = false; name = ownerDocument.getNodeName(fNodeIndex); // attributes setupDefaultAttributes(); int index = ownerDocument.getNodeExtra(fNodeIndex); if (index != -1) { NamedNodeMap attrs = getAttributes(); do { NodeImpl attr = (NodeImpl)ownerDocument.getNodeObject(index); attrs.setNamedItem(attr); index = ownerDocument.getPrevSibling(index); } while (index != -1); } // set mutation events flag back to its original value ownerDocument.mutationEvents = orig; }
Example 9
Source File: Hk2DatasourceManager.java From netbeans with Apache License 2.0 | 5 votes |
private static void appendProperty(Document doc, Node node, String name, String value, boolean force) { if(force || (value != null && value.length() > 0)) { Node newProperty = doc.createElement("property");//NOI18N Attr nameAttr = doc.createAttribute("name");//NOI18N nameAttr.setValue(name); Attr valueAttr = doc.createAttribute("value");//NOI18N valueAttr.setValue(value); NamedNodeMap attrs = newProperty.getAttributes(); attrs.setNamedItem(nameAttr); attrs.setNamedItem(valueAttr); node.appendChild(newProperty); } }
Example 10
Source File: DeferredElementImpl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** Synchronizes the data (name and value) for fast nodes. */ protected final void synchronizeData() { // no need to sync in the future needsSyncData(false); // fluff data DeferredDocumentImpl ownerDocument = (DeferredDocumentImpl)this.ownerDocument; // we don't want to generate any event for this so turn them off boolean orig = ownerDocument.mutationEvents; ownerDocument.mutationEvents = false; name = ownerDocument.getNodeName(fNodeIndex); // attributes setupDefaultAttributes(); int index = ownerDocument.getNodeExtra(fNodeIndex); if (index != -1) { NamedNodeMap attrs = getAttributes(); do { NodeImpl attr = (NodeImpl)ownerDocument.getNodeObject(index); attrs.setNamedItem(attr); index = ownerDocument.getPrevSibling(index); } while (index != -1); } // set mutation events flag back to its original value ownerDocument.mutationEvents = orig; }
Example 11
Source File: DOMResultBuilder.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void doctypeDecl(DocumentType node) throws XNIException { /** Create new DocumentType node for the target. */ if (fDocumentImpl != null) { DocumentType docType = fDocumentImpl.createDocumentType(node.getName(), node.getPublicId(), node.getSystemId()); final String internalSubset = node.getInternalSubset(); /** Copy internal subset. */ if (internalSubset != null) { ((DocumentTypeImpl) docType).setInternalSubset(internalSubset); } /** Copy entities. */ NamedNodeMap oldMap = node.getEntities(); NamedNodeMap newMap = docType.getEntities(); int length = oldMap.getLength(); for (int i = 0; i < length; ++i) { Entity oldEntity = (Entity) oldMap.item(i); EntityImpl newEntity = (EntityImpl) fDocumentImpl.createEntity(oldEntity.getNodeName()); newEntity.setPublicId(oldEntity.getPublicId()); newEntity.setSystemId(oldEntity.getSystemId()); newEntity.setNotationName(oldEntity.getNotationName()); newMap.setNamedItem(newEntity); } /** Copy notations. */ oldMap = node.getNotations(); newMap = docType.getNotations(); length = oldMap.getLength(); for (int i = 0; i < length; ++i) { Notation oldNotation = (Notation) oldMap.item(i); NotationImpl newNotation = (NotationImpl) fDocumentImpl.createNotation(oldNotation.getNodeName()); newNotation.setPublicId(oldNotation.getPublicId()); newNotation.setSystemId(oldNotation.getSystemId()); newMap.setNamedItem(newNotation); } append(docType); } }
Example 12
Source File: DOMResultBuilder.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public void doctypeDecl(DocumentType node) throws XNIException { /** Create new DocumentType node for the target. */ if (fDocumentImpl != null) { DocumentType docType = fDocumentImpl.createDocumentType(node.getName(), node.getPublicId(), node.getSystemId()); final String internalSubset = node.getInternalSubset(); /** Copy internal subset. */ if (internalSubset != null) { ((DocumentTypeImpl) docType).setInternalSubset(internalSubset); } /** Copy entities. */ NamedNodeMap oldMap = node.getEntities(); NamedNodeMap newMap = docType.getEntities(); int length = oldMap.getLength(); for (int i = 0; i < length; ++i) { Entity oldEntity = (Entity) oldMap.item(i); EntityImpl newEntity = (EntityImpl) fDocumentImpl.createEntity(oldEntity.getNodeName()); newEntity.setPublicId(oldEntity.getPublicId()); newEntity.setSystemId(oldEntity.getSystemId()); newEntity.setNotationName(oldEntity.getNotationName()); newMap.setNamedItem(newEntity); } /** Copy notations. */ oldMap = node.getNotations(); newMap = docType.getNotations(); length = oldMap.getLength(); for (int i = 0; i < length; ++i) { Notation oldNotation = (Notation) oldMap.item(i); NotationImpl newNotation = (NotationImpl) fDocumentImpl.createNotation(oldNotation.getNodeName()); newNotation.setPublicId(oldNotation.getPublicId()); newNotation.setSystemId(oldNotation.getSystemId()); newMap.setNamedItem(newNotation); } append(docType); } }
Example 13
Source File: DeferredElementImpl.java From Bytecoder with Apache License 2.0 | 5 votes |
/** Synchronizes the data (name and value) for fast nodes. */ protected final void synchronizeData() { // no need to sync in the future needsSyncData(false); // fluff data DeferredDocumentImpl ownerDocument = (DeferredDocumentImpl)this.ownerDocument; // we don't want to generate any event for this so turn them off boolean orig = ownerDocument.mutationEvents; ownerDocument.mutationEvents = false; name = ownerDocument.getNodeName(fNodeIndex); // attributes setupDefaultAttributes(); int index = ownerDocument.getNodeExtra(fNodeIndex); if (index != -1) { NamedNodeMap attrs = getAttributes(); do { NodeImpl attr = (NodeImpl)ownerDocument.getNodeObject(index); attrs.setNamedItem(attr); index = ownerDocument.getPrevSibling(index); } while (index != -1); } // set mutation events flag back to its original value ownerDocument.mutationEvents = orig; }
Example 14
Source File: DeferredElementImpl.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** Synchronizes the data (name and value) for fast nodes. */ protected final void synchronizeData() { // no need to sync in the future needsSyncData(false); // fluff data DeferredDocumentImpl ownerDocument = (DeferredDocumentImpl)this.ownerDocument; // we don't want to generate any event for this so turn them off boolean orig = ownerDocument.mutationEvents; ownerDocument.mutationEvents = false; name = ownerDocument.getNodeName(fNodeIndex); // attributes setupDefaultAttributes(); int index = ownerDocument.getNodeExtra(fNodeIndex); if (index != -1) { NamedNodeMap attrs = getAttributes(); do { NodeImpl attr = (NodeImpl)ownerDocument.getNodeObject(index); attrs.setNamedItem(attr); index = ownerDocument.getPrevSibling(index); } while (index != -1); } // set mutation events flag back to its original value ownerDocument.mutationEvents = orig; }
Example 15
Source File: DeferredElementNSImpl.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** Synchronizes the data (name and value) for fast nodes. */ protected final void synchronizeData() { // no need to sync in the future needsSyncData(false); // fluff data DeferredDocumentImpl ownerDocument = (DeferredDocumentImpl) this.ownerDocument; // we don't want to generate any event for this so turn them off boolean orig = ownerDocument.mutationEvents; ownerDocument.mutationEvents = false; name = ownerDocument.getNodeName(fNodeIndex); // extract local part from QName int index = name.indexOf(':'); if (index < 0) { localName = name; } else { localName = name.substring(index + 1); } namespaceURI = ownerDocument.getNodeURI(fNodeIndex); type = (XSTypeDefinition)ownerDocument.getTypeInfo(fNodeIndex); // attributes setupDefaultAttributes(); int attrIndex = ownerDocument.getNodeExtra(fNodeIndex); if (attrIndex != -1) { NamedNodeMap attrs = getAttributes(); boolean seenSchemaDefault = false; do { AttrImpl attr = (AttrImpl) ownerDocument.getNodeObject(attrIndex); // Take special care of schema defaulted attributes. Calling the // non-namespace aware setAttributeNode() method could overwrite // another attribute with the same local name. if (!attr.getSpecified() && (seenSchemaDefault || (attr.getNamespaceURI() != null && attr.getNamespaceURI() != NamespaceContext.XMLNS_URI && attr.getName().indexOf(':') < 0))) { seenSchemaDefault = true; attrs.setNamedItemNS(attr); } else { attrs.setNamedItem(attr); } attrIndex = ownerDocument.getPrevSibling(attrIndex); } while (attrIndex != -1); } // set mutation events flag back to its original value ownerDocument.mutationEvents = orig; }
Example 16
Source File: DeferredElementNSImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** Synchronizes the data (name and value) for fast nodes. */ protected final void synchronizeData() { // no need to sync in the future needsSyncData(false); // fluff data DeferredDocumentImpl ownerDocument = (DeferredDocumentImpl) this.ownerDocument; // we don't want to generate any event for this so turn them off boolean orig = ownerDocument.mutationEvents; ownerDocument.mutationEvents = false; name = ownerDocument.getNodeName(fNodeIndex); // extract local part from QName int index = name.indexOf(':'); if (index < 0) { localName = name; } else { localName = name.substring(index + 1); } namespaceURI = ownerDocument.getNodeURI(fNodeIndex); type = (XSTypeDefinition)ownerDocument.getTypeInfo(fNodeIndex); // attributes setupDefaultAttributes(); int attrIndex = ownerDocument.getNodeExtra(fNodeIndex); if (attrIndex != -1) { NamedNodeMap attrs = getAttributes(); boolean seenSchemaDefault = false; do { AttrImpl attr = (AttrImpl) ownerDocument.getNodeObject(attrIndex); // Take special care of schema defaulted attributes. Calling the // non-namespace aware setAttributeNode() method could overwrite // another attribute with the same local name. if (!attr.getSpecified() && (seenSchemaDefault || (attr.getNamespaceURI() != null && attr.getNamespaceURI() != NamespaceContext.XMLNS_URI && attr.getName().indexOf(':') < 0))) { seenSchemaDefault = true; attrs.setNamedItemNS(attr); } else { attrs.setNamedItem(attr); } attrIndex = ownerDocument.getPrevSibling(attrIndex); } while (attrIndex != -1); } // set mutation events flag back to its original value ownerDocument.mutationEvents = orig; }
Example 17
Source File: AbstractDOMParser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * A notation declaration * * @param name The name of the notation. * @param identifier An object containing all location information * pertinent to this notation. * @param augs Additional information that may include infoset * augmentations. * * @throws XNIException Thrown by handler to signal an error. */ public void notationDecl (String name, XMLResourceIdentifier identifier, Augmentations augs) throws XNIException { // internal subset string String publicId = identifier.getPublicId (); String literalSystemId = identifier.getLiteralSystemId (); if (fInternalSubset != null && !fInDTDExternalSubset) { fInternalSubset.append ("<!NOTATION "); fInternalSubset.append (name); if (publicId != null) { fInternalSubset.append (" PUBLIC '"); fInternalSubset.append (publicId); if (literalSystemId != null) { fInternalSubset.append ("' '"); fInternalSubset.append (literalSystemId); } } else { fInternalSubset.append (" SYSTEM '"); fInternalSubset.append (literalSystemId); } fInternalSubset.append ("'>\n"); } // NOTE: We only know how to create these nodes for the Xerces // DOM implementation because DOM Level 2 does not specify // that functionality. -Ac // create full node if (fDocumentImpl !=null && fDocumentType != null) { NamedNodeMap notations = fDocumentType.getNotations (); if (notations.getNamedItem (name) == null) { NotationImpl notation = (NotationImpl)fDocumentImpl.createNotation (name); notation.setPublicId (publicId); notation.setSystemId (literalSystemId); notation.setBaseURI (identifier.getBaseSystemId ()); notations.setNamedItem (notation); } } // create deferred node if (fDocumentTypeIndex != -1) { boolean found = false; int nodeIndex = fDeferredDocumentImpl.getLastChild (fDocumentTypeIndex, false); while (nodeIndex != -1) { short nodeType = fDeferredDocumentImpl.getNodeType (nodeIndex, false); if (nodeType == Node.NOTATION_NODE) { String nodeName = fDeferredDocumentImpl.getNodeName (nodeIndex, false); if (nodeName.equals (name)) { found = true; break; } } nodeIndex = fDeferredDocumentImpl.getPrevSibling (nodeIndex, false); } if (!found) { int notationIndex = fDeferredDocumentImpl.createDeferredNotation ( name, publicId, literalSystemId, identifier.getBaseSystemId ()); fDeferredDocumentImpl.appendChild (fDocumentTypeIndex, notationIndex); } } }
Example 18
Source File: AbstractDOMParser.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * A notation declaration * * @param name The name of the notation. * @param identifier An object containing all location information * pertinent to this notation. * @param augs Additional information that may include infoset * augmentations. * * @throws XNIException Thrown by handler to signal an error. */ public void notationDecl (String name, XMLResourceIdentifier identifier, Augmentations augs) throws XNIException { // internal subset string String publicId = identifier.getPublicId (); String literalSystemId = identifier.getLiteralSystemId (); if (fInternalSubset != null && !fInDTDExternalSubset) { fInternalSubset.append ("<!NOTATION "); fInternalSubset.append (name); if (publicId != null) { fInternalSubset.append (" PUBLIC '"); fInternalSubset.append (publicId); if (literalSystemId != null) { fInternalSubset.append ("' '"); fInternalSubset.append (literalSystemId); } } else { fInternalSubset.append (" SYSTEM '"); fInternalSubset.append (literalSystemId); } fInternalSubset.append ("'>\n"); } // NOTE: We only know how to create these nodes for the Xerces // DOM implementation because DOM Level 2 does not specify // that functionality. -Ac // create full node if (fDocumentImpl !=null && fDocumentType != null) { NamedNodeMap notations = fDocumentType.getNotations (); if (notations.getNamedItem (name) == null) { NotationImpl notation = (NotationImpl)fDocumentImpl.createNotation (name); notation.setPublicId (publicId); notation.setSystemId (literalSystemId); notation.setBaseURI (identifier.getBaseSystemId ()); notations.setNamedItem (notation); } } // create deferred node if (fDocumentTypeIndex != -1) { boolean found = false; int nodeIndex = fDeferredDocumentImpl.getLastChild (fDocumentTypeIndex, false); while (nodeIndex != -1) { short nodeType = fDeferredDocumentImpl.getNodeType (nodeIndex, false); if (nodeType == Node.NOTATION_NODE) { String nodeName = fDeferredDocumentImpl.getNodeName (nodeIndex, false); if (nodeName.equals (name)) { found = true; break; } } nodeIndex = fDeferredDocumentImpl.getPrevSibling (nodeIndex, false); } if (!found) { int notationIndex = fDeferredDocumentImpl.createDeferredNotation ( name, publicId, literalSystemId, identifier.getBaseSystemId ()); fDeferredDocumentImpl.appendChild (fDocumentTypeIndex, notationIndex); } } }
Example 19
Source File: AbstractDOMParser.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * A notation declaration * * @param name The name of the notation. * @param identifier An object containing all location information * pertinent to this notation. * @param augs Additional information that may include infoset * augmentations. * * @throws XNIException Thrown by handler to signal an error. */ public void notationDecl (String name, XMLResourceIdentifier identifier, Augmentations augs) throws XNIException { // internal subset string String publicId = identifier.getPublicId (); String literalSystemId = identifier.getLiteralSystemId (); if (fInternalSubset != null && !fInDTDExternalSubset) { fInternalSubset.append ("<!NOTATION "); fInternalSubset.append (name); if (publicId != null) { fInternalSubset.append (" PUBLIC '"); fInternalSubset.append (publicId); if (literalSystemId != null) { fInternalSubset.append ("' '"); fInternalSubset.append (literalSystemId); } } else { fInternalSubset.append (" SYSTEM '"); fInternalSubset.append (literalSystemId); } fInternalSubset.append ("'>\n"); } // NOTE: We only know how to create these nodes for the Xerces // DOM implementation because DOM Level 2 does not specify // that functionality. -Ac // create full node if (fDocumentImpl !=null && fDocumentType != null) { NamedNodeMap notations = fDocumentType.getNotations (); if (notations.getNamedItem (name) == null) { NotationImpl notation = (NotationImpl)fDocumentImpl.createNotation (name); notation.setPublicId (publicId); notation.setSystemId (literalSystemId); notation.setBaseURI (identifier.getBaseSystemId ()); notations.setNamedItem (notation); } } // create deferred node if (fDocumentTypeIndex != -1) { boolean found = false; int nodeIndex = fDeferredDocumentImpl.getLastChild (fDocumentTypeIndex, false); while (nodeIndex != -1) { short nodeType = fDeferredDocumentImpl.getNodeType (nodeIndex, false); if (nodeType == Node.NOTATION_NODE) { String nodeName = fDeferredDocumentImpl.getNodeName (nodeIndex, false); if (nodeName.equals (name)) { found = true; break; } } nodeIndex = fDeferredDocumentImpl.getPrevSibling (nodeIndex, false); } if (!found) { int notationIndex = fDeferredDocumentImpl.createDeferredNotation ( name, publicId, literalSystemId, identifier.getBaseSystemId ()); fDeferredDocumentImpl.appendChild (fDocumentTypeIndex, notationIndex); } } }
Example 20
Source File: AbstractDOMParser.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * A notation declaration * * @param name The name of the notation. * @param identifier An object containing all location information * pertinent to this notation. * @param augs Additional information that may include infoset * augmentations. * * @throws XNIException Thrown by handler to signal an error. */ public void notationDecl (String name, XMLResourceIdentifier identifier, Augmentations augs) throws XNIException { // internal subset string String publicId = identifier.getPublicId (); String literalSystemId = identifier.getLiteralSystemId (); if (fInternalSubset != null && !fInDTDExternalSubset) { fInternalSubset.append ("<!NOTATION "); fInternalSubset.append (name); if (publicId != null) { fInternalSubset.append (" PUBLIC '"); fInternalSubset.append (publicId); if (literalSystemId != null) { fInternalSubset.append ("' '"); fInternalSubset.append (literalSystemId); } } else { fInternalSubset.append (" SYSTEM '"); fInternalSubset.append (literalSystemId); } fInternalSubset.append ("'>\n"); } // NOTE: We only know how to create these nodes for the Xerces // DOM implementation because DOM Level 2 does not specify // that functionality. -Ac // create full node if (fDocumentImpl !=null && fDocumentType != null) { NamedNodeMap notations = fDocumentType.getNotations (); if (notations.getNamedItem (name) == null) { NotationImpl notation = (NotationImpl)fDocumentImpl.createNotation (name); notation.setPublicId (publicId); notation.setSystemId (literalSystemId); notation.setBaseURI (identifier.getBaseSystemId ()); notations.setNamedItem (notation); } } // create deferred node if (fDocumentTypeIndex != -1) { boolean found = false; int nodeIndex = fDeferredDocumentImpl.getLastChild (fDocumentTypeIndex, false); while (nodeIndex != -1) { short nodeType = fDeferredDocumentImpl.getNodeType (nodeIndex, false); if (nodeType == Node.NOTATION_NODE) { String nodeName = fDeferredDocumentImpl.getNodeName (nodeIndex, false); if (nodeName.equals (name)) { found = true; break; } } nodeIndex = fDeferredDocumentImpl.getPrevSibling (nodeIndex, false); } if (!found) { int notationIndex = fDeferredDocumentImpl.createDeferredNotation ( name, publicId, literalSystemId, identifier.getBaseSystemId ()); fDeferredDocumentImpl.appendChild (fDocumentTypeIndex, notationIndex); } } }