[xml] XInclude and DTD declarations



Hi,

I have two xml documents one of which XIncludes the other.  For ease of
description I'll call them parent and child.  The parent document has a
DOCTYPE declaration, and the DTD it points to has a number of external
entities defined within it.  The child document has no DOCTYPE
declaration of it's own, but also references the external entities
defined in the parent documents DTD.  e.g.

---parent.xml---
<?xml version="1.0" standalone="no"?>
<!DOCTYPE parent SYSTEM "parent.dtd">
<parent xmlns:xi="http://www.w3.org/2001/XInclude";>
    <tag1>&extentity;</tag1>
    <xi:xinclude href="child.xml">
</parent>
---end parent.xml---

---child.xml---
<?xml version="1.0" standalone="no"?>
<child>
   <name>Babbling Boo</name>
   <info>&extentity;</info>
</child>
---end child.xml---

I then use the following command to process the xincludes and validate
the resultant XML document:

xmllint --xinclude --postvalid parent.xml

The output shows that the xinclude wasn't in fact processed at all
(although no error was given).  If I either take out the reference to
the external entity from child.xml or add the DOCTYPE declaration to
child.xml then the xinclude is processed as expected.  It looks as the
child document is being validated before inclusion, and if validation
fails it isn't included into the parent document.  It would appear that
the DTD from the parent document isn't being looked at to resolve any
external entities that can't be resolved by the child document itself,
hence the child is invalid.  I don't know whether this is defined in the
standard (I couldn't see anything at first glance), or whether what I am
personally classing as "sensible" behaviour is in fact what the majority
of the XML community don't want.  Maybe there's a way of turning off
validation

Thanks for any assistance,

Matthew Burgess.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]