Oleg
Oleg

Reputation: 43

element book: validity error : Element book content does not follow the DTD

I have the following DocBook structure in my book.xml file:

   <?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"  "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" 
    [ <!-- -->
   <!ENTITY bookinfo SYSTEM "bookinfo.sgm">
      <!ENTITY abstract SYSTEM "abstract.sgm">
      <!ENTITY chap1 SYSTEM "chap1.sgm">
      <!ENTITY biblio SYSTEM "biblio.sgm">
      <!ENTITY the_author "Author Name">
    ] > 
    <book> 
      <title>Book title</title>
     &bookinfo; 
      <abstract>
        <para>Abstract.</para>
      </abstract>
     &chap1; 
     &biblio; 
    </book> 

When I am running xmllint -valid book.xml from cmd, I am getting this error:

book.xml:18: element book: validity error : Element book content does not follow the DTD, expecting ((title , subtitle? , titleabbrev?)? , bookinfo? , (dedication | toc | lot | glossary | bibliography | preface | chapter | reference | part | article | appendix | index | setindex | colophon)*), got (title CDATA abstract CDATA CDATA )

Why does xmllint give me this error? Seems everything is OK...

Upvotes: 1

Views: 572

Answers (1)

Tsundoku
Tsundoku

Reputation: 2707

Assuming the external parsed entities referenced in the document (bookinfo.sgm, chap1.sgm and biblio.sgm) are at their correct locations and valid, the validation error is caused by the presence of the abstract element in the book element.

For the list of parents of abstract, see "abstract" in DocBook: The Definitive Guide.

You can solve the issue by moving the abstract inside an element where it is allowed. For example, if bookinfo.sgm is defined as follows, book.xml will validate:

<subtitle>The Subtitle</subtitle>
<bookinfo>
  <abstract>
    <para>Abstract.</para>
  </abstract>
</bookinfo>

I don't know what else you have in bookinfo.sgm, but moving the abstract inside a bookinfo element definitely works and is valid.

Upvotes: 0

Related Questions