Hi all,
I´m trying to load a xml doc in Saxon´s cache in order to access it inside my xslt with a document() function.
This is my Java code:
Code:
Source xsltTarget = new StreamSource(xsltInput);
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(xsltTarget);
Controller controller = (net.sf.saxon.Controller) transformer;
Configuration configuration = controller.getConfiguration();
configuration.setConfigurationProperty(FeatureKeys.PRE_EVALUATE_DOC_FUNCTION, Boolean.TRUE);
Source source = r.resolve("C:/xml/mydocument.xml", "C:/xml");
DocumentInfo newdoc = configuration.buildDocument(source);
configuration.getGlobalDocumentPool().add(newdoc, "C:/xml/mydocument.xml");
streamSource = new StreamSource(new StringReader(xml));
resultTarget = new StreamResult(new StringWriter());
transformer.transform(streamSource, resultTarget);
Then, in my xslt, I want to define my document variable:
<xsl:variable name="documentPath" select="'C:/xml/mydocument.xml'"/>
<xsl:variable name="doc" select="document($documentPath)"/>
I don´t know whether I´m setting the URI and baseURI parameters correctly in my Java code, and also don´t know how to reference it inside my xslt (does it work just with document('C:/xml/mydocument.xml')?), but I think Saxon is not pre-caching anything.
I´d appreciate any help. I can´t find a complete example in the Internet.
Regards