1

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...

Tsundoku
  • 2,455
  • 1
  • 19
  • 31
Oleg
  • 35
  • 4
  • It is hard to reproduce as we don't know what is in `&bookinfo`, i.e `bookinfo.sgm` but most likely is that it opens and closes a `` block. Probably `` is now at an invalid place (should be in an info type of block, se also: https://tdg.docbook.org/tdg/5.0/abstract.html – albert Mar 22 '22 at 10:14

1 Answers1

0

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.

Tsundoku
  • 2,455
  • 1
  • 19
  • 31