#938 Transformation Fails when XIncludes are Unresolved

v9.1
closed
Michael Kay
5
2012-10-08
2009-03-31
Ryan Lubben
No

Hello,

I am trying to process various XML files that includes 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.

        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%5C0000061792.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%5C0000062195.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%5C0000062193.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
(href='file:///%5C%5Cpublishcms%5CShare%5Cpubtemp%5Cpublish44853tmp%5C0000062469.xml').
Reason: \publishcms\Share\pubtemp\publish44853tmp\0000062469.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%5C0000062526.xml').
Reason: \publishcms\Share\pubtemp\publish44853tmp\0000062526.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%5C0000062525.xml').
Reason: \publishcms\Share\pubtemp\publish44853tmp\0000062525.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%5C0000062558.xml').
Reason: \publishcms\Share\pubtemp\publish44853tmp\0000062558.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%5C0000062623.xml').
Reason: \publishcms\Share\pubtemp\publish44853tmp\0000062623.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%5C0000062692.xml').
Reason: \publishcms\Share\pubtemp\publish44853tmp\0000062692.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%5C0000062923.xml').
Reason: \publishcms\Share\pubtemp\publish44853tmp\0000062923.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%5C0000062919.xml').
Reason: \publishcms\Share\pubtemp\publish44853tmp\0000062919.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%5C0000063045.xml').
Reason: \publishcms\Share\pubtemp\publish44853tmp\0000063045.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%5C0000063043.xml').
Reason: \publishcms\Share\pubtemp\publish44853tmp\0000063043.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%5C0000063441.xml').
Reason: \publishcms\Share\pubtemp\publish44853tmp\0000063441.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%5C0000072599.xml').
Reason: \publishcms\Share\pubtemp\publish44853tmp\0000072599.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%5C0000078706.xml').
Reason: \publishcms\Share\pubtemp\publish44853tmp\0000078706.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%5C0000062544.xml').
Reason: \publishcms\Share\pubtemp\publish44853tmp\0000062544.xml (The system cannot find
the file specified)
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)

Discussion

  • Michael Kay
    Michael Kay
    2009-03-31

    You failed to notice the request on the "add entry" form asking you not to use this tracker to report suspected problems - I prefer to use it for confirmed Saxon bugs only. Requests for help should be raised on the saxon-help list or forum.

    If this is a bug, it's pretty clear that it's an XML parser bug and not a Saxon bug. The XInclude processing is not done by Saxon, it is done by the XML parser. Saxon merely passes the request to the parser and reports the error if it fails. I am therefore closing the bug as invalid. If you want to discuss it further, please do so on the help list or forum.