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


Java Node.DOCUMENT_NODE属性代码示例

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


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

示例1: hasLegalRootContainer

/**
 * Finds the root container for the given node and determines
 * if that root container is legal with respect to the
 * DOM 2 specification.  At present, that means the root
 * container must be either an attribute, a document,
 * or a document fragment.
 */
private boolean hasLegalRootContainer( Node node )
{
	if ( node==null )
		return false;

	Node rootContainer = getRootContainer( node );
	switch( rootContainer.getNodeType() )
	{
	case Node.ATTRIBUTE_NODE:
	case Node.DOCUMENT_NODE:
	case Node.DOCUMENT_FRAGMENT_NODE:
		return true;
	}
	return false;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:22,代码来源:RangeImpl.java

示例2: isLegalContainedNode

/**
 * Returns true IFF the given node can be contained by
 * a range.
 */
private boolean isLegalContainedNode( Node node )
{
	if ( node==null )
		return false;
	switch( node.getNodeType() )
	{
	case Node.DOCUMENT_NODE:
	case Node.DOCUMENT_FRAGMENT_NODE:
	case Node.ATTRIBUTE_NODE:
	case Node.ENTITY_NODE:
	case Node.NOTATION_NODE:
		return false;
	}
	return true;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:19,代码来源:RangeImpl.java

示例3: setDOMResult

public void setDOMResult(DOMResult result) {
    fCurrentNode = null;
    fFragmentRoot = null;
    fIgnoreChars = false;
    fTargetChildren.clear();
    if (result != null) {
    	//MF
        fTarget = (Node) result.getNode();
        //MF
        fNextSibling = (Node) result.getNextSibling();
        fDocument = (fTarget.getNodeType() == Node.DOCUMENT_NODE) ? (Document) fTarget : fTarget.getOwnerDocument();
        fDocumentImpl = (fDocument instanceof CoreDocumentImpl) ? (CoreDocumentImpl) fDocument : null;
        fStorePSVI = (fDocument instanceof PSVIDocumentImpl);
        return;
    }
    fTarget = null;
    fNextSibling = null;
    fDocument = null;
    fDocumentImpl = null;
    fStorePSVI = false;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:21,代码来源:DOMResultBuilder.java

示例4: _getXmlVersion

private String _getXmlVersion(Node node) {
    Document doc = (node.getNodeType() == Node.DOCUMENT_NODE) ? 
            (Document) node : node.getOwnerDocument();
    if (doc != null && DocumentMethods.fgDocumentMethodsAvailable) {
        try {
            return (String) DocumentMethods.fgDocumentGetXmlVersionMethod.invoke(doc, (Object[]) null);
        }
        // The VM ran out of memory or there was some other serious problem. Re-throw.
        catch (VirtualMachineError vme) {
            throw vme;
        }
        // ThreadDeath should always be re-thrown
        catch (ThreadDeath td) {
            throw td;
        }
        // Ignore all other exceptions and errors
        catch (Throwable t) {}
    }
    return null;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:20,代码来源:DOMSerializerImpl.java

示例5: _getInputEncoding

private String _getInputEncoding(Node node) {
    Document doc = (node.getNodeType() == Node.DOCUMENT_NODE) ? 
            (Document) node : node.getOwnerDocument();
    if (doc != null && DocumentMethods.fgDocumentMethodsAvailable) {
        try {
            return (String) DocumentMethods.fgDocumentGetInputEncodingMethod.invoke(doc, (Object[]) null);
        }
        // The VM ran out of memory or there was some other serious problem. Re-throw.
        catch (VirtualMachineError vme) {
            throw vme;
        }
        // ThreadDeath should always be re-thrown
        catch (ThreadDeath td) {
            throw td;
        }
        // Ignore all other exceptions and errors
        catch (Throwable t) {}
    }
    return null;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:20,代码来源:DOMSerializerImpl.java

示例6: _getXmlEncoding

private String _getXmlEncoding(Node node) {
    Document doc = (node.getNodeType() == Node.DOCUMENT_NODE) ? 
            (Document) node : node.getOwnerDocument();
    if (doc != null && DocumentMethods.fgDocumentMethodsAvailable) {
        try {
            return (String) DocumentMethods.fgDocumentGetXmlEncodingMethod.invoke(doc, (Object[]) null);
        }
        // The VM ran out of memory or there was some other serious problem. Re-throw.
        catch (VirtualMachineError vme) {
            throw vme;
        }
        // ThreadDeath should always be re-thrown
        catch (ThreadDeath td) {
            throw td;
        }
        // Ignore all other exceptions and errors
        catch (Throwable t) {}
    }
    return null;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:20,代码来源:DOMSerializerImpl.java

示例7: useIsSameNode

/**
 * Use isSameNode() for testing node identity if the DOM implementation
 * supports DOM Level 3 core and it isn't the Xerces implementation.
 */
private boolean useIsSameNode(Node node) {
    if (node instanceof NodeImpl) {
        return false;
    }
    Document doc = node.getNodeType() == Node.DOCUMENT_NODE 
        ? (Document) node : node.getOwnerDocument();
    return (doc != null && doc.getImplementation().hasFeature("Core", "3.0"));
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:12,代码来源:TreeWalkerImpl.java

示例8: setDOMResult

public void setDOMResult(DOMResult result) {
    fIgnoreChars = false;
    if (result != null) {
    	//MF - Renamed - Resourced
        final Node target = (Node) result.getNode();
        fDocument = (target.getNodeType() == Node.DOCUMENT_NODE) ? (Document) target : target.getOwnerDocument();
        fDocumentImpl = (fDocument instanceof CoreDocumentImpl) ? (CoreDocumentImpl) fDocument : null;
        fStorePSVI = (fDocument instanceof PSVIDocumentImpl);
        return;
    }
    fDocument = null;
    fDocumentImpl = null;
    fStorePSVI = false;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:14,代码来源:DOMResultAugmentor.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: {
            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:MaTriXy,项目名称:xerces-for-android,代码行数:50,代码来源:NodeImpl.java

示例10: getNodeType

/** Returns the node type. */
public short getNodeType() {
    return Node.DOCUMENT_NODE;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:4,代码来源:CoreDocumentImpl.java

示例11: 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:MaTriXy,项目名称:xerces-for-android,代码行数:45,代码来源:RangeImpl.java

示例12: getSchemaDocument

/**
 * getSchemaDocument method uses DOMInputSource to parse a schema document.
 * @param schemaNamespace
 * @param schemaSource
 * @param mustResolve
 * @param referType
 * @param referElement
 * @return A schema Element.
 */
private Element getSchemaDocument(String schemaNamespace, DOMInputSource schemaSource,
        boolean mustResolve, short referType, Element referElement) {
    boolean hasInput = true;
    IOException exception = null;
    Element schemaElement = null;
    Element schemaRootElement = null;
    
    final Node node = schemaSource.getNode();
    short nodeType = -1;
    if (node != null) {
        nodeType = node.getNodeType();
        if (nodeType == Node.DOCUMENT_NODE) {
            schemaRootElement = DOMUtil.getRoot((Document) node);
        }
        else if (nodeType == Node.ELEMENT_NODE) {
            schemaRootElement = (Element) node;
        }
    }
    
    try {
        if (schemaRootElement != null) {
            // check whether the same document has been parsed before. 
            // If so, return the document corresponding to that system id.
            XSDKey key = null;
            String schemaId = null;
            if (referType != XSDDescription.CONTEXT_PREPARSE) {
                schemaId = XMLEntityManager.expandSystemId(schemaSource.getSystemId(), schemaSource.getBaseSystemId(), false);
                boolean isDocument = (nodeType == Node.DOCUMENT_NODE);
                if (!isDocument) {
                    Node parent = schemaRootElement.getParentNode();
                    if (parent != null) {
                        isDocument = (parent.getNodeType() == Node.DOCUMENT_NODE);
                    }
                }
                if (isDocument) {
                    key = new XSDKey(schemaId, referType, schemaNamespace);
                    if ((schemaElement = (Element) fTraversed.get(key)) != null) {
                        fLastSchemaWasDuplicate = true;
                        return schemaElement;
                    }
                }
            }

            schemaElement = schemaRootElement;
            return getSchemaDocument0(key, schemaId, schemaElement);
        }
        else {
            hasInput = false;
        }
    }
    catch (IOException ioe) {
        exception = ioe;
    }
    return getSchemaDocument1(mustResolve, hasInput, schemaSource, referElement, exception);
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:64,代码来源:XSDHandler.java

示例13: DefaultDocument

public DefaultDocument() {
    this.nodeType = Node.DOCUMENT_NODE;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:3,代码来源:DefaultDocument.java

示例14: prepareForSerialization

private void prepareForSerialization(XMLSerializer ser, Node node) {
    ser.reset();
    ser.features = features;
    ser.fDOMErrorHandler = fErrorHandler;
    ser.fNamespaces = (features & NAMESPACES) != 0;
    ser.fNamespacePrefixes = (features & NSDECL) != 0;
    ser._format.setIndenting((features & PRETTY_PRINT) != 0);
    ser._format.setOmitComments((features & COMMENTS)==0);
    ser._format.setOmitXMLDeclaration((features & XMLDECL) == 0);   
 
    if ((features & WELLFORMED) != 0) {
        // REVISIT: this is inefficient implementation of well-formness. Instead, we should check
        // well-formness as we serialize the tree
        Node next, root;
        root = node;
        Method versionChanged;
        boolean verifyNames = true;
        Document document =(node.getNodeType() == Node.DOCUMENT_NODE)
                ? (Document) node
                : node.getOwnerDocument();
        try {
            versionChanged = document.getClass().getMethod("isXMLVersionChanged()", new Class[] {});
            if (versionChanged != null) {
                verifyNames = ((Boolean)versionChanged.invoke(document, (Object[]) null)).booleanValue();
            }
        } catch (Exception e) {
            //no way to test the version...
            //ignore the exception
        }
        if (node.getFirstChild() != null) {
            while (node != null) {
                verify(node, verifyNames, false);
                // Move down to first child
                next = node.getFirstChild();
                // No child nodes, so walk tree
                while (next == null) {
                  // Move to sibling if possible.
                  next = node.getNextSibling();
                  if (next == null) {
                      node = node.getParentNode();
                      if (root == node){
                          next = null;
                          break;                   
                      }
                      next = node.getNextSibling();
                  }
                }
                node = next;
            }
        }
        else {
            verify(node, verifyNames, false);
        }
    }
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:55,代码来源:DOMSerializerImpl.java


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