Package net.sf.saxon.xpath

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


            return prefixes.iterator();
        }
    }

    private void init() throws XPathExpressionException {
        XPathEvaluator xPathEvaluator = new XPathEvaluator();
        xPathEvaluator.setNamespaceContext(XPath2NamespaceContext.INSTANCE);
        xPathExpression = xPathEvaluator.compile(xpathStr);
    }
View Full Code Here

        // 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

            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

            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

    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

            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

            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

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

        // Retrieve all the ITEM elements
        XPathEvaluator xpath = new XPathEvaluator(docw);
        Iterator iter = xpath.evaluate("//ITEM").iterator();

        // For each of these, compute an additional attribute

        while (iter.hasNext()) {
            //NodeWrapper node = (NodeWrapper)enum.next();
View Full Code Here

            // 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

TOP

Related Classes of net.sf.saxon.xpath.XPathEvaluator

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.