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'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("<a href=3D"http://apache.org/xml/features/xinclude">http://ap=
ache.org/xml/features/xinclude</a>", true);<br>=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 Document doc =3D builder.build(new File("c:\\tem=
p\\one.xml"));<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("salida es "+out.outputString(doc));<br><b=
r>the file one.xml is as follows:<br><br>=C2=A0=C2=A0=C2=A0 <?xml versio=
n=3D"1.0" encoding=3D"UTF-8" ?><br>
=C2=A0=C2=A0=C2=A0 <eco xmlns:xi=3D"<a href=3D"http://www.w3.org/20=
01/XInclude">http://www.w3.org/2001/XInclude</a>"><br>=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <tmp-path>/opt/eco/ecoprd/tmp</tmp-=
path><br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <!--<br>=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <xi:include href=3D"two.xml"=
parse=3D"xml"/><br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 --><br>=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 <xi:include href=3D"two.xml" parse=3D&qu=
ot;xml" xpointer=3D"web-servers"/><br>=C2=A0=C2=A0=C2=A0 =
</eco><br><br>and two.xml is as follows:<br><br>=C2=A0=C2=A0=C2=A0 &l=
t;?xml version=3D"1.0" encoding=3D"UTF-8" ?><br>
=C2=A0=C2=A0=C2=A0 <eco><br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 <web-servers xml:id=3D"web-servers"><br>=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <valuations><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 <url-base><a href=3D"http://naboo:8080">http://naboo:=
8080</a></url-base><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 <context>/Statements<=
;/context><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 <path>/services/ValuationsXMLGenerator</path><b=
r>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 </v=
aluations><br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 </web-server=
s><br>=C2=A0=C2=A0=C2=A0 </eco><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 'include' failed, and no '=
;fallback' 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 'includ=
e' failed, and no 'fallback' 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'm m=
issing? supposedly the xpointer=3D"web-servers" should get the el=
ement web-serves with xml:id=3D"web-servers", 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==--