Package org.w3c.dom

Examples of org.w3c.dom.DocumentType


    public boolean isRootName(String name) {
        return rootElement.getNodeName().equals(name);
    }

    public String getDoctype() {
        DocumentType doctype = xmlDocument.getDoctype();
        if (null != doctype) {
            return doctype.getName();
        }
        return null;
    }
View Full Code Here


        }
        return null;
    }

    public String getPiblicId() {
        DocumentType doctype = xmlDocument.getDoctype();
        if (null != doctype) {
            return doctype.getPublicId();
        }
        return null;
    }
View Full Code Here

   */
  private List getAvailableRootChildren(Document document, int childIndex) {
    List list = null;

    // extract the valid 'root' node name from the DocumentType Node
    DocumentType docType = document.getDoctype();
    String rootName = null;
    if (docType != null) {
      rootName = docType.getNodeName();
    }
    if (rootName == null) {
      return new ArrayList(0);
    }

    for (Node child = document.getFirstChild(); child != null; child = child.getNextSibling()) {
      // make sure the "root" Element isn't already present
      // is it required to be an Element?
      if ((child.getNodeType() == Node.ELEMENT_NODE) && child.getNodeName().equalsIgnoreCase(rootName)) {
        // if the node is missing either the start or end tag, don't
        // count it as present
        if ((child instanceof IDOMNode) && ((((IDOMNode) child).getStartStructuredDocumentRegion() == null) || (((IDOMNode) child).getEndStructuredDocumentRegion() == null))) {
          continue;
        }
        if (Debug.displayInfo) {
          System.out.println(rootName + " already present!"); //$NON-NLS-1$
        }
        setErrorMessage(NLS.bind(XMLUIMessages.The_document_element__, (new Object[]{rootName})));
        return new ArrayList(0);
      }
    }

    list = new ArrayList(1);
    ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document);
    if (modelQuery != null) {
      CMDocument cmdoc = modelQuery.getCorrespondingCMDocument(document);
      if (cmdoc != null) {
        if (rootName != null) {
          CMElementDeclaration rootDecl = (CMElementDeclaration) cmdoc.getElements().getNamedItem(rootName);
          if (rootDecl != null) {
            list.add(rootDecl);
          }
          else {
            // supply the given document name anyway, even if it
            // is an error
            list.add(new SimpleCMElementDeclaration(rootName));

            String location = "" + (docType.getPublicId() != null ? docType.getPublicId() + "/" : "") + (docType.getSystemId() != null ? docType.getSystemId() : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
            if (location.length() > 0) {
              setErrorMessage(NLS.bind(
                  XMLUIMessages.No_definition_for_in,
                  (new Object[]{rootName, location})));
            }
            else {
              setErrorMessage(NLS.bind(
                  XMLUIMessages.No_definition_for,
                  (new Object[]{rootName})));
            }
          }
        }
      }
      else {
        String location = "" + (docType.getPublicId() != null ? docType.getPublicId() + "/" : "") + (docType.getSystemId() != null ? docType.getSystemId() : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        if (location.length() > 0) {
          setErrorMessage(NLS.bind(
              XMLUIMessages.No_content_model_for,
              (new Object[]{location})));
        }
View Full Code Here

      if (child.getNodeType() == DOCUMENT_TYPE_NODE && child instanceof DocumentType) {
        return (DocumentType) child;
      }
      else if (child.getNodeType() == ELEMENT_NODE && ((IDOMElement) child).isCommentTag()) {
        // search DOCTYPE inside of generic comment element
        DocumentType docType = findDoctype(child);
        if (docType != null) {
          return docType;
        }
      }
    }
View Full Code Here

   *         document, of course, the result is the same, but not
   *         necessarily the same in an ill-formed document.
   */
  public Element getDocumentElement() {
    String name = null;
    DocumentType docType = getDocumentType();
    if (docType != null) {
      name = docType.getName();
    }

    Element first[] = new Element[1];
    Element docElement = findDocumentElement(name, this, first, noMaxSearch);
    if (docElement == null) {
View Full Code Here

    return adapter.getDocumentType();
  }


  public String getDocumentTypeId() {
    DocumentType docType = getDocumentType();
    if (docType == null)
      return null;
    String id = docType.getPublicId();
    if (id == null)
      id = docType.getSystemId();
    return id;
  }
View Full Code Here

        if(value != null){
          doctype_pubid = value;
        }
        //Don't inject DOCTYPE if QName is null
        if(doctype_qname != null){
          DocumentType docTypeNode = document.getImplementation()
              .createDocumentType(doctype_qname, doctype_pubid, doctype_sysid);
          if(document.getDoctype() != null){
            document.removeChild(document.getDoctype());
          }
          document.insertBefore(docTypeNode, document.getFirstChild());
View Full Code Here

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

           /*  DOM Level 2 was introduced into the code base*/
           doctype = doc.getDoctype();
           if ( doctype != null ) {
           // Note on catch: DOM Level 1 does not specify this method
           // and the code will throw a NoSuchMethodError
           try {
           return doctype.getPublicId();
           } catch ( Error except ) {  }
           }
       
        if ( doc instanceof HTMLDocument )
            return DTD.XHTMLPublicId;
View Full Code Here

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

        /* DOM Level 2 was introduced into the code base*/
           doctype = doc.getDoctype();
           if ( doctype != null ) {
           // Note on catch: DOM Level 1 does not specify this method
           // and the code will throw a NoSuchMethodError
           try {
           return doctype.getSystemId();
           } catch ( Error except ) { }
           }
       
        if ( doc instanceof HTMLDocument )
            return DTD.XHTMLSystemId;
View Full Code Here

        case Node.ELEMENT_NODE :
            serializeElement( (Element) node );
            break;

        case Node.DOCUMENT_NODE : {
            DocumentType      docType;

            // 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)
                // TODO: result of the following call was assigned to a local variable that was never
                // read. Can the call be deleted?
                ( (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

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.