Project

Profile

Help

XPathException: Failed to load document

Added by Anonymous over 12 years ago

Legacy ID: #10578809 Legacy Poster: Dayana (leyre)

Hi! Well, Im using JDOM, SAXON and XERCES to transform xml docs, using stylesheets. The problem is, that during this transformation, I receive this error message: [quote]et.sf.saxon.trans.XPathException: Failed to load document C:\UMLR\tmp\3639122.xml.mod[/quote] My transforming code, is: [code]private Document transformar(Document docMOD, String xslt, Map<String, String> parametros) throws TransformerException { //Generamos la guia //System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl"); TransformerFactory guia = TransformerFactory.newInstance(); Configuration config = ((TransformerFactoryImpl)guia).getConfiguration(); DocumentWrapper wrapper = new DocumentWrapper(docMOD, docMOD.getBaseURI(), config); System.out.println(docMOD.getBaseURI()); //Preparamos los traductores Templates plantilla = guia.newTemplates(new StreamSource(xslt)); Transformer conversor = plantilla.newTransformer(); for(String clave : parametros.keySet()){ conversor.setParameter(clave, parametros.get(clave)); } //Transformamos JDOMResult resultado = new JDOMResult(); conversor.transform(wrapper, resultado); return resultado.getDocument(); }[/code] The line where the error pops up, is: conversor.transform(wrapper, resultado); Sorry for the newbie question, but I don't know what more to try. Thanks, hope to read some answers.


Replies (7)

Please register to reply

RE: XPathException: Failed to load document - Added by Anonymous over 12 years ago

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

It's not clear from the information you have supplied, but I would think a likely explanation is that you have used a Windows filesname (such as C:\UMLR\tmp\3639122.xml.mod) in a context where a URI is expected. Some APIs tolerate this; Saxon typically doesn't. It should be written file:///c:/UMLR/tmp/3639122.xml.mod. It's also possible, of course (from the information given) that the file really doesn't exist.

RE: XPathException: Failed to load document - Added by Anonymous over 12 years ago

Legacy ID: #10579507 Legacy Poster: Dayana (leyre)

Hi! Thanks for your answer. The System.out.println() prints this URI: file:///C:/UMLR/tmp/9129250.xml.mod Also, the file does exists, because I create it before in the program, and already checked that it is there when called. The other method where I read the doc, it is: [code]String nombreArchivo = directorio + nro + ".xml"; SAXBuilder constructor = new SAXBuilder("org.apache.xerces.parsers.SAXParser", true); constructor.setFeature("http://apache.org/xml/features/validation/schema", true); Document docMOD = constructor.build(nombreArchivo + ".mod"); [/code]

RE: XPathException: Failed to load document - Added by Anonymous over 12 years ago

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

I suspect that there are further diagnostics being written to System.err which perhaps you are not displaying. If this is the case, please either redirect System.err to some log file, or configure Saxon to write to a location other than System.err, perhaps by supplying your own JAXP ErrorListener. (or you could supply an instance of the Saxon StandardErrorListener in which you have called setErrorOutput() to direct the error messages perhaps to a file.

RE: XPathException: Failed to load document - Added by Anonymous over 12 years ago

Legacy ID: #10581768 Legacy Poster: Dayana (leyre)

Hi again! Ok, I got all the error message, and it told, in an upper part, that the problem was in a line in the xslt file (still don't get why It result in an XPathException). Anyways, I got to track the problem. Thank you so much, this libs are so usefull.

RE: XPathException: Failed to load document - Added by Anonymous over 12 years ago

Legacy ID: #10597309 Legacy Poster: Dayana (leyre)

Ok, the full system error message, is: [quote]Recoverable error on line 77 of PrimerMapeo.xslt: FODC0002: Exception thrown by URIResolver: Invalid relative URI {C:\UMLR\tmp\1020457.xml.mod}: Illegal character in opaque part at index 2: C:\UMLR\tmp\1020457.xml.mod Error on line 77 of PrimerMapeo.xslt: FODC0002: Failed to load document C:\UMLR\tmp\1020457.xml.mod ; SystemID: file:///D:/Mis%20documentos/FRSF/Beca%20I+D/2011/workspace/umlrelacional/files/PrimerMapeo.xslt; Line#: 77; Column#: -1 net.sf.saxon.trans.XPathException: Failed to load document C:\UMLR\tmp\1020457.xml.mod at net.sf.saxon.expr.Expression.dynamicError(Expression.java:995) at net.sf.saxon.functions.Doc.doc(Doc.java:158) at net.sf.saxon.functions.Doc.evaluateItem(Doc.java:129) at net.sf.saxon.expr.Expression.iterate(Expression.java:393) at net.sf.saxon.expr.PathExpression.iterate(PathExpression.java:619) at net.sf.saxon.expr.PathExpression.iterate(PathExpression.java:619) at net.sf.saxon.expr.LazyExpression.iterate(LazyExpression.java:106) at net.sf.saxon.value.MemoClosure.iterate(MemoClosure.java:98) at net.sf.saxon.value.Value.getIterator(Value.java:119) at net.sf.saxon.expr.VariableReference.iterate(VariableReference.java:407) at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:344) at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:123) at net.sf.saxon.expr.LetExpression.process(LetExpression.java:409) at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:318) at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:269) at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:123) at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:318) at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:269) at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:569) at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:123) at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:318) at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:269) at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:569) at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:123) at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:318) at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:269) at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:123) at net.sf.saxon.expr.LetExpression.process(LetExpression.java:409) at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:387) at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:569) at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:123) at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:318) at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:269) at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:123) at net.sf.saxon.expr.LetExpression.process(LetExpression.java:409) at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:387) at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:569) at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:123) at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:387) at net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:567) at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:569) at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:123) at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:318) at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:269) at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:208) at net.sf.saxon.expr.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:368) at net.sf.saxon.Controller.transformDocument(Controller.java:1887) at net.sf.saxon.Controller.transform(Controller.java:1737)[/quote] I got this error message AGAIN, when I did resolve the NullPointer one. What I am missing?

RE: XPathException: Failed to load document - Added by Anonymous over 12 years ago

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

Failed to load document C:\UMLR\tmp\1020457.xml.mod The doc() function expects a URI, not a Windows filename. The URI corresponding to this filename is file:///c:/UMLR/tmp/1020457.xml.mod

RE: XPathException: Failed to load document - Added by Anonymous over 12 years ago

Legacy ID: #10597928 Legacy Poster: Dayana (leyre)

I see, I was looking for the issue in the other function. Tried, and solved. Kinds regards.

    (1-7/7)

    Please register to reply