Examples of XPathEvaluator


Examples of net.sf.saxon.xpath.XPathEvaluator

        // Create an XPathEvaluator and set the source document

        InputSource is = new InputSource(new File(filename).toURL().toString());
        SAXSource ss = new SAXSource(is);
        XPathEvaluator xpe = new XPathEvaluator(ss);

        // Declare a variable for use in XPath expressions

        StandaloneContext sc = (StandaloneContext)xpe.getStaticContext();
        Variable wordVar = sc.declareVariable("word", "");

        // Compile the XPath expressions used by the application

        XPathExpression findLine =
            xpe.createExpression("//LINE[contains(., $word)]");
        XPathExpression findLocation =
            xpe.createExpression("concat(ancestor::ACT/TITLE, ' ', ancestor::SCENE/TITLE)");
        XPathExpression findSpeaker =
            xpe.createExpression("string(ancestor::SPEECH/SPEAKER[1])");

        // Create a reader for reading input from the console

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
View Full Code Here

Examples of net.sf.saxon.xpath.XPathEvaluator

            throws TransformerException, TransformerConfigurationException {

        TransformerFactory tfactory = TransformerFactory.newInstance();
        Templates templates = tfactory.newTemplates(new StreamSource(xslID));
        Transformer transformer = templates.newTransformer();
        XPathEvaluator xpath = new XPathEvaluator();
        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

            return prefixes.iterator();
        }
    }

    private void init() throws XPathExpressionException {
        XPathEvaluator xPathEvaluator = new XPathEvaluator();
        xPathEvaluator.setNamespaceContext(XPath2NamespaceContext.INSTANCE);
        xPathExpression = xPathEvaluator.compile(xpathStr);
    }
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

            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 static NodeInfo exampleSaxonToSaxon(String sourceID, String xslID)
            throws TransformerException, TransformerConfigurationException,
            IOException, MalformedURLException {

        TransformerFactory tfactory = TransformerFactory.newInstance();
        NodeInfo doc = new XPathEvaluator().setSource(new StreamSource(new File(xslID).toURL().toString()));
        Templates templates = tfactory.newTemplates(doc);
        System.err.println("Stylesheet built OK");

        Transformer transformer = templates.newTransformer();
        doc = new XPathEvaluator().setSource(new StreamSource(new File(sourceID).toURL().toString()));
        System.err.println("Source document built OK");

        TinyBuilder builder = new TinyBuilder();
        transformer.transform(doc, builder);
        System.err.println("Transformation done OK");
View Full Code Here

Examples of net.sf.saxon.xpath.XPathEvaluator

            throws TransformerException, TransformerConfigurationException,
                   SAXException, IOException, ParserConfigurationException,
                   MalformedURLException {

        TransformerFactory tfactory = TransformerFactory.newInstance();
        NodeInfo doc = new XPathEvaluator().setSource(new StreamSource(new File(xslID).toURL().toString()));
        Templates templates = tfactory.newTemplates(doc);
        System.err.println("Stylesheet built OK");

        Transformer transformer = templates.newTransformer();
        XPathEvaluator xpath = new XPathEvaluator();
        xpath.setSource(new StreamSource(new File(sourceID).toURL().toString()));
        NodeInfo node = (NodeInfo)xpath.evaluateSingle("/*/*[1]");

        System.err.println("Source document built OK");

        TinyBuilder builder = new TinyBuilder();
        transformer.transform(node, builder);
View Full Code Here

Examples of net.sf.saxon.xpath.XPathEvaluator

            throws TransformerException, TransformerConfigurationException {

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

Examples of org.dbwiki.data.query.xpath.XPathEvaluator

 
  public boolean eval(DatabaseElementNode node) {

    EvaluationResult result = new EvaluationResult();
   
    new XPathEvaluator(result).eval((DatabaseGroupNode)node, _targetPath, this);
   
    if (_quantifier == Quantifier.FOR_ALL) {
      if (_negated) {
        return !result.hasAllPositiveEvaluations();
      } else {
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.