Package com.sun.org.apache.xpath.internal

Examples of com.sun.org.apache.xpath.internal.NodeSet


    String textNodeValue;

    if (rtf instanceof NodeIterator)
    {
      return new NodeSet((NodeIterator) rtf);
    }
    else
    {
      if (rtf instanceof String)
      {
        textNodeValue = (String) rtf;
      }
      else if (rtf instanceof Boolean)
      {
        textNodeValue = new XBoolean(((Boolean) rtf).booleanValue()).str();
      }
      else if (rtf instanceof Double)
      {
        textNodeValue = new XNumber(((Double) rtf).doubleValue()).str();
      }
      else
      {
        textNodeValue = rtf.toString();
      }

      // This no longer will work right since the DTM.
      // Document myDoc = myProcessor.getContextNode().getOwnerDocument();
      try
      {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document myDoc = db.newDocument();

        Text textNode = myDoc.createTextNode(textNodeValue);
        DocumentFragment docFrag = myDoc.createDocumentFragment();

        docFrag.appendChild(textNode);

        return new NodeSet(docFrag);
      }
      catch(ParserConfigurationException pce)
      {
        throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(pce);
      }
View Full Code Here


   * @return true if nl1 and nl2 contain exactly the same set of nodes.
   */
  public static boolean hasSameNodes(NodeList nl1, NodeList nl2)
  {

    NodeSet ns1 = new NodeSet(nl1);
    NodeSet ns2 = new NodeSet(nl2);

    if (ns1.getLength() != ns2.getLength())
      return false;

    for (int i = 0; i < ns1.getLength(); i++)
    {
      Node n = ns1.elementAt(i);

      if (!ns2.contains(n))
        return false;
    }

    return true;
  }
View Full Code Here

    Document doc = DocumentHolder.m_doc;


    StringTokenizer lTokenizer = new StringTokenizer(toTokenize, delims);
    NodeSet resultSet = new NodeSet();

    synchronized (doc)
    {
      while (lTokenizer.hasMoreTokens())
      {
        resultSet.addNode(doc.createTextNode(lTokenizer.nextToken()));
      }
    }

    return resultSet;
  }
View Full Code Here

        try{
//            int value = -1;
            Document d = getVerifierContext().getRuntimeDocument();
            if (d==null)
                return -1;
            NodeSet ns = new NodeSet(XPathAPI.selectNodeList(d, xpath));
            return ns.getLength();
        }catch(Exception ex){
            ex.printStackTrace();
            return -1;
        }
    }
View Full Code Here

            if (d==null)
                return -1;
            XObject result = XPathAPI.eval(d, xpath,
                             (PrefixResolver)new XpathPrefixResolver (d));
            NodeList nl = result.nodelist();
            NodeSet ns = new NodeSet(nl);
            return ns.getLength();
        }catch(Exception ex){
            ex.printStackTrace();
            return -1;
        }
    }
View Full Code Here

    // evaluate the XPath expression against the Document
    XPath xpath = XPathFactory.newInstance().newXPath();

    // Order node
    NodeSet nodes = (NodeSet) xpath.evaluate("//*", document, XPathConstants.NODESET);
    nodes.getLength();
    assertEquals("1234", xpath.evaluate("//*", document, XPathConstants.NODESET));
    assertEquals("1234", xpath.evaluate("/order/@id", document, XPathConstants.STRING));
    assertEquals("1234", xpath.evaluate("/order/@id", document));
    assertEquals("05/06/2013", xpath.evaluate("/order/@date", document));

View Full Code Here

   */
  public static NodeList highest (NodeList nl)
  {
    double maxValue = max(nl);

    NodeSet highNodes = new NodeSet();
    highNodes.setShouldCacheNodes(true);

    if (Double.isNaN(maxValue))
      return highNodes;  // empty Nodeset

    for (int i = 0; i < nl.getLength(); i++)
    {
      Node n = nl.item(i);
      double d = toNumber(n);
      if (d == maxValue)
        highNodes.addElement(n);
    }
    return highNodes;
  }
View Full Code Here

   */
  public static NodeList lowest (NodeList nl)
  {
    double minValue = min(nl);

    NodeSet lowNodes = new NodeSet();
    lowNodes.setShouldCacheNodes(true);

    if (Double.isNaN(minValue))
      return lowNodes;  // empty Nodeset

    for (int i = 0; i < nl.getLength(); i++)
    {
      Node n = nl.item(i);
      double d = toNumber(n);
      if (d == minValue)
        lowNodes.addElement(n);
    }
    return lowNodes;
  }
View Full Code Here

    String textNodeValue;

    if (rtf instanceof NodeIterator)
    {
      return new NodeSet((NodeIterator) rtf);
    }
    else
    {
      if (rtf instanceof String)
      {
        textNodeValue = (String) rtf;
      }
      else if (rtf instanceof Boolean)
      {
        textNodeValue = new XBoolean(((Boolean) rtf).booleanValue()).str();
      }
      else if (rtf instanceof Double)
      {
        textNodeValue = new XNumber(((Double) rtf).doubleValue()).str();
      }
      else
      {
        textNodeValue = rtf.toString();
      }

      // This no longer will work right since the DTM.
      // Document myDoc = myProcessor.getContextNode().getOwnerDocument();
      try
      {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document myDoc = db.newDocument();

        Text textNode = myDoc.createTextNode(textNodeValue);
        DocumentFragment docFrag = myDoc.createDocumentFragment();

        docFrag.appendChild(textNode);

        return new NodeSet(docFrag);
      }
      catch(ParserConfigurationException pce)
      {
        throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(pce);
      }
View Full Code Here

   * @return true if nl1 and nl2 contain exactly the same set of nodes.
   */
  public static boolean hasSameNodes(NodeList nl1, NodeList nl2)
  {

    NodeSet ns1 = new NodeSet(nl1);
    NodeSet ns2 = new NodeSet(nl2);

    if (ns1.getLength() != ns2.getLength())
      return false;

    for (int i = 0; i < ns1.getLength(); i++)
    {
      Node n = ns1.elementAt(i);

      if (!ns2.contains(n))
        return false;
    }

    return true;
  }
View Full Code Here

TOP

Related Classes of com.sun.org.apache.xpath.internal.NodeSet

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.