[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XInclude inconsistency ?

  • From: Philippe Poulard <Philippe.Poulard@s...>
  • To: xml-dev@l...
  • Date: Thu, 15 Mar 2007 11:20:16 +0100

XInclude inconsistency ?
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]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.