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...
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
abstractelement in thebookelement.For the list of parents of
abstract, see "abstract" in DocBook: The Definitive Guide.You can solve the issue by moving the
abstractinside an element where it is allowed. For example, ifbookinfo.sgmis defined as follows, book.xml will validate:I don't know what else you have in
bookinfo.sgm, but moving the abstract inside abookinfoelement definitely works and is valid.