}
private void doTransform() {
try {
final Class clazz = ObjectFactory.findProviderClass(_className, true);
final AbstractTranslet translet = (AbstractTranslet)clazz.newInstance();
translet.postInitialization();
// Create a SAX parser and get the XMLReader object it uses
final SAXParserFactory factory = SAXParserFactory.newInstance();
try {
factory.setFeature(Constants.NAMESPACE_FEATURE,true);
}
catch (Exception e) {
factory.setNamespaceAware(true);
}
final SAXParser parser = factory.newSAXParser();
final XMLReader reader = parser.getXMLReader();
// Set the DOM's DOM builder as the XMLReader's SAX2 content handler
XSLTCDTMManager dtmManager =
XSLTCDTMManager.createNewDTMManagerInstance();
DTMWSFilter wsfilter;
if (translet != null && translet instanceof StripFilter) {
wsfilter = new DOMWSFilter(translet);
} else {
wsfilter = null;
}
final DOMEnhancedForDTM dom =
(DOMEnhancedForDTM)dtmManager.getDTM(
new SAXSource(reader, new InputSource(_fileName)),
false, wsfilter, true, false, translet.hasIdCall());
dom.setDocumentURI(_fileName);
translet.prepassDocument(dom);
// Pass global parameters
int n = _params.size();
for (int i = 0; i < n; i++) {
Parameter param = (Parameter) _params.elementAt(i);
translet.addParameter(param._name, param._value);
}
// Transform the document
TransletOutputHandlerFactory tohFactory =
TransletOutputHandlerFactory.newInstance();
tohFactory.setOutputType(TransletOutputHandlerFactory.STREAM);
tohFactory.setEncoding(translet._encoding);
tohFactory.setOutputMethod(translet._method);
if (_iterations == -1) {
translet.transform(dom, tohFactory.getSerializationHandler());
}
else if (_iterations > 0) {
long mm = System.currentTimeMillis();
for (int i = 0; i < _iterations; i++) {
translet.transform(dom,
tohFactory.getSerializationHandler());
}
mm = System.currentTimeMillis() - mm;
System.err.println("\n<!--");