Error building a document with xinclude and xpointer

JOSE L MARTINEZ-AVIAL <[email protected]> Thu, 21 Aug 2014 19:45:22 -0400
Newsgroups gmane.comp.java.jdom.general
Message-ID <CAHB4ARs3ftQaVZbaZRe_68Qu4d1F=osrZDm3T=doCT9JT75GXw@mail.gmail.com>
--===============0743606783==
Content-Type: multipart/alternative; boundary=001a11c26774633da205012c5014

--001a11c26774633da205012c5014
Content-Type: text/plain; charset=UTF-8

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?

--001a11c26774633da205012c5014
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hello all,<br>=C2=A0 I&#39;m using Jdom 2.0.5 and opening =
a document one.xml which includes another file two.xml through xinclude. I&=
#39;m calling the builder as follows:<br><br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 SAXBuilder builder =3D new SAXBuilder();<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 builder.setJDOMFactory(new Locat=
edJDOMFactory());<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 builder.set=
Feature(&quot;<a href=3D"http://apache.org/xml/features/xinclude">http://ap=
ache.org/xml/features/xinclude</a>&quot;, true);<br>=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 Document doc =3D builder.build(new File(&quot;c:\\tem=
p\\one.xml&quot;));<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 XMLOutputter out =3D new XMLOutp=
utter(Format.getPrettyFormat());<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 System.out.println(&quot;salida es &quot;+out.outputString(doc));<br><b=
r>the file one.xml is as follows:<br><br>=C2=A0=C2=A0=C2=A0 &lt;?xml versio=
n=3D&quot;1.0&quot; encoding=3D&quot;UTF-8&quot; ?&gt;<br>
=C2=A0=C2=A0=C2=A0 &lt;eco xmlns:xi=3D&quot;<a href=3D"http://www.w3.org/20=
01/XInclude">http://www.w3.org/2001/XInclude</a>&quot;&gt;<br>=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &lt;tmp-path&gt;/opt/eco/ecoprd/tmp&lt;/tmp-=
path&gt;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &lt;!--<br>=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &lt;xi:include href=3D&quot;two.xml&quot;=
 parse=3D&quot;xml&quot;/&gt;<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 --&gt;<br>=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 &lt;xi:include href=3D&quot;two.xml&quot; parse=3D&qu=
ot;xml&quot; xpointer=3D&quot;web-servers&quot;/&gt;<br>=C2=A0=C2=A0=C2=A0 =
&lt;/eco&gt;<br><br>and two.xml is as follows:<br><br>=C2=A0=C2=A0=C2=A0 &l=
t;?xml version=3D&quot;1.0&quot; encoding=3D&quot;UTF-8&quot; ?&gt;<br>
=C2=A0=C2=A0=C2=A0 &lt;eco&gt;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 &lt;web-servers xml:id=3D&quot;web-servers&quot;&gt;<br>=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &lt;valuations&gt;<br>=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 &lt;url-base&gt;<a href=3D"http://naboo:8080">http://naboo:=
8080</a>&lt;/url-base&gt;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &lt;context&gt;/Statements&lt=
;/context&gt;<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 &lt;path&gt;/services/ValuationsXMLGenerator&lt;/path&gt;<b=
r>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &lt;/v=
aluations&gt;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &lt;/web-server=
s&gt;<br>=C2=A0=C2=A0=C2=A0 &lt;/eco&gt;<br><br>the inclusion of the file w=
ithout the xpointer works fine. But if I use xpointer, I get an error as fo=
llows:<br>
<br>=C2=A0=C2=A0=C2=A0 org.jdom2.input.JDOMParseException: Error on line 7 =
of document file:/c:/temp/one.xml: An &#39;include&#39; failed, and no &#39=
;fallback&#39; element was found.<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 at org.jdom2.input.sax.SAXBuilderEngine.build(SAXBuilderEngine.java:=
228)<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.jdom2.input.sax.SAXBuilde=
rEngine.build(SAXBuilderEngine.java:277)<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 at org.jdom2.input.sax.SAXBuilderEngine.build(SAXBuilderEngine=
.java:264)<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.jdom2.input=
.SAXBuilder.build(SAXBuilder.java:1116)<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at test.XMLTest.main(XMLTest.jav=
a:17)<br>=C2=A0=C2=A0=C2=A0 Caused by: org.xml.sax.SAXParseException; syste=
mId: file:/c:/temp/one.xml; lineNumber: 7; columnNumber: 65; An &#39;includ=
e&#39; failed, and no &#39;fallback&#39; element was found.<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.apache.xerces.util.ErrorH=
andlerWrapper.createSAXParseException(Unknown Source)<br>=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 at org.apache.xerces.util.ErrorHandlerWrapper.fata=
lError(Unknown Source)<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org=
.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.apache.xerces.impl.XMLErr=
orReporter.reportError(Unknown Source)<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 at org.apache.xerces.xinclude.XIncludeHandler.reportError(Unknown=
 Source)<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.apache.xerces=
.xinclude.XIncludeHandler.reportFatalError(Unknown Source)<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.apache.xerces.xinclude.XI=
ncludeHandler.reportFatalError(Unknown Source)<br>=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 at org.apache.xerces.xinclude.XIncludeHandler.reportFata=
lError(Unknown Source)<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org=
.apache.xerces.xinclude.XIncludeHandler.emptyElement(Unknown Source)<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.apache.xerces.impl.XMLNSD=
ocumentScannerImpl.scanStartElement(Unknown Source)<br>=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 at org.apache.xerces.impl.XMLDocumentFragmentScann=
erImpl$FragmentContentDispatcher.dispatch(Unknown Source)<br>=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.apache.xerces.impl.XMLDocumentFragmen=
tScannerImpl.scanDocument(Unknown Source)<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.apache.xerces.parsers.XML=
11Configuration.parse(Unknown Source)<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Sou=
rce)<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.apache.xerces.par=
sers.XMLParser.parse(Unknown Source)<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.apache.xerces.parsers.Abs=
tractSAXParser.parse(Unknown Source)<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unkno=
wn Source)<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 at org.jdom2.input=
.sax.SAXBuilderEngine.build(SAXBuilderEngine.java:217)<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ... 4 more<br><br>What I&#39;m m=
issing? supposedly the xpointer=3D&quot;web-servers&quot; should get the el=
ement web-serves with xml:id=3D&quot;web-servers&quot;, but it is not. Any =
suggestions?<br><br></div>

--001a11c26774633da205012c5014--

--===============0743606783==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]
--===============0743606783==--