Package org.apache.xpath

Examples of org.apache.xpath.XPath


      xctxt.pushCurrentNode(contextNode);
     
      double result = 0;
      try
      {
        XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(),
                                       xctxt.getNamespaceContext(),
                                       XPath.SELECT);
        result = dynamicXPath.execute(xctxt, contextNode, xctxt.getNamespaceContext()).num();
      }
      catch (TransformerException e)
      {
        xctxt.popCurrentNode();
        xctxt.popContextNodeList();
View Full Code Here


      xctxt.pushCurrentNode(contextNode);
     
      double result = 0;
      try
      {
        XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(),
                                       xctxt.getNamespaceContext(),
                                       XPath.SELECT);
        result = dynamicXPath.execute(xctxt, contextNode, xctxt.getNamespaceContext()).num();
      }
      catch (TransformerException e)
      {
        xctxt.popCurrentNode();
        xctxt.popContextNodeList();
View Full Code Here

      xctxt.pushCurrentNode(contextNode);
     
      XObject object = null;
      try
      {
        XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(),
                                       xctxt.getNamespaceContext(),
                                       XPath.SELECT);
        object = dynamicXPath.execute(xctxt, contextNode, xctxt.getNamespaceContext());
       
        if (object instanceof XNodeSet)
        {
          NodeList nodelist = null;
          nodelist = ((XNodeSet)object).nodelist();
View Full Code Here

    {
      XPathContext xctxt = null;
      try
      {
        xctxt = ((XPathContext.XPathExpressionContext) myContext).getXPathContext();
        XPath dynamicXPath = new XPath(xpathExpr, xctxt.getSAXLocator(),
                                       xctxt.getNamespaceContext(),
                                       XPath.SELECT);

        return dynamicXPath.execute(xctxt, myContext.getContextNode(),
                                    xctxt.getNamespaceContext());
      }
      catch (TransformerException e)
      {
        return new XNodeSet(xctxt.getDTMManager());
View Full Code Here

        xctxt.pushCurrentNode(contextNode);

        XObject object = null;
        try
        {
          XPath dynamicXPath = new XPath(expr, xctxt.getSAXLocator(),
                                         xctxt.getNamespaceContext(),
                                         XPath.SELECT);
          object = dynamicXPath.execute(xctxt, contextNode, xctxt.getNamespaceContext());
         
          if (object instanceof XNodeSet)
          {
            NodeList nodelist = null;
            nodelist = ((XNodeSet)object).nodelist();
View Full Code Here

    @Test
    public void testIterationContext() throws Exception {
        expect(pageContext.findAttribute("doc")).andStubReturn(test);
        tag.setSelect("$doc/root/a/num");
        replay(pageContext);
        XPath dot = new XPath(".", null, null, XPath.SELECT);
        XPath position = new XPath("position()", null, null, XPath.SELECT);
        XPath last = new XPath("last()", null, null, XPath.SELECT);
        tag.prepare();
        XPathContext context = tag.getContext();
        tag.hasNext();
        tag.next();
        Assert.assertEquals("3", last.execute(context, context.getCurrentNode(), null).str());
        Assert.assertEquals("one", dot.execute(context, context.getCurrentNode(), null).str());
        Assert.assertEquals("1", position.execute(context, context.getCurrentNode(), null).str());
        tag.hasNext();
        tag.next();
        Assert.assertEquals("two", dot.execute(context, context.getCurrentNode(), null).str());
View Full Code Here

            Element child = test.createElement("a");
            child.setTextContent(Integer.toString(i));
            root.appendChild(child);
        }

        XPath dot = new XPath(".", null, null, XPath.SELECT);
        expect(pageContext.findAttribute("doc")).andStubReturn(test);
        tag.setSelect("$doc/root/a");
        replay(pageContext);
        long time = -System.nanoTime();
        XObject result = null;
View Full Code Here

        expect(tag.getParent()).andReturn(null);
        expect(pageContext.findAttribute("a")).andReturn("Hello");
        expect(pageContext.getAttribute("b", PageContext.REQUEST_SCOPE)).andReturn("World");
        replay(pageContext, tag);
        XPathContext context = XalanUtil.getContext(tag, pageContext);
        XPath xpath = new XPath("concat($a, ' ', $requestScope:b)", null, null, XPath.SELECT);
        Assert.assertEquals("Hello World", xpath.execute(context, context.getCurrentNode(), null).str());
        verify(pageContext, tag);
    }
View Full Code Here

        if (prefixResolver == null) prefixResolver = new PrefixResolverDefault(
          (namespaceNode.getNodeType() == Node.DOCUMENT_NODE) ? ((Document) namespaceNode).getDocumentElement() : namespaceNode);

        // Create the XPath object.
        XPath xpath = (XPath)XpathTable.get(path);
        if (xpath == null) {
          xpath = new XPath(path, null, prefixResolver, XPath.SELECT, null);
          XpathTable.put(path,xpath);
        }

        // Execute the XPath, and have it return the result
        int ctxtNode = xpathSupport.getDTMHandleFromNode(data);
        return xpath.execute(xpathSupport, ctxtNode, prefixResolver);
    }
View Full Code Here

               XPathContext xpc = new XPathContext();
               PrefixResolver pfx;
               if ( pr == null ) {
                  pfx = new PrefixResolverDefault(d.getDocumentElement());
                  xp = new XPath(query, null, pfx, XPath.SELECT, errors);
               }
               else {
                  pfx = pr;
                  if ( xp == null )
                     xp = new XPath(query, null, pfx, XPath.SELECT, errors);
               }

               ni = xp.execute(xpc, n, pfx).nodeset();

               node = ni.nextNode();
View Full Code Here

TOP

Related Classes of org.apache.xpath.XPath

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.