Examples of XPathEvaluator


Examples of net.sf.saxon.sxpath.XPathEvaluator

    public List selectNodes(Object node)
    {
        try
        {
            DOMSource rootNode = new DOMSource((Node) node);
            XPathEvaluator xpe = new XPathEvaluator();
            XBeansIndependentContext sc = new XBeansIndependentContext();

            // Declare ns bindings
            if (defaultNS != null)
                sc.setDefaultElementNamespace(defaultNS);

            for (int i = 0; i < namespaceMap.length; i++)
            {
                Map.Entry entry = (Map.Entry) namespaceMap[i];
                sc.declareNamespace((String) entry.getKey(),
                        (String) entry.getValue());
            }

            xpe.setStaticContext(sc);

            Variable thisVar = sc.declareVariable("this");
            thisVar.setValue(rootNode);

            XPathExpression exp = xpe.createExpression(_queryExp);
            return exp.evaluate(rootNode);
        }
        catch (TransformerException e)
        {
            throw new RuntimeException(e);
View Full Code Here

Examples of net.sf.saxon.xpath.XPathEvaluator

            net.sf.saxon.xpath.XPathFactoryImpl xpf = new net.sf.saxon.xpath.XPathFactoryImpl();

            OXPath20ExpressionBPEL20 oxpath20 = ((OXPath20ExpressionBPEL20) cexp);
            xpf.setXPathFunctionResolver(new JaxpFunctionResolver(ctx, oxpath20));
            xpf.setXPathVariableResolver(new JaxpVariableResolver(ctx, oxpath20));
            XPathEvaluator xpe = (XPathEvaluator) xpf.newXPath();
            xpe.setNamespaceContext(oxpath20.namespaceCtx);
            // Just checking that the expression is valid
            XPathExpression expr = xpe.compile(((OXPath10Expression)cexp).xpath);

            Object evalResult = expr.evaluate(ctx.getRootNode() == null ? DOMUtils.newDocument() : ctx.getRootNode(), type);
            if (evalResult != null && __log.isDebugEnabled()) {
                __log.debug("Expression " + cexp.toString() + " generated result " + evalResult
                        + " - type=" + evalResult.getClass().getName());
View Full Code Here

Examples of net.sf.saxon.xpath.XPathEvaluator

            net.sf.saxon.xpath.XPathFactoryImpl xpf = new net.sf.saxon.xpath.XPathFactoryImpl();

            OXPath20ExpressionBPEL20 oxpath20 = ((OXPath20ExpressionBPEL20) cexp);
            xpf.setXPathFunctionResolver(new JaxpFunctionResolver(ctx, oxpath20));
            xpf.setXPathVariableResolver(new JaxpVariableResolver(ctx, oxpath20));
            XPathEvaluator xpe = (XPathEvaluator) xpf.newXPath();
            xpe.setNamespaceContext(oxpath20.namespaceCtx);
            // Just checking that the expression is valid
            XPathExpression expr = xpe.compile(((OXPath10Expression)cexp).xpath);

            Object evalResult = expr.evaluate(ctx.getRootNode() == null ? DOMUtils.newDocument() : ctx.getRootNode(), type);
            if (evalResult != null && __log.isDebugEnabled()) {
                __log.debug("Expression " + cexp.toString() + " generated result " + evalResult
                        + " - type=" + evalResult.getClass().getName());
View Full Code Here

Examples of net.sf.saxon.xpath.XPathEvaluator

                    _compilerContext, out, source.getNamespaceContext(), _bpelNS);
            xpf.setXPathFunctionResolver(funcResolver);
            JaxpVariableResolver varResolver = new JaxpVariableResolver(_compilerContext, out);
            xpf.setXPathVariableResolver(varResolver);

            XPathEvaluator xpe = (XPathEvaluator) xpf.newXPath();
            xpe.setStaticContext(new SaxonContext(xpf.getConfiguration(), varResolver, funcResolver));
            xpe.setXPathFunctionResolver(funcResolver);
            xpe.setNamespaceContext(source.getNamespaceContext());
            xpe.compile(xpathStr);
        } catch (XPathExpressionException e) {
            __log.debug(e);
            __log.info("Couldn't validate properly expression " + xpathStr);
        } catch (WrappedResolverException wre) {
            if (wre._compilationMsg != null)
View Full Code Here

Examples of net.sf.saxon.xpath.XPathEvaluator

            net.sf.saxon.xpath.XPathFactoryImpl xpf = new net.sf.saxon.xpath.XPathFactoryImpl();

            OXPath20ExpressionBPEL20 oxpath20 = ((OXPath20ExpressionBPEL20) cexp);
            xpf.setXPathFunctionResolver(new JaxpFunctionResolver(ctx, oxpath20));
            xpf.setXPathVariableResolver(new JaxpVariableResolver(ctx, oxpath20));
            XPathEvaluator xpe = (XPathEvaluator) xpf.newXPath();
            xpe.setNamespaceContext(oxpath20.namespaceCtx);
            // Just checking that the expression is valid
            XPathExpression expr = xpe.compile(((OXPath10Expression)cexp).xpath);

            Object evalResult = expr.evaluate(ctx.getRootNode() == null ? DOMUtils.newDocument() : ctx.getRootNode(), type);
            if (evalResult != null && __log.isDebugEnabled()) {
                __log.debug("Expression " + cexp.toString() + " generated result " + evalResult
                        + " - type=" + evalResult.getClass().getName());
View Full Code Here

Examples of net.sf.saxon.xpath.XPathEvaluator

        // Give it a Saxon wrapper
        DocumentWrapper docw =
                new DocumentWrapper(doc, sourceID, config);

        // Retrieve all the ITEM elements
        XPathEvaluator xpath = new XPathEvaluator(config);
        XPathExpression exp = xpath.compile("//ITEM");
        List list = (List)exp.evaluate(docw, XPathConstants.NODESET);

        // For each of these, compute an additional attribute

        for (Iterator iter=list.iterator(); iter.hasNext();) {
View Full Code Here

Examples of net.sf.saxon.xpath.XPathEvaluator

            // the actual query and serialization.
            System.out.println("Loading classes, parsing " + filename + ", and setting up serializer");

            Object document = null;
            if (objectModel.equals(NamespaceConstant.OBJECT_MODEL_SAXON)) {
                document = new XPathEvaluator().setSource(new StreamSource(new File(filename)));

            } else if (objectModel.equals(XPathConstants.DOM_OBJECT_MODEL)) {
                InputSource in = new InputSource(new FileInputStream(filename));
                DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
                dfactory.setNamespaceAware(true);
View Full Code Here

Examples of net.sf.saxon.xpath.XPathEvaluator

            throws TransformerException {

        TransformerFactory tfactory = TransformerFactory.newInstance();
        Templates templates = tfactory.newTemplates(new StreamSource(xslID));
        Transformer transformer = templates.newTransformer();
        XPathEvaluator xpath = new XPathEvaluator(((TransformerFactoryImpl)tfactory).getConfiguration());
        DocumentInfo doc = (DocumentInfo)xpath.setSource(new SAXSource(new InputSource(sourceID)));
        transformer.transform(doc, new StreamResult(System.out));
    }
View Full Code Here

Examples of net.sf.saxon.xpath.XPathEvaluator

            DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
            System.err.println("Using DocumentBuilder " + docBuilder.getClass());

            Document doc = docBuilder.newDocument();

            XPathEvaluator xpath = new XPathEvaluator(((TransformerFactoryImpl)tfactory).getConfiguration());
            DocumentInfo saxonDoc = (DocumentInfo)xpath.setSource(new SAXSource(new InputSource(sourceID)));
            NodeInfo top = (NodeInfo)saxonDoc.iterateAxis(Axis.CHILD, NodeKindTest.ELEMENT).next();

            Node imported = doc.importNode(NodeOverNodeInfo.wrap(top), true);

            // Serialize the output so we can see the import actually worked
View Full Code Here

Examples of net.sf.saxon.xpath.XPathEvaluator

    public List selectNodes(Object node)
    {
        try
        {
            DOMSource rootNode =new DOMSource((Node) node);
            XPathEvaluator xpe = new XPathEvaluator();
            NodeInfo _theNode = xpe.setSource(rootNode);
            XBeansStandaloneContext sc = new XBeansStandaloneContext();
            sc.declareVariable("this",_theNode);
            xpe.setStaticContext(sc);

            // Declare ns bindings
            if (defaultNS != null)
                sc.setDefaultElementNamespace(defaultNS);

            for (int i = 0; i < namespaceMap.length; i++)
            {
                Map.Entry entry = (Map.Entry) namespaceMap[i];
                sc.declareNamespace((String) entry.getKey(),
                        (String) entry.getValue());
            }
              return xpe.evaluate(_queryExp);
        }
        catch (XPathException e)
        {
            throw new RuntimeException(e);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.