Examples of XPathEvaluator


Examples of net.sf.saxon.sxpath.XPathEvaluator

                // parameters starting with "+" are taken as input documents
                Object sources = Transform.loadDocuments(argvalue, useURLs, config, true);
                dynamicEnv.setParameter(argname.substring(1), sources);
            } else if (argname.startsWith("?")) {
                // parameters starting with "?" are taken as XPath expressions
                XPathEvaluator xpe = new XPathEvaluator(getConfiguration());
                XPathExpression expr = xpe.createExpression(argvalue);
                XPathDynamicContext context = expr.createDynamicContext(null);
                ValueRepresentation val = SequenceExtent.makeSequenceExtent(expr.iterate(context));
                dynamicEnv.setParameter(argname.substring(1), val);               
            } else {
                dynamicEnv.setParameter(argname, new UntypedAtomicValue(argvalue));
View Full Code Here

Examples of net.sf.saxon.sxpath.XPathEvaluator

                // parameters starting with "+" are taken as input documents
                Object sources = loadDocuments(argvalue, useURLs, config, true);
                controller.setParameter(argname.substring(1), sources);
            } else if (argname.startsWith("?")) {
                // parameters starting with "?" are taken as XPath expressions
                XPathEvaluator xpe = new XPathEvaluator(controller.getConfiguration());
                XPathExpression expr = xpe.createExpression(argvalue);
                XPathDynamicContext context = expr.createDynamicContext(null);
                ValueRepresentation val = SequenceExtent.makeSequenceExtent(expr.iterate(context));
                controller.setParameter(argname.substring(1), val);
            } else {
                controller.setParameter(argname, new UntypedAtomicValue(argvalue));
View Full Code Here

Examples of net.sf.saxon.sxpath.XPathEvaluator

                XPathVariable var2 = ic.declareVariable(var.getVariableQName());
                var2.setRequiredType(var.getRequiredType());
            }
        }
        try {
            XPathEvaluator eval = new XPathEvaluator(processor.getUnderlyingConfiguration());
            eval.setStaticContext(ic);
            XPathExpression cexp = eval.createExpression(source);
            return new XPathExecutable(cexp, processor, ic);
        } catch (XPathException e) {
            throw new SaxonApiException(e);
        }
    }
View Full Code Here

Examples of net.sf.saxon.sxpath.XPathEvaluator

     * @since 9.1
     */

    public XPathExecutable compilePattern(String source) throws SaxonApiException {
        try {
            XPathEvaluator eval = new XPathEvaluator(processor.getUnderlyingConfiguration());
            eval.setStaticContext(env);
            XPathExpression cexp = eval.createPattern(source);
            return new XPathExecutable(cexp, processor, env);
        } catch (XPathException e) {
            throw new SaxonApiException(e);
        }
    }
View Full Code Here

Examples of net.sf.saxon.sxpath.XPathEvaluator

     * @throws SaxonApiException if any static error is detected while analyzing the expression
     */

    public XPathExecutable compile(String source) throws SaxonApiException {
        try {
            XPathEvaluator eval = new XPathEvaluator(config);
            eval.setStaticContext(env);
            XPathExpression cexp = eval.createExpression(source);
            return new XPathExecutable(cexp, config, env, declaredVariables);
        } catch (XPathException e) {
            throw new SaxonApiException(e);
        }
    }
View Full Code Here

Examples of net.sf.saxon.sxpath.XPathEvaluator

    public List selectNodes(Object node)
    {
        try
        {
            DOMSource rootNode = new DOMSource((Node) node);
            XPathEvaluator xpe = new XPathEvaluator();
            Configuration c = new Configuration();
            c.setTreeModel(net.sf.saxon.event.Builder.STANDARD_TREE);
            XBeansIndependentContext sc = new XBeansIndependentContext(c);

            // 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(_contextVar);
            thisVar.setValue(needsDomSourceWrapping ? rootNode : node);

            XPathExpression exp = xpe.createExpression(_queryExpr);

            // After 8.3(?) Saxon nodes no longer implement Dom.
            // The client needs saxon8-dom.jar, and the code needs
            // this NodeOverNodeInfo Dom wrapper doohickey
            List saxonNodes = exp.evaluate(rootNode);
View Full Code Here

Examples of net.sf.saxon.sxpath.XPathEvaluator

        if (argument.length > 2) {
            Value errorObject = ((Value)SequenceExtent.makeSequenceExtent(argument[2].iterate(context))).reduce();
            if (errorObject instanceof SingletonNode) {
                NodeInfo root = ((SingletonNode)errorObject).getNode();
                if (root.getNodeKind() == Type.DOCUMENT) {
                    XPathEvaluator xpath = new XPathEvaluator();
                    XPathExpression exp = xpath.createExpression("/error/@module");
                    NodeInfo moduleAtt = (NodeInfo)exp.evaluateSingle(root);
                    String module = (moduleAtt == null ? null : moduleAtt.getStringValue());
                    exp = xpath.createExpression("/error/@line");
                    NodeInfo lineAtt = (NodeInfo)exp.evaluateSingle(root);
                    int line = (lineAtt == null ? -1 : Integer.parseInt(lineAtt.getStringValue()));
                    exp = xpath.createExpression("/error/@column");
                    NodeInfo columnAtt = (NodeInfo)exp.evaluateSingle(root);
                    int column = (columnAtt == null ? -1 : Integer.parseInt(columnAtt.getStringValue()));
                    ExpressionLocation locator = new ExpressionLocation();
                    locator.setSystemId(module);
                    locator.setLineNumber(line);
View Full Code Here

Examples of net.sf.saxon.sxpath.XPathEvaluator

    public static void main(String[] args) throws Exception {
        Configuration config = new Configuration();
        Expression exp;
        if (args[0].equals("xpath")) {
            XPathEvaluator xpath = new XPathEvaluator(config);
            XPathExpression xpexp = xpath.createExpression(args[1]);
            exp = xpexp.getInternalExpression();
        } else if (args[0].equals("xquery")) {
            StaticQueryContext sqc = new StaticQueryContext(config);
            sqc.setBaseURI(new File(args[1]).toURI().toString());
            XQueryExpression xqe = sqc.compileQuery(new FileReader(args[1]));
View Full Code Here

Examples of net.sf.saxon.sxpath.XPathEvaluator

    public int count(XdmNode doc, RuntimeValue match, boolean deep) {
        count = 0;

        try {
            XPathEvaluator xeval = new XPathEvaluator(saxonConfig);
            NamespaceResolver resolver = new MatchingNamespaceResolver(match.getNamespaceBindings());
            xeval.setNamespaceResolver(resolver);

            matcher = xeval.createPattern(match.getString());

            traverse(doc, deep);
        } catch (XProcException e) {
            throw e;
        } catch (Exception e) {
View Full Code Here

Examples of net.sf.saxon.sxpath.XPathEvaluator

    public void match(XdmNode doc, RuntimeValue match) {
        XdmNode node = match.getNode();
        String expr = match.getString();

        try {
            XPathEvaluator xeval = new XPathEvaluator(saxonConfig);
            NamespaceResolver resolver = new MatchingNamespaceResolver(match.getNamespaceBindings());
            xeval.setNamespaceResolver(resolver);

            matcher = xeval.createPattern(match.getString());

            destination = new XdmDestination();
            receiver = destination.getReceiver(saxonConfig);
            receiver = new NamespaceReducer(receiver);
            PipelineConfiguration pipe = controller.makePipelineConfiguration();
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.