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


Java Node.DOCUMENT_FRAGMENT_NODE属性代码示例

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


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

示例1: 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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:RangeImpl.java

示例2: 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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:RangeImpl.java

示例3: print

public void print(Node node) throws XMLStreamException {
    switch (node.getNodeType()) {
    case Node.DOCUMENT_NODE:
        visitDocument((Document) node);
        break;
    case Node.DOCUMENT_FRAGMENT_NODE:
        visitDocumentFragment((DocumentFragment) node);
        break;
    case Node.ELEMENT_NODE:
        visitElement((Element) node);
        break;
    case Node.TEXT_NODE:
        visitText((Text) node);
        break;
    case Node.CDATA_SECTION_NODE:
        visitCDATASection((CDATASection) node);
        break;
    case Node.PROCESSING_INSTRUCTION_NODE:
        visitProcessingInstruction((ProcessingInstruction) node);
        break;
    case Node.ENTITY_REFERENCE_NODE:
        visitReference((EntityReference) node);
        break;
    case Node.COMMENT_NODE:
        visitComment((Comment) node);
        break;
    case Node.DOCUMENT_TYPE_NODE:
        break;
    case Node.ATTRIBUTE_NODE:
    case Node.ENTITY_NODE:
    default:
        throw new XMLStreamException("Unexpected DOM Node Type "
            + node.getNodeType()
        );
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:DOMPrinter.java

示例4: getNodeData

/**
 * Retrieve the text content of a DOM subtree, appending it into a
 * user-supplied FastStringBuffer object. Note that attributes are
 * not considered part of the content of an element.
 * <p>
 * There are open questions regarding whitespace stripping.
 * Currently we make no special effort in that regard, since the standard
 * DOM doesn't yet provide DTD-based information to distinguish
 * whitespace-in-element-context from genuine #PCDATA. Note that we
 * should probably also consider xml:space if/when we address this.
 * DOM Level 3 may solve the problem for us.
 * <p>
 * %REVIEW% Actually, since this method operates on the DOM side of the
 * fence rather than the DTM side, it SHOULDN'T do
 * any special handling. The DOM does what the DOM does; if you want
 * DTM-level abstractions, use DTM-level methods.
 *
 * @param node Node whose subtree is to be walked, gathering the
 * contents of all Text or CDATASection nodes.
 * @param buf FastStringBuffer into which the contents of the text
 * nodes are to be concatenated.
 */
protected static void getNodeData(Node node, FastStringBuffer buf)
{

  switch (node.getNodeType())
  {
  case Node.DOCUMENT_FRAGMENT_NODE :
  case Node.DOCUMENT_NODE :
  case Node.ELEMENT_NODE :
  {
    for (Node child = node.getFirstChild(); null != child;
            child = child.getNextSibling())
    {
      getNodeData(child, buf);
    }
  }
  break;
  case Node.TEXT_NODE :
  case Node.CDATA_SECTION_NODE :
  case Node.ATTRIBUTE_NODE :  // Never a child but might be our starting node
    buf.append(node.getNodeValue());
    break;
  case Node.PROCESSING_INSTRUCTION_NODE :
    // warning(XPATHErrorResources.WG_PARSING_AND_PREPARING);
    break;
  default :
    // ignore
    break;
  }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:51,代码来源:DOM2DTM.java

示例5: getNodeData

/**
 * Retrieve the text content of a DOM subtree, appending it into a
 * user-supplied FastStringBuffer object. Note that attributes are
 * not considered part of the content of an element.
 * <p>
 * There are open questions regarding whitespace stripping.
 * Currently we make no special effort in that regard, since the standard
 * DOM doesn't yet provide DTD-based information to distinguish
 * whitespace-in-element-context from genuine #PCDATA. Note that we
 * should probably also consider xml:space if/when we address this.
 * DOM Level 3 may solve the problem for us.
 *
 * @param node Node whose subtree is to be walked, gathering the
 * contents of all Text or CDATASection nodes.
 * @param buf FastStringBuffer into which the contents of the text
 * nodes are to be concatenated.
 */
public static void getNodeData(Node node, FastStringBuffer buf)
{

  switch (node.getNodeType())
  {
  case Node.DOCUMENT_FRAGMENT_NODE :
  case Node.DOCUMENT_NODE :
  case Node.ELEMENT_NODE :
  {
    for (Node child = node.getFirstChild(); null != child;
            child = child.getNextSibling())
    {
      getNodeData(child, buf);
    }
  }
  break;
  case Node.TEXT_NODE :
  case Node.CDATA_SECTION_NODE :
    buf.append(node.getNodeValue());
    break;
  case Node.ATTRIBUTE_NODE :
    buf.append(node.getNodeValue());
    break;
  case Node.PROCESSING_INSTRUCTION_NODE :
    // warning(XPATHErrorResources.WG_PARSING_AND_PREPARING);
    break;
  default :
    // ignore
    break;
  }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:48,代码来源:DOMHelper.java

示例6: dispatchNodeData

/**
   * Retrieve the text content of a DOM subtree, appending it into a
   * user-supplied FastStringBuffer object. Note that attributes are
   * not considered part of the content of an element.
   * <p>
   * There are open questions regarding whitespace stripping.
   * Currently we make no special effort in that regard, since the standard
   * DOM doesn't yet provide DTD-based information to distinguish
   * whitespace-in-element-context from genuine #PCDATA. Note that we
   * should probably also consider xml:space if/when we address this.
   * DOM Level 3 may solve the problem for us.
   * <p>
   * %REVIEW% Note that as a DOM-level operation, it can be argued that this
   * routine _shouldn't_ perform any processing beyond what the DOM already
   * does, and that whitespace stripping and so on belong at the DTM level.
   * If you want a stripped DOM view, wrap DTM2DOM around DOM2DTM.
   *
   * @param node Node whose subtree is to be walked, gathering the
   * contents of all Text or CDATASection nodes.
   */
  protected static void dispatchNodeData(Node node,
                                         org.xml.sax.ContentHandler ch,
                                         int depth)
            throws org.xml.sax.SAXException
  {

    switch (node.getNodeType())
    {
    case Node.DOCUMENT_FRAGMENT_NODE :
    case Node.DOCUMENT_NODE :
    case Node.ELEMENT_NODE :
    {
      for (Node child = node.getFirstChild(); null != child;
              child = child.getNextSibling())
      {
        dispatchNodeData(child, ch, depth+1);
      }
    }
    break;
    case Node.PROCESSING_INSTRUCTION_NODE : // %REVIEW%
    case Node.COMMENT_NODE :
      if(0 != depth)
        break;
        // NOTE: Because this operation works in the DOM space, it does _not_ attempt
        // to perform Text Coalition. That should only be done in DTM space.
    case Node.TEXT_NODE :
    case Node.CDATA_SECTION_NODE :
    case Node.ATTRIBUTE_NODE :
      String str = node.getNodeValue();
      if(ch instanceof CharacterNodeHandler)
      {
        ((CharacterNodeHandler)ch).characters(node);
      }
      else
      {
        ch.characters(str.toCharArray(), 0, str.length());
      }
      break;
//    /* case Node.PROCESSING_INSTRUCTION_NODE :
//      // warning(XPATHErrorResources.WG_PARSING_AND_PREPARING);
//      break; */
    default :
      // ignore
      break;
    }
  }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:66,代码来源:DOM2DTM.java

示例7: 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,代码来源:DOM2DTMdefaultNamespaceDeclarationNode.java

示例8: addNodeInTree2

private static void addNodeInTree2(Node node, Document document, Element parent, int [] index) {
    Element currentElement = createElement2(document, node, index);
    currentElement.setAttribute("type", Short.toString(node.getNodeType()));

    switch (node.getNodeType()) {
        case Node.ELEMENT_NODE:
            currentElement.setAttribute("text", node.getNodeName());
            NamedNodeMap map = node.getAttributes();
            if (node.hasAttributes()) {
                Element attributes = createElement2(document, node, index);
                attributes.setAttribute("text", "Attributes");
                attributes.setAttribute("type", Short.toString(Node.ATTRIBUTE_NODE));
                currentElement.appendChild(attributes);

                for (int i = 0; i < map.getLength(); ++i) {
                    Element attribute = createElement2(document, map.item(i), index);
                    attribute.setAttribute("text", map.item(i).getNodeName() + "=\"" + map.item(i).getNodeValue() + "\"");
                    attribute.setAttribute("type", Short.toString(Node.ATTRIBUTE_NODE));
                    attributes.appendChild(attribute);
                }
            }
            break;

        case Node.TEXT_NODE:
            currentElement.setAttribute("text", node.getNodeValue() == null ? "" : node.getNodeValue().trim());
            break;

        case Node.ENTITY_NODE:
            currentElement.setAttribute("text", "[Entity]");
            break;

        case Node.ENTITY_REFERENCE_NODE:
            currentElement.setAttribute("text", "[Entityref]");
            break;

        case Node.PROCESSING_INSTRUCTION_NODE:
            currentElement.setAttribute("text", "[Pi]");
            break;

        case Node.COMMENT_NODE:
            currentElement.setAttribute("text", "[Comment]");
            break;

        case Node.DOCUMENT_FRAGMENT_NODE:
            currentElement.setAttribute("text", "[Docfgmt]");
            break;

        case Node.DOCUMENT_TYPE_NODE:
            currentElement.setAttribute("text", "[Doctype]");
            break;

        case Node.NOTATION_NODE:
            currentElement.setAttribute("text", "[Notation]");
            break;

        default:
            break;
    }
    parent.appendChild(currentElement);

    NodeList nodeList = node.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node currentNode = nodeList.item(i);
        addNodeInTree2(currentNode, document, currentElement, index);
    }
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:66,代码来源:TwsDomTreeWrap.java

示例9: lookupPrefix

/**
     *
     * DOM Level 3
     * Look up the prefix associated to the given namespace URI, starting from this node.
     *
     * @param namespaceURI
     * @return the prefix for the namespace
     */
    @Override
    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,代码行数:55,代码来源:DTMNodeProxy.java

示例10: NodeCreateRule

/**
 * Constructor. Creates an instance of this rule that will create either a 
 * DOM {@link org.w3c.dom.Element Element} or a DOM 
 * {@link org.w3c.dom.DocumentFragment DocumentFragment}, depending on the
 * value of the <code>nodeType</code> parameter. This constructor lets you
 * specify the JAXP <code>DocumentBuilder</code> that should be used when
 * constructing the node tree.
 * 
 * @param nodeType the type of node to create, which can be either
 *   {@link org.w3c.dom.Node#ELEMENT_NODE Node.ELEMENT_NODE} or 
 *   {@link org.w3c.dom.Node#DOCUMENT_FRAGMENT_NODE Node.DOCUMENT_FRAGMENT_NODE}
 * @param documentBuilder the JAXP <code>DocumentBuilder</code> to use
 * @throws IllegalArgumentException if the node type is not supported
 */
public NodeCreateRule(int nodeType, DocumentBuilder documentBuilder) {

    if (!((nodeType == Node.DOCUMENT_FRAGMENT_NODE) ||
          (nodeType == Node.ELEMENT_NODE))) {
        throw new IllegalArgumentException(
            "Can only create nodes of type DocumentFragment and Element");
    }
    this.nodeType = nodeType;
    this.documentBuilder = documentBuilder;

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:25,代码来源:NodeCreateRule.java

示例11: NodeCreateRule

/**
 * Constructor. Creates an instance of this rule that will create either a
 * DOM {@link org.w3c.dom.Element Element} or a DOM
 * {@link org.w3c.dom.DocumentFragment DocumentFragment}, depending on the
 * value of the <code>nodeType</code> parameter. This constructor lets you
 * specify the JAXP <code>DocumentBuilder</code> that should be used when
 * constructing the node tree.
 * 
 * @param nodeType
 *            the type of node to create, which can be either
 *            {@link org.w3c.dom.Node#ELEMENT_NODE Node.ELEMENT_NODE} or
 *            {@link org.w3c.dom.Node#DOCUMENT_FRAGMENT_NODE
 *            Node.DOCUMENT_FRAGMENT_NODE}
 * @param documentBuilder
 *            the JAXP <code>DocumentBuilder</code> to use
 * @throws IllegalArgumentException
 *             if the node type is not supported
 */
public NodeCreateRule(int nodeType, DocumentBuilder documentBuilder) {

	if (!((nodeType == Node.DOCUMENT_FRAGMENT_NODE) || (nodeType == Node.ELEMENT_NODE))) {
		throw new IllegalArgumentException("Can only create nodes of type DocumentFragment and Element");
	}
	this.nodeType = nodeType;
	this.documentBuilder = documentBuilder;

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:27,代码来源:NodeCreateRule.java

示例12: getRootNode

/**
 * Get the root node of the document tree, regardless of
 * whether or not the node passed in is a document node.
 * <p>
 * TODO: This doesn't handle DocumentFragments or "orphaned" subtrees
 * -- it's currently returning ownerDocument even when the tree is
 * not actually part of the main Document tree. We should either
 * rewrite the description to say that it finds the Document node,
 * or change the code to walk up the ancestor chain.

 *
 * @param n Node to be examined
 *
 * @return the Document node. Note that this is not the correct answer
 * if n was (or was a child of) a DocumentFragment or an orphaned node,
 * as can arise if the DOM has been edited rather than being generated
 * by a parser.
 */
public Node getRootNode(Node n)
{
  int nt = n.getNodeType();
  return ( (Node.DOCUMENT_NODE == nt) || (Node.DOCUMENT_FRAGMENT_NODE == nt) )
         ? n : n.getOwnerDocument();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:DOMHelper.java

示例13: 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_FRAGMENT_NODE;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:DocumentFragmentImpl.java


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