Help with validation error in modular DocBook

This should cover W3C XML Schema, Relax NG and DTD related problems.
robert3L
Posts: 21
Joined: Sun Jan 15, 2006 11:36 am

Help with validation error in modular DocBook

Post by robert3L »

I need to refactor a fairly large DocBook help system to modularize it. The examples for book and chapter files at http://www.ibm.com/developerworks/xml/l ... ters3.html would do what I need. I've started a simplified version of that example. However when I try the chapter wrapper (chap5 in the online example) I get this validation error:

F Xerces A DOCTYPE is not allowed in content.

Using DocBook version: 4.4. Here is code:

Book file:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "file:///c:/docbook-xml-4.4/docbookx.dtd" [
<!ENTITY bookinfo SYSTEM "bookinfo.xml">
<!ENTITY preface SYSTEM "preface.xml">
<!ENTITY chap1 SYSTEM "chap1.xml">
]>

<book id="alm" lang="en">
&bookinfo;
&preface;
&chap1;
</book>
Chapter wrapper file "chap1.xml":

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "file:///c:/docbook-xml-4.4/docbookx.dtd" [
<!ENTITY chap1_1 SYSTEM "admin/admin_basics.xml">
]>
<chapter id="ch1_Admin">
<title>System Administration & Configuration</title>
<para>BLAH BLAH BLAH</para>
&chap1_1;
</chapter>
Section file defined in chapter wrapper:

Code: Select all


<sect1 id="admin_admin_basics">
<title>Administration Basics</title>
<para>BLAH BLAH BLAH</para>
</sect1>
The online example uses an earlier version of DocBook, so I wonder if something changed and the my version doesn't support this way of modularizing content.

Any help, advice, link to newer resources much appreciated!
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Help with validation error in modular DocBook

Post by sorin_ristache »

Hello,
robert3L wrote:when I try the chapter wrapper (chap5 in the online example) I get this validation error:

F Xerces A DOCTYPE is not allowed in content.
When the entity &chap1; is expanded in the book file the result will be the DOCTYPE declaration of file chap1.xml inserted in the element <book> of the book file:

Code: Select all

<book id="alm" lang="en">
<!-- bookinfo content here -->
<!-- preface content here -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "file:///c:/docbook-xml-4.4/docbookx.dtd" [ ...

</book>
That is not allowed in an XML document. You did not show the content of bookinfo and preface but if they contain a DOCTYPE declaration you get the same error. You do not get this error when you validate chap1.xml because the entity chap1_1 does not include a DOCTYPE declaration and you should do the same for the main book file.

If you want to keep the DOCTYPE declaration in chap1.xml you can include chap1.xml in the main book file with XInclude instead of entity as explained in the Oxygen User Manual.


Regards,
Sorin
robert3L
Posts: 21
Joined: Sun Jan 15, 2006 11:36 am

Re: Help with validation error in modular DocBook

Post by robert3L »

Thanks for pointer to that doc - I was able to create a more modular structure of all valid DocBook xml files. :D

Now I have to figure out why my existing build batch file doesn't work anymore. I think it is unrelated to the structure change. (I inherited the whole system from someone who didn't document it. The batch invokes Saxon which I guess is a transformer... guess I have to learn about that next).

Anyway thanks for good pointer on this one.
Post Reply