I am using Transformer to perform XSL transformation from XML to XHTML:
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
// ...
Transformer transformer = TransformerFactory.newInstance()
.newTransformer(/* xsl */);
transformer.transform(new StreamSource(xml), new StreamResult(xhtml));
In this code I should explicitly provide XSL file. In my situation I don’t know which file should be used. Instead, I want the transformer to get this information from <?xsl-stylesheet?> processing instruction in the original XML. Is it possible to do with JDK6 and Saxon?
Xalan can do that, check this.
Probably Saxon as well as it is method of
javax.xml.transform.TransformerFactory:getAssociatedStylesheet