net.sf.saxon.trans.XPathException with saxon8

Added by Anonymous over 12 years ago

Legacy ID: #11037934 Legacy Poster: jhodgski2 (jhodgski2)

Hiya, I'm having trouble with the following code. It runs fine on my local development machine (jdk1.6.0_23) but when I upload to the web (jdk1.6.0_26), I get this error: [quote]net.sf.saxon.trans.XPathException: no protocol: % at net.sf.saxon.event.Sender.sendSAXSource( at net.sf.saxon.event.Sender.send( at net.sf.saxon.event.Sender.send( at net.sf.saxon.Configuration.buildDocument( at org.w3c.mwi.mobileok.basic.XhtmlContent10.parseDOM( at org.w3c.mwi.mobileok.basic.XhtmlContent10.( at org.w3c.mwi.mobileok.basic.MobileOKDecodedContentFactory.decodeContent( at org.w3c.mwi.mobileok.basic.Resource.decode( at org.w3c.mwi.mobileok.basic.Preprocessor.processResource( at org.w3c.mwi.mobileok.basic.Preprocessor.access$000( at org.w3c.mwi.mobileok.basic.Preprocessor$ at java.util.concurrent.ThreadPoolExecutor$Worker.runTask( at java.util.concurrent.ThreadPoolExecutor$ at Caused by: no protocol: % at at at at at at at at$DTDDriver.dispatch( at$ at$ at at at at at at at at$JAXPSAXParser.parse( at net.sf.saxon.event.Sender.sendSAXSource( ... 13 more [/quote] [code]/** * Parses the given string as XML and returns the corresponding DOM * Document. * *

The function uses Saxon's extended DOM implementation to be * able to retrieve the line number where a given node appears in * the original string. In particular, the returned Document may * be casted to the * class.

* * @param body XML string to parse. * @return the DOM Document representation of the XML string, * null when the string is not valid XML. * @throws TestException an unexpected error occurred. */ private Document parseDOM(final String body) throws TestException { if (body == null) { return null; } try { // Use Saxon's ability to track line numbers // Note that we cannot use the DocumentBuilderImpl class provided // by Saxon because of an existing bug that prevents the use of // and entity resolver, see discussion and bug at: // // // Activate line numbering final Configuration config = new Configuration(); config.setLineNumbering(true); config.setStripsWhiteSpace(Whitespace.NONE); // Force local resolution of entities in the document final XMLReader xmlReader = config.getSourceParser(); final EntityResolver resolver = new ExtendedCatalogResolver(new XHTMLCatalogResolver()); xmlReader.setEntityResolver(resolver); // Create source final InputSource stringSource = new InputSource(new StringReader(body)); final SAXSource saxSource = new SAXSource(xmlReader, stringSource); // Parse document and wrap it into a DOM document final DocumentInfo docInfo = config.buildDocument(saxSource); // ** This line throws the exception ** final Document doc = (Document)DocumentOverNodeInfo.wrap(docInfo); return doc; } catch (XPathException e) { // A parse error occurred. The document cannot be parsed because // it's a not a valid XML file. if ((e.getCause() != null) && (e.getCause() instanceof IOException)) { throw new TestException(e.getCause()); } return null; } }[/code] Does anyone have any ideas what the problem could be? The strack trace suggests maybe there's an issue with the DTD, but how to solve?? Many thanks in advance, James

Replies (1)

RE: net.sf.saxon.trans.XPathException with saxon8 - Added by Anonymous over 12 years ago

Legacy ID: #11039482 Legacy Poster: Michael Kay (mhkay)

Firstly, "saxon8" refers to a sequence of 10 major releases (8.0, 8.1,,, 8.9) issued over a period of about four years between 2004 and 2008. The current release is 9.4. All I can really tell you from this information is that you have called Configuration.buildDocument() from your application supplying a Source object that wraps a URI which Java considers invalid. This URI is probably generated by your ExtendedCatalogResolver.


    Please register to reply