[xml] Best way to add XInclude to existing DTD?



I'm investigating XInclude as a way to compile a number of separately
maintained DocBook XML documents into one document for publication. The
beauty of using XInclude is that each document is a valid instance by
itself, which makes it a lot easier to edit (and besides, it encourages a
writing style which is beneficial for this particular purpose).

I wonder what might be the most kosher way to add the necessary <include
href="..."> element to DocBook?

E.g., to pick up fragments as <section> elements:

  <?xml version="1.0"?>
  <!DOCTYPE section PUBLIC 
    "-//OASIS//DTD DocBook XML V4.1.2//EN"
    "/usr/share/sgml/docbook/xml-dtd-4.1.2/docbookx.dtd" [
    <!ENTITY % local.section.attrib
      "xmlns:xi CDATA #FIXED 'http://www.w3.org/2001/XInclude'"
    >
    <!ENTITY % local.refentry.class
      "|xi:include"
    >
    <!-- ENTITY % local.refentry.class
      "|include"
    -->
    <!ELEMENT xi:include
      EMPTY
    >
    <!ATTLIST xi:include
      href CDATA #REQUIRED
      parse (xml|text) "xml"
      encoding CDATA #IMPLIED
    >
  ]>
  <section> 
    <title>A section</title> 
    <para>Some introductory remarks</para>
    <xi:include href="included.xml#xpointer(/section)"/>
  </section>

I've added the XInclude namespace declaration as a #FIXED attribute to
<section>, and added <xi:include> to the content model of %refentry.class;,
which was as close as I could easily get to <section>. 

This works well with editors and with libxml/libxslt (2.4.5/1.0.4) except
that it does not validate with xmllint (using libxml version 20405). For
validation, xmllint wants "include" rather than "xi:include":

$ xmllint --catalogs --loaddtd --valid --debug template.xml

template.xml:27: validity error: Element section content doesn't follow the
Dtd
Expecting (sectioninfo? , ... a large content model ... | (refentry |
xi:include)+ | section+) , (toc | lot | index | glossary | bibliography)*),
got (title para include )
</section>
         ^
DOCUMENT
version=1.0
URL=template.xml
standalone=true
  DTD(section), PUBLIC -//OASIS//DTD DocBook XML V4.1.2//EN, SYSTEM
/usr/share/sgml/docbook/xml-dtd-4.1.2/docbookx.dtd
    ENTITYDECL(local.section.attrib), parameter
     content=xmlns:xi CDATA #FIXED 'http://www.w3.org...
    ENTITYDECL(local.refentry.class), parameter
     content=|xi:include
    COMMENT
      content= ENTITY % local.refentry.class     "|inc...
    ELEMDECL(include), EMPTY
    ATTRDECL(href) for xi:include CDATA REQUIRED
    ATTRDECL(parse) for xi:include ENUMERATION (xml|text)"xml"
    ATTRDECL(encoding) for xi:include CDATA IMPLIED
  ELEMENT section
    namespace xi href=http://www.w3.org/2001/XInclude
    TEXT
      content=    
    ELEMENT title
      TEXT
        content=A section
    TEXT
      content=    
    ELEMENT para
      TEXT
        content=Some introductory remarks
    TEXT
      content=   
    ELEMENT xi:include
      ATTRIBUTE href
        TEXT
          content=included.xml#xpointer(/section)
    TEXT
      content= 

For the validation, xmllint reports that it got an "include" element, while
the debug output displays a "xi:include" element.

What gives?

Kind regards,
Peter Ring




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]