Reputation: 3190
I have a method that transforms an XML document into an HTML document.
Processor saxProc = ...
XsltTransformer trans = ...
XdmNode source = saxProc.newDocumentBuilder().build(new StreamSource(xmlFile));
trans.setInitialContextNode(source);
Serializer out = saxProc.newSerializer(htmlFile);
out.setOutputProperty(Serializer.Property.METHOD, "html");
trans.setDestination(out);
trans.transform();
I now need this method to make available a new class member whose scalar value is the result of an XPATH expression executed upon the same source XML file.
Perhaps the best thing to do is create an additional XsltTransformer to return the scalar value?
But after reading the doc for setDestination
and Destination, I'm wondering, should I investigate the possibility of defining an additional destination that can receive the scalar value during the existing transform?
Upvotes: 0
Views: 41
Reputation: 167696
If you want to use XPath against your input document then use http://saxonica.com/html/documentation/javadoc/net/sf/saxon/s9api/XPathSelector.html by calling http://saxonica.com/html/documentation/javadoc/net/sf/saxon/s9api/Processor.html#newXPathCompiler--, http://saxonica.com/html/documentation/javadoc/net/sf/saxon/s9api/XPathCompiler.html#compile-java.lang.String-, http://saxonica.com/html/documentation/javadoc/net/sf/saxon/s9api/XPathExecutable.html#load-- on your Processor.
Upvotes: 1