xinclude warnings treated as errors
Added by Anonymous about 15 years ago
Legacy ID: #7600131 Legacy Poster: David Lee (daldei)
In Saxon 9.1.0.6 xinclude warnings are treated as fatal errors. If I create a SAX parser using S9API like this : XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); Source ssource = new StreamSource(stdin.asInputStream(opts )); ssource.setSystemId( stdin.getSystemId()); AugmentedSource source = AugmentedSource.makeAugmentedSource(ssource); source.setXIncludeAware(true); source.setXMLReader(reader); XdmNode node = processor.newDocumentBuilder().build(source); Then feed it an XML document with this construct <xi:include href="that.xml" > <xi:fallback> <para><emphasis>FIXME: MISSING XINCLUDE CONTENT- that.xml</emphasis></para> </xi:fallback> </xi:include> I get this warning produced (OK) Warning: org.xml.sax.SAXParseException: Include operation failed, reverting to fallback. Resource error reading file as XML (href='that.xml'). Reason: C:\Work\DEI\xmlsh\trunk\doc\manual\that.xml (The system cannot find the file specified) But then I get this fatal error: net.sf.saxon.s9api.SaxonApiException: The XML parser reported one or more errors Tracing down this comes from DocumentBuilder.build() try { NodeInfo doc = config.buildDocument(as); return new XdmNode(doc); } catch (XPathException e) { throw new SaxonApiException(e); } The XPathException comes from: Sender.sendSAXSource if (errorHandler.getErrorCount() > 0) { throw new XPathException("The XML parser reported one or more errors"); } The getError count comes from a warning Which comes from the StandardErrorHandler public void warning (SAXParseException e) { if (errorListener != null) { try { // DTD validation errors are reported as warnings, but we treat them as fatal errorCount++; errorListener.warning(new TransformerException(e)); } catch (Exception err) {} } } ----------- SO ... how to avoid this ? The problem seems to be that if there is an error listener at all, then warnings are treated as errors. Supplying a custom error listener wouldnt do it. since sendSAXSource creates its own error Handler explicitly StandardErrorHandler errorHandler = new StandardErrorHandler(pipe.getErrorListener()); I think I'm SOL ... (unless I use a null error listener ... but then real errors would get lost ?) Suggestions welcome.
Replies (1)
RE: xinclude warnings treated as errors - Added by Anonymous about 15 years ago
Legacy ID: #7600967 Legacy Poster: Michael Kay (mhkay)
I may not get a chance to look at this properly until I'm back from vacation. I think 9.2 changes so that an ErrorHandler included as part of the XMLReader supplied in a SAXSource is respected - Saxon doesn't change it.
Please register to reply