Jeff Holt
Jeff Holt

Reputation: 3190

Produce a document and return a scalar with one XsltTransformer object?

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

Answers (1)

Related Questions