Page 1 of 1

including xinclude

Posted: Tue Apr 05, 2011 3:58 pm
by mdamkier
Hi all,
Using oXygen 12.1.
I have, what I hope is, a simple problem/question. In the DTD declaration I would like to call my own driver file that adds a couple of things, including xinclude, to the "stock" DTD (DocBook XML 4.5). Like this...
<!DOCTYPE book SYSTEM "DTD/driver.dtd">

Here is my driver file...
<!-- DocBook 4.5 -->
<!ENTITY % docbook4.5 SYSTEM "docbook/xml/4.5/docbookx.dtd">
%docbook4.5;
<!-- DTD extensions -->
<!ENTITY % xinclude SYSTEM "docbook/xml/xinclude.mod">
%xinclude;

This works just fine for processing the document outside of oXygen. But, oXygen does not 'see' the xinclude information and complains that xi:include is an unexpected element.
It does work in oXygen if I declare it like this...
<!DOCTYPE book SYSTEM "DTD/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % xinclude SYSTEM "DTD/docbook/xml/xinclude.mod">
%xinclude;
]>

Is this an oXygen configuration/preferences thing? Any ideas?
Thanks in advance.
- Michael

Re: including xinclude

Posted: Wed Apr 06, 2011 6:04 pm
by adrian
Hello,

In the driver.dtd you should put the XInclude extension before the Docbook DTD:

Code: Select all

<!-- DTD extensions -->
<!ENTITY % xinclude SYSTEM "docbook/xml/xinclude.mod">
%xinclude;
<!-- DocBook 4.5 -->
<!ENTITY % docbook4.5 SYSTEM "docbook/xml/4.5/docbookx.dtd">
%docbook4.5;
This is necessary because the Docbook DTDs use the entities declared in the xinclude.mod, so they have to be declared beforehand.

Regards,
Adrian

Re: including xinclude

Posted: Thu Apr 07, 2011 12:43 pm
by mdamkier
Hi Adrian,
Thank you for your answer! It works now, but that order is counter intuitive (to me, anyway). Does that mean that the stuff one adds between the [] brackets in the DTD declaration is read/processed first, before the specified DTD file?
(Excuse my demonstrating a complete lack of knowledge here. :? )

Re: including xinclude

Posted: Thu Apr 07, 2011 2:20 pm
by george
I think a better model is to think of that as the internal subset overwrites entities that are declared/used in the external subset.

Basically the specification does not restricts the order in which a processor reads the DTDs/internal subset, it cares only about the end result.

Best Regards,
George

Re: including xinclude

Posted: Thu Apr 07, 2011 5:45 pm
by mdamkier
George,
Using the vocabulary external and internal helped. So, if I understand, by putting everything external, that would make the order important.
Many thanks for your help.

Re: including xinclude

Posted: Fri Apr 08, 2011 12:35 pm
by george
The first occurrence of an entity wins but the internal subset gets a chance to modify anything from the external DTDs.

Most of the redefine techniques work this way, that is by placing the redefinitions inside the reference to the content to be redefined. See for example the xsd:redefine from XML Schema. Also in Relax NG if you use an include and refer to a schema, all the patterns placed inside that include (as children of the include element) redefine the ones from the included schema.

Best Regards,
George