Saxon Fails when XIncludes are Unresolved
Added by Anonymous over 15 years ago
Legacy ID: #7041504 Legacy Poster: Ryan Lubben (ryanlubben)
Hello, I am trying to process various XML files that include large numbers of XIncludes, but when a SAX parser error is throw because an XInclude file cannot be located Saxon fails rather than using the XInclude fallback that is present in the XML. Does anyone know if there is a setting that will allow Saxon to continue on with the transformation if recoverable errors are encountered by the parser? Just an FYI, Xalan runs the transformation when the same parser errors are encountered. System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl"); System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl"); SAXParserFactory saxFactory = SAXParserFactoryImpl.newInstance(); saxFactory.setFeature("http://apache.org/xml/features/xinclude", true); saxFactory.setXIncludeAware(true); saxFactory.setValidating(false); TransformerFactory tFactory = TransformerFactory.newInstance(); tFactory.setAttribute(net.sf.saxon.FeatureKeys.XINCLUDE,true); tFactory.setAttribute(net.sf.saxon.FeatureKeys.RECOVERY_POLICY,1); StreamSource stylesource = new StreamSource(xsltFile); Transformer transformer = tFactory.newTransformer(stylesource); StreamSource source = new StreamSource(xmlFile); StreamResult result = new StreamResult(new FileOutputStream(foFile)); transformer.transform(source, result); Warning: org.xml.sax.SAXParseException: Include operation failed, reverting to fallback. Resource error reading file as XML (href='file:///%5C%5Cpublishcms%5CShare%5Cpubtemp%5Cpublish44853tmp%5C00000 61792.xml'). Reason: \publishcms\Share\pubtemp\publish44853tmp\0000061792.xml (The system cannot find the file specified) Warning: org.xml.sax.SAXParseException: Include operation failed, reverting to fallback. Resource error reading file as XML (href='file:///%5C%5Cpublishcms%5CShare%5Cpubtemp%5Cpublish44853tmp%5C00000 62195.xml'). Reason: \publishcms\Share\pubtemp\publish44853tmp\0000062195.xml (The system cannot find the file specified) Warning: org.xml.sax.SAXParseException: Include operation failed, reverting to fallback. Resource error reading file as XML (href='file:///%5C%5Cpublishcms%5CShare%5Cpubtemp%5Cpublish44853tmp%5C00000 62193.xml'). Reason: \publishcms\Share\pubtemp\publish44853tmp\0000062193.xml (The system cannot find the file specified) Warning: org.xml.sax.SAXParseException: Include operation failed, reverting to fallback. Resource error reading file as XML Error The XML parser reported one or more errors Mar 31, 2009 8:35:21 AM com.kencook.arbortext.publish.RunXSLT generateFO SEVERE: null net.sf.saxon.trans.XPathException: The XML parser reported one or more errors at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:427) at net.sf.saxon.event.Sender.send(Sender.java:214) at net.sf.saxon.event.Sender.send(Sender.java:50) at net.sf.saxon.Controller.transform(Controller.java:1611) at com.kencook.arbortext.publish.RunXSLT.generateFO(RunXSLT.java:119) at com.kencook.arbortext.publish.RunXSLT.main(RunXSLT.java:41) Thanks in advance.
Replies (1)
RE: Saxon Fails when XIncludes are Unresolved - Added by Anonymous over 15 years ago
Legacy ID: #7063717 Legacy Poster: Ryan Lubben (ryanlubben)
I haven't seen any responses to my earlier posting, but I was just wondering if it would be possible to create my own ErrorListener that would prevent the Transformer from failing if the SAX parser ErrorHandler produces a warning?
Please register to reply