This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Entity defs per XML file?


On Wed, Nov 13, 2002 at 09:24:45AM +0100, Kraa de Simon wrote:
> Hello,
> 
> I have a question about how to "spread" the entity definitions across the
> different XML files.
> 
> Let me explain...
> 
> Part of the document structure looks like:
> 
> main.xml
>   userman.xml
>     ch01.xml
>     ch02.xml
>       ch02_inbound.xml
>       ch02_storage.xml
>       ch02_outbound.xml
>     ch03.xml
>     ch04.xml
>     ch05.xml
>   implman.xml
> 
> The doctype is defined in main.xml:
> 
> <?xml version="1.0"?>
> <!DOCTYPE book SYSTEM
> "file://hol01sthira/utils/docbook-xml-4.2/docbookx.dtd"[
>   <!ENTITY % content SYSTEM "content.ent">
> %content; ]>
> 
> With content.ent is:
> 
> <!ENTITY books.userman          SYSTEM "books/userman/userman.xml">
> <!ENTITY ch01.userman           SYSTEM "books/userman/ch01.xml">
> <!ENTITY ch02.userman           SYSTEM "books/userman/ch02.xml">
> <!ENTITY ch02.userman.inbound   SYSTEM "books/userman/ch02_inbound.xml">
> <!ENTITY ch02.userman.storage   SYSTEM "books/userman/ch02_storage.xml">
> <!ENTITY ch02.userman.outbound  SYSTEM "books/userman/ch02_outbound.xml">
> <!ENTITY ch03.userman           SYSTEM "books/userman/ch03.xml">
> <!ENTITY ch04.userman           SYSTEM "books/userman/ch04.xml">
> <!ENTITY ch05.userman           SYSTEM "books/userman/ch05.xml">
> <!ENTITY books.implman          SYSTEM "books/implman/implman.xml">
> 
> What I would like is entity definitions included that are relevant for the
> file only.
> 
> Something like:
> 
> main.xml:
> 
> <!ENTITY books.userman          SYSTEM "books/userman/userman.xml">
> <!ENTITY books.implman          SYSTEM "books/implman/implman.xml">
> 
> userman.xml:
> 
> <!ENTITY ch01.userman           SYSTEM "books/userman/ch01.xml">
> <!ENTITY ch02.userman           SYSTEM "books/userman/ch02.xml">
> <!ENTITY ch03.userman           SYSTEM "books/userman/ch03.xml">
> <!ENTITY ch04.userman           SYSTEM "books/userman/ch04.xml">
> <!ENTITY ch05.userman           SYSTEM "books/userman/ch05.xml">
> 
> ch02.xml:
> 
> <!ENTITY ch02.userman.inbound   SYSTEM "books/userman/ch02_inbound.xml">
> <!ENTITY ch02.userman.storage   SYSTEM "books/userman/ch02_storage.xml">
> <!ENTITY ch02.userman.outbound  SYSTEM "books/userman/ch02_outbound.xml">
> 
> Can this be done? If so, how? I cannot seem to get it working right.

This isn't possible using just SYSTEM entities.
The basic problem is that in order to put a SYSTEM entity
declaration in a chapter file to include its sections, the
chapter file must have a DOCTYPE declaration to permit
adding an internal subset.  But then the chapter file is
referenced as a SYSTEM entity from the book file.
Then you find out that a file referenced as a
SYSTEM entity cannot have a DOCTYPE declaration according
to the XML spec, and parsers will report errors if it
does.  This "feature" is a serious barrier to doing
modular doc like you want.

You can do modular doc with XIncludes, however.  XIncludes
tolerate  DOCTYPE declarations in the modular files,
and in fact will use any declarations in the
internal subset of the DOCTYPE.  Instead of
declaring system entities in the DOCTYPE, just declare
regular entities, and use those entities in your xinclude
hrefs.

Something like:

main.xml:

<!DOCTYPE book SYSTEM "docbook.dtd" [
<!ENTITY books.userman          "books/userman/userman.xml">
<!ENTITY books.implman          "books/implman/implman.xml">
]>
<book>
...
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"; href="&books.userman;"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"; href="&books.implman;"/>
</book>


userman.xml:
<!DOCTYPE chapter SYSTEM "docbook.dtd" [
<!ENTITY ch01.userman           "ch01.xml">
<!ENTITY ch02.userman           "ch02.xml">
<!ENTITY ch03.userman           "ch03.xml">
<!ENTITY ch04.userman           "ch04.xml">
<!ENTITY ch05.userman           "ch05.xml">
]>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"; href="&ch01.userman;"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"; href="&ch02.userman;"/>
...


By default, xinclude relative paths are resolved
relative to the including document, so your second set
of entities looks like it could use just filenames.

It may be that some of your modules don't validate.
Your userman.xml looks like a flat list of
chapters, which works fine as a system entity.
But without a container it is not a valid document.  
If you want individual modules to validate, you'll
have to restructure a bit.
But since validation is taking place after XInclude
resolution, only the book level document needs to
be valid.


Bob Stayton                                 400 Encinal Street
Publications Architect                      Santa Cruz, CA  95060
Technical Publications                      voice: (831) 427-7796
The SCO Group                               fax:   (831) 429-1887
                                            email: bobs@sco.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]