The Source
and Result
classes within TrAX are
used to handle input and output documents. These classes can be extended to
encapsulate additional input types. XSLTC's TrAX implementation contains an
extension to the Source
class:
| | |
|
org.apache.xalan.xsltc.trax.XSLTCSource | |
| | |
This extension class can be used to build XSLTC's internal
DOM and cache it for later usage. The following sample shows how to
use it with a Transformer:
| | |
|
public void run(String xmlfile, String xslfile) {
// Create an XSLTCSource for the input XML document
XSLTCSource source = new XSLTCSource(xmlfile);
// Build a StreamSource for the stylesheet
StreamSource stylesheet = new StreamSource(xslfile);
// Create a Transformer instance and process the input
Transformer transformer = factory.newTransformer(stylesheet);
transformer.transform(source, new StreamResult(System.out));
:
:
} | |
| | |
If you do chose to implement a DOM cache, you should have your cache
implement the javax.xml.transform.URIResolver
interface so
that documents loaded by the document()
function are also read
from your cache.