Package org.w3c.dom.traversal

Examples of org.w3c.dom.traversal.NodeIterator


      return new NodeListImpl();

    DocumentImpl document = (DocumentImpl) getOwnerDocument();
    if (document == null)
      return new NodeListImpl();
    NodeIterator it = document.createNodeIterator(this, NodeFilter.SHOW_ALL, null, false);
    if (it == null)
      return new NodeListImpl();
    NodeListImpl elements = new NodeListImpl();

    if (tagName.length() == 1 && tagName.charAt(0) == '*') {
      tagName = null; // do not care
    }

    it.nextNode(); // skip the first node since it is the root from createNodeIterator
    for (Node node = it.nextNode(); node != null; node = it.nextNode()) {
      if (node.getNodeType() != ELEMENT_NODE)
        continue;
      if (tagName != null) {
        ElementImpl element = (ElementImpl) node;
        if (!element.matchTagName(tagName))
View Full Code Here


      return new NodeListImpl();

    DocumentImpl document = (DocumentImpl) getOwnerDocument();
    if (document == null)
      return new NodeListImpl();
    NodeIterator it = document.createNodeIterator(this, NodeFilter.SHOW_ALL, null, false);
    if (it == null)
      return new NodeListImpl();
    NodeListImpl elements = new NodeListImpl();

    if (uri != null && uri.length() == 1 && uri.charAt(0) == '*') {
      uri = null; // do not care
    }
    if (tagName.length() == 1 && tagName.charAt(0) == '*') {
      tagName = null; // do not care
    }

    it.nextNode(); // skip the first node since it is the root from createNodeIterator
    for (Node node = it.nextNode(); node != null; node = it.nextNode()) {
      if (node.getNodeType() != ELEMENT_NODE)
        continue;
      ElementImpl element = (ElementImpl) node;
      if (tagName != null) {
        String localName = element.getLocalName();
View Full Code Here

  }

  public Element getElementById(String id) {
    if (id == null)
      return null;
    NodeIterator it = createNodeIterator(this, NodeFilter.SHOW_ALL, null, false);
    if (it == null)
      return null;

    for (Node node = it.nextNode(); node != null; node = it.nextNode()) {
      if (node.getNodeType() != ELEMENT_NODE)
        continue;
      ElementImpl element = (ElementImpl) node;
      if (element.hasAttribute("id") && id.equals(element.getAttribute("id"))) //$NON-NLS-1$ //$NON-NLS-2$
        return element;
View Full Code Here

   */
  public NodeList getElementsByTagNameNS(String uri, String tagName) {
    if (tagName == null)
      return new NodeListImpl();

    NodeIterator it = createNodeIterator(this, NodeFilter.SHOW_ALL, null, false);
    if (it == null)
      return new NodeListImpl();
    NodeListImpl elements = new NodeListImpl();

    if (uri != null && uri.length() == 1 && uri.charAt(0) == '*') {
      uri = null; // do not care
    }
    if (tagName.length() == 1 && tagName.charAt(0) == '*') {
      tagName = null; // do not care
    }

    for (Node node = it.nextNode(); node != null; node = it.nextNode()) {
      if (node.getNodeType() != ELEMENT_NODE)
        continue;
      ElementImpl element = (ElementImpl) node;
      if (tagName != null) {
        String localName = element.getLocalName();
View Full Code Here

    return imported;
  }

  private NodeListImpl internalGetElementsByTagName(String tagName) {
    // System.out.println("getElementsByTagname: " + tagName);
    NodeIterator it = createNodeIterator(this, NodeFilter.SHOW_ALL, null, false);
    if (it == null)
      return new NodeListImpl();
    NodeListImpl elements = new NodeListImpl();

    if (tagName.length() == 1 && tagName.charAt(0) == '*') {
      tagName = null; // do not care
    }

    for (Node node = it.nextNode(); node != null; node = it.nextNode()) {
      if (node.getNodeType() != ELEMENT_NODE)
        continue;
      if (tagName != null) {
        ElementImpl element = (ElementImpl) node;
        if (!element.matchTagName(tagName))
View Full Code Here

        if ( returnType.equals( XPathConstants.NODESET ) ) {
            return resultObject.nodelist();
        }
        // XPathConstants.NODE
        if ( returnType.equals( XPathConstants.NODE ) ) {
            NodeIterator ni = resultObject.nodeset();
            //Return the first node, or null
            return ni.nextNode();
        }
        // If isSupported check is already done then the execution path
        // shouldn't come here. Being defensive
        String fmsg = XSLMessages.createXPATHMessage(
                XPATHErrorResources.ER_UNSUPPORTED_RETURN_TYPE,
View Full Code Here

        if ( returnType.equals( XPathConstants.NODESET ) ) {
            return resultObject.nodelist();
        }
        // XPathConstants.NODE
        if ( returnType.equals( XPathConstants.NODE ) ) {
            NodeIterator ni = resultObject.nodeset();
            //Return the first node, or null
            return ni.nextNode();
        }
        String fmsg = XSLMessages.createXPATHMessage(
                XPATHErrorResources.ER_UNSUPPORTED_RETURN_TYPE,
                new Object[] { returnType.toString()});
        throw new IllegalArgumentException( fmsg );
View Full Code Here

        throw new XPathException(XPathException.TYPE_ERR,fmsg);
//        "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be converted to a single node.
//         This method applies only to types ANY_UNORDERED_NODE_TYPE and FIRST_ORDERED_NODE_TYPE."
      }
 
    NodeIterator result = null;
    try {
      result = m_resultObj.nodeset();
    } catch (TransformerException te) {
      throw new XPathException(XPathException.TYPE_ERR,te.getMessage());
    }
       
        if (null == result) return null;
       
        Node node = result.nextNode();
        
        // Wrap "namespace node" in an XPathNamespace
        if (isNamespaceNode(node)) {
            return new XPathNamespaceImpl(node);
        } else {
View Full Code Here

        throw new XPathException(XPathException.TYPE_ERR,fmsg);
//        "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be converted to a single node.
//         This method applies only to types ANY_UNORDERED_NODE_TYPE and FIRST_ORDERED_NODE_TYPE."
      }
 
    NodeIterator result = null;
    try {
      result = m_resultObj.nodeset();
    } catch (TransformerException te) {
      throw new XPathException(XPathException.TYPE_ERR,te.getMessage());
    }
       
        if (null == result) return null;
       
        Node node = result.nextNode();
        
        // Wrap "namespace node" in an XPathNamespace
        if (isNamespaceNode(node)) {
            return new XPathNamespaceImpl(node);
        } else {
View Full Code Here

          Node contextNode, String str, Node namespaceNode)
            throws TransformerException
  {

    // Have the XObject return its result as a NodeSetDTM.
    NodeIterator nl = selectNodeIterator(contextNode, str, namespaceNode);

    // Return the first node, or null
    return nl.nextNode();
  }
View Full Code Here

TOP

Related Classes of org.w3c.dom.traversal.NodeIterator

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.