[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
XInclude inconsistency ?
- From: Philippe Poulard <Philippe.Poulard@sophia.inria.fr>
- To: xml-dev@lists.xml.org
- Date: Thu, 15 Mar 2007 11:20:16 +0100
hi,
I'm not sure what's wrong with XInclude : the spec, the test suite... or
me ?
While implementing XInclude in RefleX, I encountered something strange
about loops
http://www.w3.org/TR/xinclude/#xml-included-items
The XInclude test suite check that part of the spec in the [eduni-2]
test case by Richard Tobin, that verifies that xi:include elements in
the target have been processed in the acquired infoset, ie before the
xpointer is applied.
Here is the test :
--------------extract.xml
<extract>
<include href="book.xml" xpointer="intro"/>
<include href="book.xml" xpointer="chap1"/>
</extract>
--------------book.xml
<book>
<intro id="intro">
You will enjoy this book.
</intro>
<include href="chap1.xml"/>
<include href="chap2.xml"/>
</book>
--------------chap1.xml
<chapter id="chap1">
It was a dark and stormy night.
</chapter>
--------------the result expected
<extract>
<intro id="intro" xml:base="book.xml">
You will enjoy this book.</intro>
<chapter id="chap1" xml:base="chap1.xml">
It was a dark and stormy night.
</chapter>
</extract>
So far, everything seems ok.
Another part of the spec talk about loops :
http://www.w3.org/TR/2006/REC-xinclude-20061115/#loops
Which states that A include B include A can work as long as the pointed
parts of A are not dependant hierarchycally ; exemple :
--------------xi2.xml
<root xmlns:xi="http://www.w3.org/2001/XInclude">
<p>Include a part of A that include B that include another part of
A</p>
<A><xi:include href="xi2-A-include.xml" parse="xml"
xpointer="xpointer(//here[2])"/></A>
</root>
-------------xi2-A-include.xml
<rootA xmlns:xi="http://www.w3.org/2001/XInclude">
<here>HERE</here>
<there>there</there>
<here>here<B><xi:include href="xi2-B-include.xml" parse="xml"
xpointer="xpointer(//somewhere)"/></B></here>
</rootA>
-------------xi2-B-include.xml
<rootB xmlns:xi="http://www.w3.org/2001/XInclude">
<somewhere>somewhere<A><xi:include href="xi2-A-include.xml"
parse="xml" xpointer="xpointer(//there)"/></A></somewhere>
</rootB>
-------------result expected
<root xmlns:xi="http://www.w3.org/2001/XInclude">
<p>Include a part of A that include B that include another part of
A</p>
<A><here>here<B><somewhere>somewhere<A><there>there</there></A></somewhere></B></here></A>
</root>
To make this example fail, we can simply change the xpointer expression
in xi2-B-include.xml with "xpointer(//here[2])", which MUST cause a loop
exception.
So far, everything seems ok once again.
However, in my implementation, I first consider the latter case, and
when I tried to pass the XInclude test suite, the [eduni-2] test case
fails ; so, I tried to correct the bug, but the changes broke my own
test (infinite loop).
In fact, I'm not sure that both can work together : the spec says that
in one hand xpointer have to be resolved on the acquired infoset, that
is to say that the input target have to be pass through an xinclude
filter before applying xpointer, and in the other hand that it is
allowed to have the same input target involved several times if the
nodes are not hierarchically dependant, which implies that the input
target mustn't be passed through an xinclude filter before applying
xpointer, otherwise an infinite loop may occur (because it can't be
detected).
When I fix the bug in one case, it cause a bug in the other.
I tried my theory on another implementation : I suppose that XOM passes
the test suite (and the [eduni-2] test case), so I just try to resolve
the inclusion on my example ; I just replace the xpointer() scheme which
is not supported by XOM with an equivalent element() scheme, and I get
the result expected, as XOM is certainly implemented to pass the
[eduni-2] test case, it also resolves correctly my test, but when I
replace the xpointer expression to cause a loop exception, I get the
famous infinite loop :
Exception in thread "main" java.lang.StackOverflowError
I bet on an inconsistency in the XInclude spec, because I don't think it
is implementable, although I'm not sure. Perhaps there is a solution
to make the 2 examples working correctly (with the ability to detect the
loop in the second case).
Some advice ?
--
Cordialement,
///
(. .)
--------ooO--(_)--Ooo--------
| Philippe Poulard |
-----------------------------
http://reflex.gforge.inria.fr/
Have the RefleX !
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]