for (int i = 0; i < 1; i++) // Loop for diagnosing bugs with inconsistent behavior
{
// System.out.println("Testing the TransformerHandler...");
// ===============
XMLReader reader = null;
// Use JAXP1.1 ( if possible )
try
{
javax.xml.parsers.SAXParserFactory factory =
javax.xml.parsers.SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
javax.xml.parsers.SAXParser jaxpParser =
factory.newSAXParser();
reader = jaxpParser.getXMLReader();
}
catch (javax.xml.parsers.ParserConfigurationException ex)
{
throw new org.xml.sax.SAXException(ex);
}
catch (javax.xml.parsers.FactoryConfigurationError ex1)
{
throw new org.xml.sax.SAXException(ex1.toString());
}
catch (NoSuchMethodError ex2){}
catch (AbstractMethodError ame){}
if (null == reader)
{
reader = XMLReaderFactory.createXMLReader();
}
if (!useXSLTC)
stf.setAttribute(org.apache.xalan.processor.TransformerFactoryImpl.FEATURE_INCREMENTAL,
Boolean.TRUE);
TransformerHandler th = stf.newTransformerHandler(stylesheet);
reader.setContentHandler(th);
reader.setDTDHandler(th);
if(th instanceof org.xml.sax.ErrorHandler)
reader.setErrorHandler((org.xml.sax.ErrorHandler)th);
try
{
reader.setProperty(
"http://xml.org/sax/properties/lexical-handler", th);
}
catch (org.xml.sax.SAXNotRecognizedException e){}
catch (org.xml.sax.SAXNotSupportedException e){}
try
{
reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
true);
} catch (org.xml.sax.SAXException se) {}
try
{
reader.setFeature("http://apache.org/xml/features/validation/dynamic",
true);
} catch (org.xml.sax.SAXException se) {}
th.setResult(strResult);
reader.parse(new InputSource(inFileName));
}
}
else
{
if (entityResolver != null)
{
XMLReader reader = null;
// Use JAXP1.1 ( if possible )
try
{
javax.xml.parsers.SAXParserFactory factory =
javax.xml.parsers.SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
javax.xml.parsers.SAXParser jaxpParser =
factory.newSAXParser();
reader = jaxpParser.getXMLReader();
}
catch (javax.xml.parsers.ParserConfigurationException ex)
{
throw new org.xml.sax.SAXException(ex);
}
catch (javax.xml.parsers.FactoryConfigurationError ex1)
{
throw new org.xml.sax.SAXException(ex1.toString());
}
catch (NoSuchMethodError ex2){}
catch (AbstractMethodError ame){}
if (null == reader)
{
reader = XMLReaderFactory.createXMLReader();
}
reader.setEntityResolver(entityResolver);
if (contentHandler != null)
{
SAXResult result = new SAXResult(contentHandler);