当前位置: 首页>>代码示例>>Java>>正文


Java Node.DOCUMENT_TYPE_NODE属性代码示例

本文整理汇总了Java中org.w3c.dom.Node.DOCUMENT_TYPE_NODE属性的典型用法代码示例。如果您正苦于以下问题:Java Node.DOCUMENT_TYPE_NODE属性的具体用法?Java Node.DOCUMENT_TYPE_NODE怎么用?Java Node.DOCUMENT_TYPE_NODE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.w3c.dom.Node的用法示例。


在下文中一共展示了Node.DOCUMENT_TYPE_NODE属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: endNode

/**
 * End processing of given node
 *
 *
 * @param node Node we just finished processing
 *
 * @throws org.xml.sax.SAXException
 */
protected void endNode(Node node) throws org.xml.sax.SAXException {

    switch (node.getNodeType()) {
        case Node.DOCUMENT_NODE :
            break;
        case Node.DOCUMENT_TYPE_NODE :
            serializeDocType((DocumentType) node, false);
            break;
        case Node.ELEMENT_NODE :
            serializeElement((Element) node, false);
            break;
        case Node.CDATA_SECTION_NODE :
            break;
        case Node.ENTITY_REFERENCE_NODE :
            serializeEntityReference((EntityReference) node, false);
            break;
        default :
            }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:DOM3TreeWalker.java

示例2: removeChild

/**
 * Since insertBefore caches the docElement (and, currently, docType),
 * removeChild has to know how to undo the cache
 *
 * REVISIT: According to the spec it is not allowed to alter neither the
 * document element nor the document type in any way
 */
public Node removeChild(Node oldChild) throws DOMException {

    super.removeChild(oldChild);

    // If remove succeeded, un-cache the kid appropriately
    int type = oldChild.getNodeType();
    if(type == Node.ELEMENT_NODE) {
        docElement = null;
    }
    else if (type == Node.DOCUMENT_TYPE_NODE) {
        docType = null;
    }

    return oldChild;

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:CoreDocumentImpl.java

示例3: getNodeTypeFromCode

private String getNodeTypeFromCode(short code) {
    String retval = null;
    switch (code) {
    case Node.ATTRIBUTE_NODE :
        retval = "ATTRIBUTE_NODE"; break;
    case Node.CDATA_SECTION_NODE :
        retval = "CDATA_SECTION_NODE"; break;
    case Node.COMMENT_NODE :
        retval = "COMMENT_NODE"; break;
    case Node.DOCUMENT_FRAGMENT_NODE :
        retval = "DOCUMENT_FRAGMENT_NODE"; break;
    case Node.DOCUMENT_NODE :
        retval = "DOCUMENT_NODE"; break;
    case Node.DOCUMENT_TYPE_NODE :
        retval = "DOCUMENT_TYPE_NODE"; break;
    case Node.ELEMENT_NODE :
        retval = "ELEMENT_NODE"; break;
    case Node.ENTITY_NODE :
        retval = "ENTITY_NODE"; break;
    case Node.ENTITY_REFERENCE_NODE :
        retval = "ENTITY_REFERENCE_NODE"; break;
    case Node.NOTATION_NODE :
        retval = "NOTATION_NODE"; break;
    case Node.PROCESSING_INSTRUCTION_NODE :
        retval = "PROCESSING_INSTRUCTION_NODE"; break;
    case Node.TEXT_NODE:
        retval = "TEXT_NODE"; break;
    }
    return retval;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:DOM2TO.java

示例4: replaceChild

/**
 * Since we cache the docElement (and, currently, docType),
 * replaceChild has to update the cache
 *
 * REVISIT: According to the spec it is not allowed to alter neither the
 * document element nor the document type in any way
 */
public Node replaceChild(Node newChild, Node oldChild)
        throws DOMException {

    // Adopt orphan doctypes
    if (newChild.getOwnerDocument() == null &&
    newChild instanceof DocumentTypeImpl) {
        ((DocumentTypeImpl) newChild).ownerDocument = this;
    }

    if (errorChecking &&((docType != null &&
        oldChild.getNodeType() != Node.DOCUMENT_TYPE_NODE &&
        newChild.getNodeType() == Node.DOCUMENT_TYPE_NODE)
        || (docElement != null &&
        oldChild.getNodeType() != Node.ELEMENT_NODE &&
        newChild.getNodeType() == Node.ELEMENT_NODE))) {

        throw new DOMException(
                DOMException.HIERARCHY_REQUEST_ERR,
                DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "HIERARCHY_REQUEST_ERR", null));
    }
    super.replaceChild(newChild, oldChild);

    int type = oldChild.getNodeType();
    if(type == Node.ELEMENT_NODE) {
        docElement = (ElementImpl)newChild;
    }
    else if (type == Node.DOCUMENT_TYPE_NODE) {
        docType = (DocumentTypeImpl)newChild;
    }
    return oldChild;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:CoreDocumentImpl.java

示例5: getDocumentElement

/** This is a bit of a problem in DTM, since a DTM may be a Document
 * Fragment and hence not have a clear-cut Document Element. We can
 * make it work in the well-formed cases but would that be confusing for others?
 *
 *
 * @see org.w3c.dom.Document
 */
@Override
public final Element getDocumentElement()
{
              int dochandle=dtm.getDocument();
              int elementhandle=DTM.NULL;
              for(int kidhandle=dtm.getFirstChild(dochandle);
                              kidhandle!=DTM.NULL;
                              kidhandle=dtm.getNextSibling(kidhandle))
              {
                      switch(dtm.getNodeType(kidhandle))
                      {
                      case Node.ELEMENT_NODE:
                              if(elementhandle!=DTM.NULL)
                              {
                                      elementhandle=DTM.NULL; // More than one; ill-formed.
                                      kidhandle=dtm.getLastChild(dochandle); // End loop
                              }
                              else
                                      elementhandle=kidhandle;
                              break;

                      // These are harmless; document is still wellformed
                      case Node.COMMENT_NODE:
                      case Node.PROCESSING_INSTRUCTION_NODE:
                      case Node.DOCUMENT_TYPE_NODE:
                              break;

                      default:
                              elementhandle=DTM.NULL; // ill-formed
                              kidhandle=dtm.getLastChild(dochandle); // End loop
                              break;
                      }
              }
              if(elementhandle==DTM.NULL)
                      throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
              else
                      return (Element)(dtm.getNode(elementhandle));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:45,代码来源:DTMNodeProxy.java

示例6: replaceChild

/**
 * Since we cache the docElement (and, currently, docType),
 * replaceChild has to update the cache
 *
 * REVISIT: According to the spec it is not allowed to alter neither the
 * document element nor the document type in any way
 */
public Node replaceChild(Node newChild, Node oldChild)
throws DOMException {

    // Adopt orphan doctypes
    if (newChild.getOwnerDocument() == null &&
    newChild instanceof DocumentTypeImpl) {
        ((DocumentTypeImpl) newChild).ownerDocument = this;
    }

    if (errorChecking &&((docType != null &&
        oldChild.getNodeType() != Node.DOCUMENT_TYPE_NODE &&
        newChild.getNodeType() == Node.DOCUMENT_TYPE_NODE)
        || (docElement != null &&
        oldChild.getNodeType() != Node.ELEMENT_NODE &&
        newChild.getNodeType() == Node.ELEMENT_NODE))) {

        throw new DOMException(
            DOMException.HIERARCHY_REQUEST_ERR,
            DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "HIERARCHY_REQUEST_ERR", null));
    }
    super.replaceChild(newChild, oldChild);

    int type = oldChild.getNodeType();
    if(type == Node.ELEMENT_NODE) {
        docElement = (ElementImpl)newChild;
    }
    else if (type == Node.DOCUMENT_TYPE_NODE) {
        docType = (DocumentTypeImpl)newChild;
    }
    return oldChild;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:38,代码来源:CoreDocumentImpl.java

示例7: isKidOK

/**
 * Uses the kidOK lookup table to check whether the proposed
 * tree structure is legal.
 */
protected boolean isKidOK(Node parent, Node child) {
    if (allowGrammarAccess &&
    parent.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
        return child.getNodeType() == Node.ELEMENT_NODE;
    }
    return 0 != (kidOK[parent.getNodeType()] & 1 << child.getNodeType());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:CoreDocumentImpl.java

示例8: synchronizeChildren

/**
 * Synchronizes the node's children with the internal structure.
 * Fluffing the children at once solves a lot of work to keep
 * the two structures in sync. The problem gets worse when
 * editing the tree -- this makes it a lot easier.
 */
protected void synchronizeChildren() {

    if (needsSyncData()) {
        synchronizeData();
        /*
         * when we have elements with IDs this method is being recursively
         * called from synchronizeData, in which case we've already gone
         * through the following and we can now simply stop here.
         */
        if (!needsSyncChildren()) {
            return;
        }
    }

    // we don't want to generate any event for this so turn them off
    boolean orig = mutationEvents;
    mutationEvents = false;

    // no need to sync in the future
    needsSyncChildren(false);

    getNodeType(0);

    // create children and link them as siblings
    ChildNode first = null;
    ChildNode last = null;
    for (int index = getLastChild(0);
         index != -1;
         index = getPrevSibling(index)) {

        ChildNode node = (ChildNode)getNodeObject(index);
        if (last == null) {
            last = node;
        }
        else {
            first.previousSibling = node;
        }
        node.ownerNode = this;
        node.isOwned(true);
        node.nextSibling = first;
        first = node;

        // save doctype and document type
        int type = node.getNodeType();
        if (type == Node.ELEMENT_NODE) {
            docElement = (ElementImpl)node;
        }
        else if (type == Node.DOCUMENT_TYPE_NODE) {
            docType = (DocumentTypeImpl)node;
        }
    }

    if (first != null) {
        firstChild = first;
        first.isFirstChild(true);
        lastChild(last);
    }

    // set mutation events flag back to its original value
    mutationEvents = orig;

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:68,代码来源:DeferredDocumentImpl.java

示例9: lookupPrefix

/**
     *
     * DOM Level 3 - Experimental:
     * Look up the prefix associated to the given namespace URI, starting from this node.
     *
     * @param namespaceURI
     * @return the prefix for the namespace
     */
    public String lookupPrefix(String namespaceURI){

        // REVISIT: When Namespaces 1.1 comes out this may not be true
        // Prefix can't be bound to null namespace
        if (namespaceURI == null) {
            return null;
        }

        short type = this.getNodeType();

        switch (type) {
/*
        case Node.ELEMENT_NODE: {

                String namespace = this.getNamespaceURI(); // to flip out children
                return lookupNamespacePrefix(namespaceURI, (ElementImpl)this);
            }

        case Node.DOCUMENT_NODE:{
                return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI);
            }
*/
        case Node.ENTITY_NODE :
        case Node.NOTATION_NODE:
        case Node.DOCUMENT_FRAGMENT_NODE:
        case Node.DOCUMENT_TYPE_NODE:
            // type is unknown
            return null;
        case Node.ATTRIBUTE_NODE:{
                if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
                    return getOwnerElement().lookupPrefix(namespaceURI);

                }
                return null;
            }
        default:{
/*
                NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
                if (ancestor != null) {
                    return ancestor.lookupPrefix(namespaceURI);
                }
*/
                return null;
            }
         }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:54,代码来源:UnImplNode.java

示例10: surroundContents

public void surroundContents(Node newParent)
    throws DOMException, RangeException
{
    if (newParent==null) return;
    int type = newParent.getNodeType();

    if (fDocument.errorChecking) {
        if (fDetach) {
            throw new DOMException(
                    DOMException.INVALID_STATE_ERR,
                    DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null));
        }
        if (type == Node.ATTRIBUTE_NODE
                || type == Node.ENTITY_NODE
                || type == Node.NOTATION_NODE
                || type == Node.DOCUMENT_TYPE_NODE
                || type == Node.DOCUMENT_NODE
                || type == Node.DOCUMENT_FRAGMENT_NODE)
        {
            throw new RangeExceptionImpl(
                    RangeException.INVALID_NODE_TYPE_ERR,
                    DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_NODE_TYPE_ERR", null));
        }
    }

    Node realStart = fStartContainer;
    Node realEnd = fEndContainer;
    if (fStartContainer.getNodeType() == Node.TEXT_NODE) {
        realStart = fStartContainer.getParentNode();
    }
    if (fEndContainer.getNodeType() == Node.TEXT_NODE) {
        realEnd = fEndContainer.getParentNode();
    }

    if (realStart != realEnd) {
            throw new RangeExceptionImpl(
            RangeException.BAD_BOUNDARYPOINTS_ERR,
            DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "BAD_BOUNDARYPOINTS_ERR", null));
    }

    DocumentFragment frag = extractContents();
    insertNode(newParent);
    newParent.appendChild(frag);
    selectNode(newParent);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:45,代码来源:RangeImpl.java

示例11: writeAnyNode

/**
 * Write any node.
 *
 * @param node
 *            the node
 * @throws ShellException
 *             the shell exception
 */
protected void writeAnyNode(Node node) throws ShellException {
    // is there anything to do?
    if (node == null) {
        return;
    }

    short type = node.getNodeType();
    switch (type) {
    case Node.DOCUMENT_NODE:
        write((Document) node);
        break;

    case Node.DOCUMENT_TYPE_NODE:
        write((DocumentType) node);
        break;

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

    case Node.ENTITY_REFERENCE_NODE:
        write((EntityReference) node);
        break;

    case Node.CDATA_SECTION_NODE:
        write((CDATASection) node);
        break;

    case Node.TEXT_NODE:
        write((Text) node);
        break;

    case Node.PROCESSING_INSTRUCTION_NODE:
        write((ProcessingInstruction) node);
        break;

    case Node.COMMENT_NODE:
        write((Comment) node);
        break;

    default:
        throw new ShellException(getString(
                "RuntimeError.18", Short.toString(type))); //$NON-NLS-1$
    }
}
 
开发者ID:DomKing,项目名称:server-utility,代码行数:53,代码来源:DomWriter.java

示例12: lookupElementDefinition

/**
 * Returns the index of the element definition in the table
 * with the specified name index, or -1 if no such definition
 * exists.
 */
public int lookupElementDefinition(String elementName) {

    if (fNodeCount > 1) {

        // find doctype
        int docTypeIndex = -1;
        int nchunk = 0;
        int nindex = 0;
        for (int index = getChunkIndex(fNodeLastChild, nchunk, nindex);
             index != -1;
             index = getChunkIndex(fNodePrevSib, nchunk, nindex)) {

            nchunk = index >> CHUNK_SHIFT;
            nindex = index  & CHUNK_MASK;
            if (getChunkIndex(fNodeType, nchunk, nindex) == Node.DOCUMENT_TYPE_NODE) {
                docTypeIndex = index;
                break;
            }
        }

        // find element definition
        if (docTypeIndex == -1) {
            return -1;
        }
        nchunk = docTypeIndex >> CHUNK_SHIFT;
        nindex = docTypeIndex & CHUNK_MASK;
        for (int index = getChunkIndex(fNodeLastChild, nchunk, nindex);
             index != -1;
             index = getChunkIndex(fNodePrevSib, nchunk, nindex)) {

            nchunk = index >> CHUNK_SHIFT;
            nindex = index & CHUNK_MASK;
            if (getChunkIndex(fNodeType, nchunk, nindex) ==
                                       NodeImpl.ELEMENT_DEFINITION_NODE
             && getChunkValue(fNodeName, nchunk, nindex) == elementName) {
                return index;
            }
        }
    }

    return -1;

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:48,代码来源:DeferredDocumentImpl.java

示例13: lookupPrefix

/**
 *
 * DOM Level 3 - Experimental:
 * Look up the prefix associated to the given namespace URI, starting from this node.
 *
 * @param namespaceURI
 * @return the prefix for the namespace
 */
public String lookupPrefix(String namespaceURI){

    // REVISIT: When Namespaces 1.1 comes out this may not be true
    // Prefix can't be bound to null namespace
    if (namespaceURI == null) {
        return null;
    }

    short type = this.getNodeType();

    switch (type) {
    case Node.ELEMENT_NODE: {

            String namespace = this.getNamespaceURI(); // to flip out children
            return lookupNamespacePrefix(namespaceURI, (ElementImpl)this);
        }
    case Node.DOCUMENT_NODE:{
            return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI);
        }

    case Node.ENTITY_NODE :
    case Node.NOTATION_NODE:
    case Node.DOCUMENT_FRAGMENT_NODE:
    case Node.DOCUMENT_TYPE_NODE:
        // type is unknown
        return null;
    case Node.ATTRIBUTE_NODE:{
            if (this.ownerNode.getNodeType() == Node.ELEMENT_NODE) {
                return ownerNode.lookupPrefix(namespaceURI);

            }
            return null;
        }
    default:{
            NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
            if (ancestor != null) {
                return ancestor.lookupPrefix(namespaceURI);
            }
            return null;
        }

    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:51,代码来源:NodeImpl.java

示例14: getNodeType

/**
 * A short integer indicating what type of node this is. The named
 * constants for this value are defined in the org.w3c.dom.Node interface.
 */
public short getNodeType() {
    return Node.DOCUMENT_TYPE_NODE;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:DocumentTypeImpl.java


注:本文中的org.w3c.dom.Node.DOCUMENT_TYPE_NODE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。