This is the mail archive of the
docbook@lists.oasis-open.org
mailing list for the DocBook project.
RE: Re: Concrete proposal for #480954: Extend textobject toinsertexternal files
- To: docbook at lists dot oasis-open dot org
- Subject: RE: DOCBOOK: Re: Concrete proposal for #480954: Extend textobject toinsertexternal files
- From: Peter Ring <pri at magnus dot dk>
- Date: Tue, 13 Nov 2001 15:04:25 +0100
- List-id: <docbook.lists.oasis-open.org>
Here's how we currently use XInclude in DocBook. The XInclude processor is
xmllint or procxslt.
The DTD is customized to allow an include element in handy places: in place
of a chapter, in place of a section, or in places where source code etc. is
typically displayed. It's not quite perfect yet, but validating editors and
parsers seem to like it:
---- magnus-docbookx.dtd ----
<!--
Customised DocBook XML DTD
Invocation:
"-//MAGNUS//DTD DocBook XML V1.0//EN" "magnus-docbookx.dtd"
$Id: magnus-docbookx.dtd,v 1.5 2001/10/26 05:33:41 pri Exp $
-->
<!-- XInclude element
-->
<!ELEMENT include
EMPTY
>
<!ATTLIST include
href CDATA #REQUIRED
parse (xml|text) "xml"
encoding CDATA #IMPLIED
xmlns CDATA #FIXED "http://www.w3.org/2001/XInclude"
>
<!-- include as chapter
-->
<!ENTITY % local.chapter.class
"|include"
>
<!-- include as section
-->
<!ENTITY % section.element "IGNORE">
<!-- Content models that could use <include parse="text" ...>
for including source code etc. verbatim
-->
<!ENTITY % programlisting.element "IGNORE">
<!ENTITY % literallayout.element "IGNORE">
<!ENTITY % screen.element "IGNORE">
<!-- DocBook XML
"http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd"
-->
<!ENTITY % DocBookDTD PUBLIC
"-//OASIS//DTD DocBook XML V4.1.2//EN"
"file:///usr/share/sgml/docbook/xml-dtd-4.1.2/docbookx.dtd"
>
%DocBookDTD;
<!ELEMENT section (sectioninfo?,
(%sect.title.content;),
(%nav.class;)*,
(((%divcomponent.mix;)+,
((%refentry.class;)* | (section | include)*))
| (%refentry.class;)+ | (section | include)+),
(%nav.class;)*)>
<!ELEMENT programlisting (%para.char.mix; | co | lineannotation | include)*>
<!ELEMENT literallayout (%para.char.mix; | lineannotation | co | include)*>
<!ELEMENT screen (%para.char.mix; | co | lineannotation | include)*>
----
A small example of a document:
---- magnus-include.xml ----
<?xml version="1.0"?>
<!DOCTYPE section PUBLIC
"-//MAGNUS//DTD DocBook XML V1.0//EN" "magnus-docbookx.dtd"
>
<section>
<title>A section</title>
<para>Some introductory remarks</para>
<!-- An included section -->
<include href="included.xml#xpointer(/section)"/>
<section>
<title>Another section</title>
<figure>
<title>Included XML</title>
<!-- An included source file with parse="text" -->
<programlisting><include href="included.xml"
parse="text"/></programlisting>
</figure>
<figure>
<title>xsltproc command line</title>
<programlisting>
SGML_CATALOG_FILES=catalog xsltproc --catalogs -nonet --xinclude
/usr/share/sgml/docbook/xsl-stylesheets-1.46-experimental/xhtml/docbook.xsl
magnus-include.xml
</programlisting>
</figure>
<figure>
<title>xmllint command line</title>
<programlisting>
SGML_CATALOG_FILES=catalog xmllint --catalogs --xinclude --dtdattr
magnus-include.xml
</programlisting>
</figure>
</section>
</section>
----
and a small included file
---- included.xml ----
<?xml version="1.0"?>
<!DOCTYPE section PUBLIC
"-//OASIS//DTD DocBook XML V4.1.2//EN" "docbookx.dtd">
<section>
<title>An included section</title>
<para>Some included remarks</para>
</section>
----
Kind regards,
Peter Ring
----------------------------------------------------------------
To subscribe or unsubscribe from this elist use the subscription
manager: <http://lists.oasis-open.org/ob/adm.pl>