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

On Thu, Sep 20, 2001 at 02:31:07PM +0200, Peter Ring wrote:
  I'm a bit late replying, I'm busy with other stuff and this raises
a few interestng but complex questions !

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

  Well people usually use external parsed entities for this, that's the
canonical way to do this. In general your question would also be suitable
for the docbook-apps mailing list at OASIS.

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 ''"
    <!ENTITY % local.refentry.class
    <!-- ENTITY % local.refentry.class
    <!ELEMENT xi:include
    <!ATTLIST xi:include
      href CDATA #REQUIRED
      parse (xml|text) "xml"
      encoding CDATA #IMPLIED

  I'm always a bit reluctant about extending the DTD from the internal
subset. It is correct but makes the document different, this should work
in this case but is IMHO looking for troubles on the long term.
using a local file path for the SystemID is not fantastic, I would
suggest you investigate XML Catalogs (see my previous posts on this
subject) and keep the canonical URI for docbookx.dtd

    <title>A section</title> 
    <para>Some introductory remarks</para>
    <xi:include href="included.xml#xpointer(/section)"/>

  XInclude is not yet a Recommendation. One of the most controversial
points of the current draft is the reuse of XPointer. I like to see this
used but in all fairness I have to note that this is subject to reexamination
by the XML Core Working Group. I think we will keep this but ...

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

  Yes this in theory should work. But as you noted this may be pushing the
limits of libxml namespaces+DTD compatibility a bit too far.

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":

  This really sounds like a bug, I'm really sorry I didn't had time
to look at it yet. Will do, if you register it on
you will be sure I won't forget :-)

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

template.xml:27: validity error: Element section content doesn't follow the
Expecting (sectioninfo? , ... a large content model ... | (refentry |
xi:include)+ | section+) , (toc | lot | index | glossary | bibliography)*),
got (title para include )
  DTD(section), PUBLIC -//OASIS//DTD DocBook XML V4.1.2//EN, SYSTEM
    ENTITYDECL(local.section.attrib), parameter
     content=xmlns:xi CDATA #FIXED '
    ENTITYDECL(local.refentry.class), parameter
      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=
    ELEMENT title
        content=A section
    ELEMENT para
        content=Some introductory remarks
    ELEMENT xi:include
      ATTRIBUTE href

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

What gives?

  A bug very probably.
I very much like the spirit of your attempt, it is an interesting suggestion.
Another way in the libxml framework to make sure the included entities
are valid is to use the
  xmllint --dtdvalid /usr/share/sgml/docbook/xml-dtd-4.1.2/docbookx.dtd \
"a posteriori" validation. It's more tied in some sense to libxml but 
do not rely on XInclude and XPointer.



Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml Gnome XML XSLT toolkit | Rpmfind RPM search engine

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