Project

Profile

Help

net.sf.saxon.trans.XPathException with saxon8

Added by Anonymous almost 13 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: java.net.MalformedURLException: no protocol: % at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:424) at net.sf.saxon.event.Sender.send(Sender.java:193) at net.sf.saxon.event.Sender.send(Sender.java:50) at net.sf.saxon.Configuration.buildDocument(Configuration.java:2973) at org.w3c.mwi.mobileok.basic.XhtmlContent10.parseDOM(XhtmlContent10.java:334) at org.w3c.mwi.mobileok.basic.XhtmlContent10.(XhtmlContent10.java:226) at org.w3c.mwi.mobileok.basic.MobileOKDecodedContentFactory.decodeContent(MobileOKDecodedContentFactory.java:64) at org.w3c.mwi.mobileok.basic.Resource.decode(Resource.java:243) at org.w3c.mwi.mobileok.basic.Preprocessor.processResource(Preprocessor.java:484) at org.w3c.mwi.mobileok.basic.Preprocessor.access$000(Preprocessor.java:33) at org.w3c.mwi.mobileok.basic.Preprocessor$2.run(Preprocessor.java:529) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) Caused by: java.net.MalformedURLException: no protocol: % at java.net.URL.(URL.java:567) at java.net.URL.(URL.java:464) at java.net.URL.(URL.java:413) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:650) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1315) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:1282) at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:283) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1194) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1090) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1003) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522) at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:404) ... 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 net.sf.saxon.om.DocumentOverNodeInfo * 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: // https://sourceforge.net/mailarchive/message.php?msg_name=209D7731E68043DC8F6695AF79CD6397@Sealion // https://sourceforge.net/tracker/?func=detail&aid=2995298&group_id=29872&atid=397617 // 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 almost 13 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.

    (1-1/1)

    Please register to reply