[jdom-interest] Error building a document with xinclude and xpointer

JOSE L MARTINEZ-AVIAL jlmagc at gmail.com
Thu Aug 21 16:45:22 PDT 2014


Hello all,
  I'm using Jdom 2.0.5 and opening a document one.xml which includes
another file two.xml through xinclude. I'm calling the builder as follows:

        SAXBuilder builder = new SAXBuilder();
        builder.setJDOMFactory(new LocatedJDOMFactory());
        builder.setFeature("http://apache.org/xml/features/xinclude", true);
        Document doc = builder.build(new File("c:\\temp\\one.xml"));
        XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());
        System.out.println("salida es "+out.outputString(doc));

the file one.xml is as follows:

    <?xml version="1.0" encoding="UTF-8" ?>
    <eco xmlns:xi="http://www.w3.org/2001/XInclude">
        <tmp-path>/opt/eco/ecoprd/tmp</tmp-path>
        <!--
        <xi:include href="two.xml" parse="xml"/>
        -->
        <xi:include href="two.xml" parse="xml" xpointer="web-servers"/>
    </eco>

and two.xml is as follows:

    <?xml version="1.0" encoding="UTF-8" ?>
    <eco>
        <web-servers xml:id="web-servers">
            <valuations>
                <url-base>http://naboo:8080</url-base>
                <context>/Statements</context>
                <path>/services/ValuationsXMLGenerator</path>
            </valuations>
        </web-servers>
    </eco>

the inclusion of the file without the xpointer works fine. But if I use
xpointer, I get an error as follows:

    org.jdom2.input.JDOMParseException: Error on line 7 of document
file:/c:/temp/one.xml: An 'include' failed, and no 'fallback' element was
found.
        at
org.jdom2.input.sax.SAXBuilderEngine.build(SAXBuilderEngine.java:228)
        at
org.jdom2.input.sax.SAXBuilderEngine.build(SAXBuilderEngine.java:277)
        at
org.jdom2.input.sax.SAXBuilderEngine.build(SAXBuilderEngine.java:264)
        at org.jdom2.input.SAXBuilder.build(SAXBuilder.java:1116)
        at test.XMLTest.main(XMLTest.java:17)
    Caused by: org.xml.sax.SAXParseException; systemId:
file:/c:/temp/one.xml; lineNumber: 7; columnNumber: 65; An 'include'
failed, and no 'fallback' element was found.
        at
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown
Source)
        at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown
Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
Source)
        at org.apache.xerces.xinclude.XIncludeHandler.reportError(Unknown
Source)
        at
org.apache.xerces.xinclude.XIncludeHandler.reportFatalError(Unknown Source)
        at
org.apache.xerces.xinclude.XIncludeHandler.reportFatalError(Unknown Source)
        at
org.apache.xerces.xinclude.XIncludeHandler.reportFatalError(Unknown Source)
        at org.apache.xerces.xinclude.XIncludeHandler.emptyElement(Unknown
Source)
        at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
Source)
        at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
        at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown
Source)
        at
org.jdom2.input.sax.SAXBuilderEngine.build(SAXBuilderEngine.java:217)
        ... 4 more

What I'm missing? supposedly the xpointer="web-servers" should get the
element web-serves with xml:id="web-servers", but it is not. Any
suggestions?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.jdom.org/pipermail/jdom-interest/attachments/20140821/f00e2f8a/attachment.html>


More information about the jdom-interest mailing list