Java 类org.w3c.dom.Entity 实例源码

项目:javify    文件:SAXEventSink.java   
public void internalEntityDecl(String name, String value)
  throws SAXException
{
  if (interrupted)
    {
      return;
    }
  if (!inDTD)
    throw new SAXException("internal entity decl outside DTD");
  DomDoctype doctype = (DomDoctype) ctx;
  Entity entity = doctype.declareEntity(name, null, null, null);
  if (entity != null)
    {
      Node text = doc.createTextNode(value);
      entity.appendChild(text);
    }
}
项目:jvm-stm    文件:SAXEventSink.java   
public void internalEntityDecl(String name, String value)
  throws SAXException
{
  if (interrupted)
    {
      return;
    }
  if (!inDTD)
    throw new SAXException("internal entity decl outside DTD");
  DomDoctype doctype = (DomDoctype) ctx;
  Entity entity = doctype.declareEntity(name, null, null, null);
  if (entity != null)
    {
      Node text = doc.createTextNode(value);
      entity.appendChild(text);
    }
}
项目:chromedevtools    文件:DomUtils.java   
static <R> R visitNode(Node node, NodeVisitor<R> visitor) {
  switch (node.getNodeType()) {
    case Node.ELEMENT_NODE: return visitor.visitElement((Element) node);
    case Node.ATTRIBUTE_NODE: return visitor.visitAttr((Attr) node);
    case Node.TEXT_NODE: return visitor.visitText((Text) node);
    case Node.CDATA_SECTION_NODE: return visitor.visitCDATASection((CDATASection) node);
    case Node.ENTITY_REFERENCE_NODE: return visitor.visitEntityReference((EntityReference) node);
    case Node.ENTITY_NODE: return visitor.visitEntity((Entity) node);
    case Node.PROCESSING_INSTRUCTION_NODE:
        return visitor.visitProcessingInstruction((ProcessingInstruction) node);
    case Node.COMMENT_NODE: return visitor.visitComment((Comment) node);
    case Node.DOCUMENT_NODE: return visitor.visitDocument((Document) node);
    case Node.DOCUMENT_TYPE_NODE: return visitor.visitDocumentType((DocumentType) node);
    case Node.DOCUMENT_FRAGMENT_NODE:
        return visitor.visitDocumentFragment((DocumentFragment) node);
    case Node.NOTATION_NODE: return visitor.visitNotation((Notation) node);
    default: throw new RuntimeException();
  }
}
项目:JamVM-PH    文件:SAXEventSink.java   
public void internalEntityDecl(String name, String value)
  throws SAXException
{
  if (interrupted)
    {
      return;
    }
  if (!inDTD)
    throw new SAXException("internal entity decl outside DTD");
  DomDoctype doctype = (DomDoctype) ctx;
  Entity entity = doctype.declareEntity(name, null, null, null);
  if (entity != null)
    {
      Node text = doc.createTextNode(value);
      entity.appendChild(text);
    }
}
项目:gocd    文件:SaveContextVisitor.java   
public boolean enter(Entity entity) {
    String name = entity.getNodeName();
    String pubId = entity.getPublicId();
    String sysId = entity.getSystemId();
    String notation = entity.getNotationName();
    buffer.append("<!ENTITY ");
    buffer.append(name);
    if (pubId != null) {
        buffer.append(" PUBLIC \"");
        buffer.append(pubId);
        buffer.append("\"");
    }
    if (sysId != null) {
        buffer.append(" SYSTEM \"");
        buffer.append(sysId);
        buffer.append("\"");
    }
    if (notation != null) {
        buffer.append(" NDATA ");
        buffer.append(notation);
    }
    buffer.append(">");
    return true;
}
项目:classpath    文件:SAXEventSink.java   
public void internalEntityDecl(String name, String value)
  throws SAXException
{
  if (interrupted)
    {
      return;
    }
  if (!inDTD)
    throw new SAXException("internal entity decl outside DTD");
  DomDoctype doctype = (DomDoctype) ctx;
  Entity entity = doctype.declareEntity(name, null, null, null);
  if (entity != null)
    {
      Node text = doc.createTextNode(value);
      entity.appendChild(text);
    }
}
项目:OpenJSharp    文件:SAXImpl.java   
/**
 * The getUnparsedEntityURI function returns the URI of the unparsed
 * entity with the specified name in the same document as the context
 * node (see [3.3 Unparsed Entities]). It returns the empty string if
 * there is no such entity.
 */
public String getUnparsedEntityURI(String name)
{
    // Special handling for DOM input
    if (_document != null) {
        String uri = "";
        DocumentType doctype = _document.getDoctype();
        if (doctype != null) {
            NamedNodeMap entities = doctype.getEntities();

            if (entities == null) {
                return uri;
            }

            Entity entity = (Entity) entities.getNamedItem(name);

            if (entity == null) {
                return uri;
            }

            String notationName = entity.getNotationName();
            if (notationName != null) {
                uri = entity.getSystemId();
                if (uri == null) {
                    uri = entity.getPublicId();
                }
            }
        }
        return uri;
    }
    else {
        return super.getUnparsedEntityURI(name);
    }
}
项目:OpenJSharp    文件:DOMValidatorHelper.java   
public boolean isEntityUnparsed(String name) {
    if (fEntities != null) {
        Entity entity = (Entity) fEntities.getNamedItem(name);
        if (entity != null) {
            return (entity.getNotationName() != null);
        }
    }
    return false;
}
项目:OpenJSharp    文件:DOMResultBuilder.java   
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);
    }
}
项目:openjdk-jdk10    文件:SAXImpl.java   
/**
 * The getUnparsedEntityURI function returns the URI of the unparsed
 * entity with the specified name in the same document as the context
 * node (see [3.3 Unparsed Entities]). It returns the empty string if
 * there is no such entity.
 */
public String getUnparsedEntityURI(String name)
{
    // Special handling for DOM input
    if (_document != null) {
        String uri = "";
        DocumentType doctype = _document.getDoctype();
        if (doctype != null) {
            NamedNodeMap entities = doctype.getEntities();

            if (entities == null) {
                return uri;
            }

            Entity entity = (Entity) entities.getNamedItem(name);

            if (entity == null) {
                return uri;
            }

            String notationName = entity.getNotationName();
            if (notationName != null) {
                uri = entity.getSystemId();
                if (uri == null) {
                    uri = entity.getPublicId();
                }
            }
        }
        return uri;
    }
    else {
        return super.getUnparsedEntityURI(name);
    }
}
项目:openjdk-jdk10    文件:CoreDocumentImpl.java   
/**
 * 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);

}
项目:openjdk-jdk10    文件:DOMValidatorHelper.java   
public boolean isEntityUnparsed(String name) {
    if (fEntities != null) {
        Entity entity = (Entity) fEntities.getNamedItem(name);
        if (entity != null) {
            return (entity.getNotationName() != null);
        }
    }
    return false;
}
项目:openjdk-jdk10    文件:DOMResultBuilder.java   
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);
    }
}
项目:openjdk9    文件:SAXImpl.java   
/**
 * The getUnparsedEntityURI function returns the URI of the unparsed
 * entity with the specified name in the same document as the context
 * node (see [3.3 Unparsed Entities]). It returns the empty string if
 * there is no such entity.
 */
public String getUnparsedEntityURI(String name)
{
    // Special handling for DOM input
    if (_document != null) {
        String uri = "";
        DocumentType doctype = _document.getDoctype();
        if (doctype != null) {
            NamedNodeMap entities = doctype.getEntities();

            if (entities == null) {
                return uri;
            }

            Entity entity = (Entity) entities.getNamedItem(name);

            if (entity == null) {
                return uri;
            }

            String notationName = entity.getNotationName();
            if (notationName != null) {
                uri = entity.getSystemId();
                if (uri == null) {
                    uri = entity.getPublicId();
                }
            }
        }
        return uri;
    }
    else {
        return super.getUnparsedEntityURI(name);
    }
}
项目:openjdk9    文件:CoreDocumentImpl.java   
/**
 * 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);

}
项目:openjdk9    文件:DOMValidatorHelper.java   
public boolean isEntityUnparsed(String name) {
    if (fEntities != null) {
        Entity entity = (Entity) fEntities.getNamedItem(name);
        if (entity != null) {
            return (entity.getNotationName() != null);
        }
    }
    return false;
}
项目:openjdk9    文件:DOMResultBuilder.java   
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);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:SAXImpl.java   
/**
 * The getUnparsedEntityURI function returns the URI of the unparsed
 * entity with the specified name in the same document as the context
 * node (see [3.3 Unparsed Entities]). It returns the empty string if
 * there is no such entity.
 */
public String getUnparsedEntityURI(String name)
{
    // Special handling for DOM input
    if (_document != null) {
        String uri = "";
        DocumentType doctype = _document.getDoctype();
        if (doctype != null) {
            NamedNodeMap entities = doctype.getEntities();

            if (entities == null) {
                return uri;
            }

            Entity entity = (Entity) entities.getNamedItem(name);

            if (entity == null) {
                return uri;
            }

            String notationName = entity.getNotationName();
            if (notationName != null) {
                uri = entity.getSystemId();
                if (uri == null) {
                    uri = entity.getPublicId();
                }
            }
        }
        return uri;
    }
    else {
        return super.getUnparsedEntityURI(name);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:CoreDocumentImpl.java   
/**
 * 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);

}
项目:lookaside_java-1.8.0-openjdk    文件:DOMValidatorHelper.java   
public boolean isEntityUnparsed(String name) {
    if (fEntities != null) {
        Entity entity = (Entity) fEntities.getNamedItem(name);
        if (entity != null) {
            return (entity.getNotationName() != null);
        }
    }
    return false;
}
项目:lookaside_java-1.8.0-openjdk    文件:DOMResultBuilder.java   
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);
    }
}
项目:javify    文件:DomDoctype.java   
/**
 * Records the declaration of a general entity in this DocumentType.
 *
 * @param name Name of the entity
 * @param publicId If non-null, provides the entity's PUBLIC identifier
 * @param systemId Provides the entity's SYSTEM identifier
 * @param notation If non-null, provides the entity's notation
 *    (indicating an unparsed entity)
 * @return The Entity that was declared, or null if the entity wasn't
 *    recorded (because it's a parameter entity or because an entity with
 *    this name was already declared).
 *
 * @exception DOMException NO_MODIFICATION_ALLOWED_ERR if the
 *    DocumentType is no longer writable.
 * @exception DOMException HIERARCHY_REQUEST_ERR if the DocumentType
 *    is not associated with a document.
 */
public Entity declareEntity(String name,
                            String publicId,
                            String systemId,
                            String notation)
{
  DomEntity entity;

  if (name.charAt(0) == '%' || "[dtd]".equals(name))
    {
      return null;
    }
  if (isReadonly())
    {
      throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
    }
  getEntities();

  DomDocument.checkName(name, (owner != null) ?
                        "1.1".equals(owner.getXmlVersion()) : false);
  if (entities.getNamedItem(name) != null)
    {
      return null;
    }

  entity = new DomEntity(owner, name, publicId, systemId, notation);
  entities.setNamedItem(entity);
  return entity;
}
项目:javify    文件:SAXEventSink.java   
public void startEntity(String name)
  throws SAXException
{
  if (interrupted)
    return;
  DocumentType doctype = doc.getDoctype();
  if (doctype == null)
    {
      throw new SAXException("SAX parser error: " +
                             "reference to entity in undeclared doctype");
    }
  if ("[dtd]".equals(name) || name.charAt(0) == '%')
    return;
  if (PREDEFINED_ENTITIES.contains(name))
    return;
  // Get entity
  NamedNodeMap entities = doctype.getEntities();
  Entity entity = (Entity) entities.getNamedItem(name);
  if (entity == null)
    {
      throw new SAXException("SAX parser error: " +
                             "reference to undeclared entity: " + name);
    }
  EntityReference ref = doc.createEntityReference(name);
  // DomDocument populates with the entity replacement text, remove this
  Node child = ref.getFirstChild();
  while (child != null)
    {
      Node nextChild = child.getNextSibling();
      ref.removeChild(child);
      child = nextChild;
    }
  ctx.appendChild(ref);
  ctx = ref;
}
项目:javify    文件:SAXEventSink.java   
public void unparsedEntityDecl(String name, String publicId, String systemId,
                               String notationName)
  throws SAXException
{
  if (interrupted)
    {
      return;
    }
  if (!inDTD)
    throw new SAXException("unparsed entity decl outside DTD");
  DomDoctype doctype = (DomDoctype) ctx;
  Entity entity = doctype.declareEntity(name, publicId, systemId,
                                        notationName);
}
项目:javify    文件:SAXEventSink.java   
public void externalEntityDecl(String name, String publicId, String systemId)
  throws SAXException
{
  if (interrupted)
    {
      return;
    }
  if (!inDTD)
    throw new SAXException("external entity decl outside DTD");
  DomDoctype doctype = (DomDoctype) ctx;
  Entity entity = doctype.declareEntity(name, publicId, systemId, null);
}
项目:javify    文件:DomEntityReference.java   
/**
 * The base URI of an entity reference is the base URI where the entity
 * declaration occurs.
 * @since DOM Level 3 Core
 */
public final String getBaseURI()
{
  DocumentType doctype = owner.getDoctype();
  if (doctype == null)
    {
      return null;
    }
  Entity entity = (Entity) doctype.getEntities().getNamedItem(name);
  if (entity == null)
    {
      return null;
    }
  return entity.getBaseURI();
}
项目:jvm-stm    文件:DomDoctype.java   
/**
 * Records the declaration of a general entity in this DocumentType.
 *
 * @param name Name of the entity
 * @param publicId If non-null, provides the entity's PUBLIC identifier
 * @param systemId Provides the entity's SYSTEM identifier
 * @param notation If non-null, provides the entity's notation
 *  (indicating an unparsed entity)
 * @return The Entity that was declared, or null if the entity wasn't
 *  recorded (because it's a parameter entity or because an entity with
 *  this name was already declared).
 *
 * @exception DOMException NO_MODIFICATION_ALLOWED_ERR if the
 *  DocumentType is no longer writable.
 * @exception DOMException HIERARCHY_REQUEST_ERR if the DocumentType
 *  is not associated with a document.
 */
public Entity declareEntity(String name,
                            String publicId,
                            String systemId,
                            String notation)
{
  DomEntity entity;

  if (name.charAt(0) == '%' || "[dtd]".equals(name))
    {
      return null;
    }
  if (isReadonly())
    {
      throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
    }
  getEntities();

  DomDocument.checkName(name, (owner != null) ?
                        "1.1".equals(owner.getXmlVersion()) : false);
  if (entities.getNamedItem(name) != null)
    {
      return null;
    }

  entity = new DomEntity(owner, name, publicId, systemId, notation);
  entities.setNamedItem(entity);
  return entity;
}
项目:jvm-stm    文件:SAXEventSink.java   
public void startEntity(String name)
  throws SAXException
{
  if (interrupted)
    return;
  DocumentType doctype = doc.getDoctype();
  if (doctype == null)
    {
      throw new SAXException("SAX parser error: " +
                             "reference to entity in undeclared doctype");
    }
  if ("[dtd]".equals(name) || name.charAt(0) == '%')
    return;
  if (PREDEFINED_ENTITIES.contains(name))
    return;
  // Get entity
  NamedNodeMap entities = doctype.getEntities();
  Entity entity = (Entity) entities.getNamedItem(name);
  if (entity == null)
    {
      throw new SAXException("SAX parser error: " +
                             "reference to undeclared entity: " + name);
    }
  EntityReference ref = doc.createEntityReference(name);
  // DomDocument populates with the entity replacement text, remove this
  Node child = ref.getFirstChild();
  while (child != null)
    {
      Node nextChild = child.getNextSibling();
      ref.removeChild(child);
      child = nextChild;
    }
  ctx.appendChild(ref);
  ctx = ref;
}
项目:jvm-stm    文件:SAXEventSink.java   
public void unparsedEntityDecl(String name, String publicId, String systemId,
                               String notationName)
  throws SAXException
{
  if (interrupted)
    {
      return;
    }
  if (!inDTD)
    throw new SAXException("unparsed entity decl outside DTD");
  DomDoctype doctype = (DomDoctype) ctx;
  Entity entity = doctype.declareEntity(name, publicId, systemId,
                                        notationName);
}
项目:jvm-stm    文件:SAXEventSink.java   
public void externalEntityDecl(String name, String publicId, String systemId)
  throws SAXException
{
  if (interrupted)
    {
      return;
    }
  if (!inDTD)
    throw new SAXException("external entity decl outside DTD");
  DomDoctype doctype = (DomDoctype) ctx;
  Entity entity = doctype.declareEntity(name, publicId, systemId, null);
}
项目:jvm-stm    文件:DomEntityReference.java   
/**
 * The base URI of an entity reference is the base URI where the entity
 * declaration occurs.
 * @since DOM Level 3 Core
 */
public final String getBaseURI()
{
  DocumentType doctype = owner.getDoctype();
  if (doctype == null)
    {
      return null;
    }
  Entity entity = (Entity) doctype.getEntities().getNamedItem(name);
  if (entity == null)
    {
      return null;
    }
  return entity.getBaseURI();
}
项目:infobip-open-jdk-8    文件:SAXImpl.java   
/**
 * The getUnparsedEntityURI function returns the URI of the unparsed
 * entity with the specified name in the same document as the context
 * node (see [3.3 Unparsed Entities]). It returns the empty string if
 * there is no such entity.
 */
public String getUnparsedEntityURI(String name)
{
    // Special handling for DOM input
    if (_document != null) {
        String uri = "";
        DocumentType doctype = _document.getDoctype();
        if (doctype != null) {
            NamedNodeMap entities = doctype.getEntities();

            if (entities == null) {
                return uri;
            }

            Entity entity = (Entity) entities.getNamedItem(name);

            if (entity == null) {
                return uri;
            }

            String notationName = entity.getNotationName();
            if (notationName != null) {
                uri = entity.getSystemId();
                if (uri == null) {
                    uri = entity.getPublicId();
                }
            }
        }
        return uri;
    }
    else {
        return super.getUnparsedEntityURI(name);
    }
}
项目:infobip-open-jdk-8    文件:DOMValidatorHelper.java   
public boolean isEntityUnparsed(String name) {
    if (fEntities != null) {
        Entity entity = (Entity) fEntities.getNamedItem(name);
        if (entity != null) {
            return (entity.getNotationName() != null);
        }
    }
    return false;
}
项目:infobip-open-jdk-8    文件:DOMResultBuilder.java   
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);
    }
}
项目:OLD-OpenJDK8    文件:SAXImpl.java   
/**
 * The getUnparsedEntityURI function returns the URI of the unparsed
 * entity with the specified name in the same document as the context
 * node (see [3.3 Unparsed Entities]). It returns the empty string if
 * there is no such entity.
 */
public String getUnparsedEntityURI(String name)
{
    // Special handling for DOM input
    if (_document != null) {
        String uri = "";
        DocumentType doctype = _document.getDoctype();
        if (doctype != null) {
            NamedNodeMap entities = doctype.getEntities();

            if (entities == null) {
                return uri;
            }

            Entity entity = (Entity) entities.getNamedItem(name);

            if (entity == null) {
                return uri;
            }

            String notationName = entity.getNotationName();
            if (notationName != null) {
                uri = entity.getSystemId();
                if (uri == null) {
                    uri = entity.getPublicId();
                }
            }
        }
        return uri;
    }
    else {
        return super.getUnparsedEntityURI(name);
    }
}
项目:OLD-OpenJDK8    文件:DOMValidatorHelper.java   
public boolean isEntityUnparsed(String name) {
    if (fEntities != null) {
        Entity entity = (Entity) fEntities.getNamedItem(name);
        if (entity != null) {
            return (entity.getNotationName() != null);
        }
    }
    return false;
}
项目:OLD-OpenJDK8    文件:DOMResultBuilder.java   
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);
    }
}
项目:JamVM-PH    文件:DomDoctype.java   
/**
 * Records the declaration of a general entity in this DocumentType.
 *
 * @param name Name of the entity
 * @param publicId If non-null, provides the entity's PUBLIC identifier
 * @param systemId Provides the entity's SYSTEM identifier
 * @param notation If non-null, provides the entity's notation
 *  (indicating an unparsed entity)
 * @return The Entity that was declared, or null if the entity wasn't
 *  recorded (because it's a parameter entity or because an entity with
 *  this name was already declared).
 *
 * @exception DOMException NO_MODIFICATION_ALLOWED_ERR if the
 *  DocumentType is no longer writable.
 * @exception DOMException HIERARCHY_REQUEST_ERR if the DocumentType
 *  is not associated with a document.
 */
public Entity declareEntity(String name,
                            String publicId,
                            String systemId,
                            String notation)
{
  DomEntity entity;

  if (name.charAt(0) == '%' || "[dtd]".equals(name))
    {
      return null;
    }
  if (isReadonly())
    {
      throw new DomDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
    }
  getEntities();

  DomDocument.checkName(name, (owner != null) ?
                        "1.1".equals(owner.getXmlVersion()) : false);
  if (entities.getNamedItem(name) != null)
    {
      return null;
    }

  entity = new DomEntity(owner, name, publicId, systemId, notation);
  entities.setNamedItem(entity);
  return entity;
}
项目:JamVM-PH    文件:SAXEventSink.java   
public void startEntity(String name)
  throws SAXException
{
  if (interrupted)
    return;
  DocumentType doctype = doc.getDoctype();
  if (doctype == null)
    {
      throw new SAXException("SAX parser error: " +
                             "reference to entity in undeclared doctype");
    }
  if ("[dtd]".equals(name) || name.charAt(0) == '%')
    return;
  if (PREDEFINED_ENTITIES.contains(name))
    return;
  // Get entity
  NamedNodeMap entities = doctype.getEntities();
  Entity entity = (Entity) entities.getNamedItem(name);
  if (entity == null)
    {
      throw new SAXException("SAX parser error: " +
                             "reference to undeclared entity: " + name);
    }
  EntityReference ref = doc.createEntityReference(name);
  // DomDocument populates with the entity replacement text, remove this
  Node child = ref.getFirstChild();
  while (child != null)
    {
      Node nextChild = child.getNextSibling();
      ref.removeChild(child);
      child = nextChild;
    }
  ctx.appendChild(ref);
  ctx = ref;
}
项目:JamVM-PH    文件:SAXEventSink.java   
public void unparsedEntityDecl(String name, String publicId, String systemId,
                               String notationName)
  throws SAXException
{
  if (interrupted)
    {
      return;
    }
  if (!inDTD)
    throw new SAXException("unparsed entity decl outside DTD");
  DomDoctype doctype = (DomDoctype) ctx;
  Entity entity = doctype.declareEntity(name, publicId, systemId,
                                        notationName);
}