Package org.w3c.dom

Examples of org.w3c.dom.DocumentType


   */
  public String getUnparsedEntityURI(String name, Document doc)
  {

    String url = "";
    DocumentType doctype = doc.getDoctype();

    if (null != doctype)
    {
      NamedNodeMap entities = doctype.getEntities();
      if(null == entities)
        return url;
      Entity entity = (Entity) entities.getNamedItem(name);
      if(null == entity)
        return url;
View Full Code Here


        }
        if (!equalNodeList(nodeA.getChildNodes(), nodeB.getChildNodes())) {
            return false;
        }
        if (nodeA.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
            DocumentType documentTypeA = (DocumentType) nodeA;
            DocumentType documentTypeB = (DocumentType) nodeB;
            if (!equalString(documentTypeA.getPublicId(), documentTypeB.getPublicId())) {
                return false;
            }
            if (!equalString(documentTypeA.getSystemId(), documentTypeB.getSystemId())) {
                return false;
            }
            if (!equalString(documentTypeA.getInternalSubset(), documentTypeB.getInternalSubset())) {
                return false;
            }
            if (!equalNamedNodeMap(documentTypeA.getEntities(), documentTypeB.getEntities())) {
                return false;
            }
            if (!equalNamedNodeMap(documentTypeA.getNotations(), documentTypeB.getNotations())) {
                return false;
            }
        }
        return true;
    }
View Full Code Here

   *
   * @param root Name of the root element.
   * @return The document with the appropriate document type declaration.
   */
  static Document createDocument(String root) {
    DocumentType docType = XML.getDOMImplementation().createDocumentType(root, PROFILES_DTD_FPI, PROFILES_DTD_URL);
    Document doc = XML.getDOMImplementation().createDocument(/*namespaceURI*/null, root, docType);
    return doc;
  }
View Full Code Here

        // Special casing for ENTITY, NOTATION, DOCTYPE and ATTRIBUTES
        // LM:  should rewrite this.                                         
        switch (thisAncestorType) {
          case Node.NOTATION_NODE:
          case Node.ENTITY_NODE: {
            DocumentType container = thisOwnerDoc.getDoctype();
            if (container == otherAncestor) return
                   (DOCUMENT_POSITION_CONTAINS | DOCUMENT_POSITION_PRECEDING);
            switch (otherAncestorType) {
              case Node.NOTATION_NODE:
              case Node.ENTITY_NODE:  {
                if (thisAncestorType != otherAncestorType)
                 // the nodes are of different types
                 return ((thisAncestorType>otherAncestorType) ?
                    DOCUMENT_POSITION_PRECEDING:DOCUMENT_POSITION_FOLLOWING);
                else {
                 // the nodes are of the same type.  Find order.
                 if (thisAncestorType == Node.NOTATION_NODE)
                
                     if (((NamedNodeMapImpl)container.getNotations()).precedes(otherAncestor,thisAncestor))
                       return (DOCUMENT_POSITION_PRECEDING |
                               DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC);
                     else
                       return (DOCUMENT_POSITION_FOLLOWING |
                               DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC);
                 else
                     if (((NamedNodeMapImpl)container.getEntities()).precedes(otherAncestor,thisAncestor))
                       return (DOCUMENT_POSITION_PRECEDING |
                               DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC);
                     else
                       return (DOCUMENT_POSITION_FOLLOWING |
                               DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC);
                }
              }
            }
            thisNode = thisAncestor = thisOwnerDoc;
            break;
          }
          case Node.DOCUMENT_TYPE_NODE: {
            if (otherNode == thisOwnerDoc)
              return (DOCUMENT_POSITION_PRECEDING |
                      DOCUMENT_POSITION_CONTAINS);
            else if (thisOwnerDoc!=null && thisOwnerDoc==otherOwnerDoc)
              return (DOCUMENT_POSITION_FOLLOWING);
            break;
          }
          case Node.ATTRIBUTE_NODE: {
            thisNode = ((AttrImpl)thisAncestor).getOwnerElement();
            if (otherAncestorType==Node.ATTRIBUTE_NODE) {
              otherNode = ((AttrImpl)otherAncestor).getOwnerElement();
              if (otherNode == thisNode) {
                if (((NamedNodeMapImpl)thisNode.getAttributes()).precedes(other,this))
                  return (DOCUMENT_POSITION_PRECEDING |
                          DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC);
                else
                  return (DOCUMENT_POSITION_FOLLOWING |
                          DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC);
              }
            }

            // Now, find the ancestor of the element
            thisDepth=0;
            for (node=thisNode; node != null; node=node.getParentNode()) {
                thisDepth +=1;
                if (node == otherNode)
                  // The other node is an ancestor of the owning element
                  return DOCUMENT_POSITION_PRECEDING;
                thisAncestor = node;
            }
          }
        }
        switch (otherAncestorType) {
          case Node.NOTATION_NODE:
          case Node.ENTITY_NODE: {
          DocumentType container = thisOwnerDoc.getDoctype();
            if (container == this) return (DOCUMENT_POSITION_IS_CONTAINED |
                                          DOCUMENT_POSITION_FOLLOWING);
            otherNode = otherAncestor = thisOwnerDoc;
            break;
          }
View Full Code Here

                // forbid it for the sake of being compliant to the DOM spec
                if (!cloningDoc) {
                    String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
                    throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
                }
                DocumentType srcdoctype = (DocumentType)source;
                DocumentTypeImpl newdoctype = (DocumentTypeImpl)
                    createDocumentType(srcdoctype.getNodeName(),
                                       srcdoctype.getPublicId(),
                                       srcdoctype.getSystemId());
                // Values are on NamedNodeMaps
                NamedNodeMap smap = srcdoctype.getEntities();
                NamedNodeMap tmap = newdoctype.getEntities();
                if(smap != null) {
                    for(int i = 0; i < smap.getLength(); i++) {
                        tmap.setNamedItem(importNode(smap.item(i), true, true,
                                                     reversedIdentifiers));
                    }
                }
                smap = srcdoctype.getNotations();
                tmap = newdoctype.getNotations();
                if (smap != null) {
                    for(int i = 0; i < smap.getLength(); i++) {
                        tmap.setNamedItem(importNode(smap.item(i), true, true,
                                                     reversedIdentifiers));
View Full Code Here

            }
            serializeElement( (Element) node );
            break;
        }
        case Node.DOCUMENT_NODE : {
            DocumentType      docType;
            DOMImplementation domImpl;
            NamedNodeMap      map;
            Entity            entity;
            Notation          notation;
            int               i;
           
            // If there is a document type, use the SAX events to
            // serialize it.
            docType = ( (Document) node ).getDoctype();
            if (docType != null) {
                // DOM Level 2 (or higher)
                domImpl = ( (Document) node ).getImplementation();
                try {
                    String internal;

                    _printer.enterDTD();
                    _docTypePublicId = docType.getPublicId();
                    _docTypeSystemId = docType.getSystemId();
                    internal = docType.getInternalSubset();
                    if ( internal != null && internal.length() > 0 )
                        _printer.printText( internal );
                    endDTD();
                }
                // DOM Level 1 -- does implementation have methods?
                catch (NoSuchMethodError nsme) {
                    Class docTypeClass = docType.getClass();

                    String docTypePublicId = null;
                    String docTypeSystemId = null;
                    try {
                        java.lang.reflect.Method getPublicId = docTypeClass.getMethod("getPublicId", null);
View Full Code Here

     * Returns the document type public identifier
     * specified for this document, or null.
     */
    public static String whichDoctypePublic( Document doc )
    {
        DocumentType doctype;

        /* XXX  Delayed until DOM Level 2 is introduced into the code base
           doctype = doc.getDoctype();
           if ( doctype != null ) {
           // Note on catch: DOM Level 1 does not specify this method
View Full Code Here

     * Returns the document type system identifier
     * specified for this document, or null.
     */
    public static String whichDoctypeSystem( Document doc )
    {
        DocumentType doctype;

        /* XXX  Delayed until DOM Level 2 is introduced into the code base
           doctype = doc.getDoctype();
           if ( doctype != null ) {
           // Note on catch: DOM Level 1 does not specify this method
View Full Code Here

            }

            // REVISIT: The DOM specifications say that DocumentType nodes
            // cannot be imported. Is this OK?
          case DOCUMENT_TYPE_NODE: {
    DocumentType srcdoctype = (DocumentType)source;
    DocumentTypeImpl newdoctype = (DocumentTypeImpl)
        createDocumentType(srcdoctype.getNodeName(),
               srcdoctype.getPublicId(),
               srcdoctype.getSystemId());
    // Values are on NamedNodeMaps
    NamedNodeMap smap = srcdoctype.getEntities();
    NamedNodeMap tmap = newdoctype.getEntities();
    if(smap != null) {
        for(int i = 0; i < smap.getLength(); i++) {
      tmap.setNamedItem(importNode(smap.item(i), true,
                                                     reversedIdentifiers));
                    }
                }
    smap = srcdoctype.getNotations();
    tmap = newdoctype.getNotations();
    if (smap != null) {
        for(int i = 0; i < smap.getLength(); i++) {
      tmap.setNamedItem(importNode(smap.item(i), true,
                                                     reversedIdentifiers));
View Full Code Here

     */
    protected void synchronize() {
        if (firstChild != null) {
            return;
        }
      DocumentType doctype;
      NamedNodeMap entities;
      EntityImpl entDef;
      if (null != (doctype = getOwnerDocument().getDoctype()) &&
            null != (entities = doctype.getEntities())) {
           
            entDef = (EntityImpl)entities.getNamedItem(getNodeName());

            // No Entity by this name, stop here.
            if (entDef == null)
View Full Code Here

TOP

Related Classes of org.w3c.dom.DocumentType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.