XIncludes witj DocBook and Oxygen 3

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.

XIncludes witj DocBook and Oxygen 3

Postby ron » Thu Jan 22, 2004 7:31 pm

I have been trying to use Docbook 4.2 with XInclude and Oxygen 3 - without much success. Can somebody please tell me where I am going wrong. The (simplified) XML files are listed below, all are well-formed and valid (according to Oxygen). I am using the suggestion of Bob Stayton, 'DocBook XSL', p.249-250 to customize docbookx.dtd to handle XIncludes. When I transform using docbook.xsl and request html output (no FO processing) and save the html output (appended below) the XInclude has not worked; all I get is the <hr> and the XInclude directives displayed (see html output file below.).

If anyone could show me how to make this example work I would be very grateful.

Ron


MAIN DRIVER FILE:
<?xml version='1.0'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "/Applications/Utilities/oxygen/3.0/oxygen/docbook/dtd/docbookx.dtd"
[
<!ELEMENT xi:include (xi:fallback?) >
<!ATTLIST xi:include
xmlns:xi CDATA #FIXED "http://www.w3.org/2003/XInclude"
href CDATA #REQUIRED
parse (xml|text) "xml"
xpointer CDATA #IMPLIED
encoding CDATA #IMPLIED
accept CDATA #IMPLIED
accept-charset CDATA #IMPLIED
accept-language CDATA #IMPLIED >
<!ELEMENT xi:fallback ANY >
<!ATTLIST xi:fallback
xmlns:xi CDATA #FIXED "http://www.w3.org/2001/XInclude" >
<!ENTITY % local.preface.class "| xi:include">
<!ENTITY % local.part.class "| xi:include">
<!ENTITY % local.chapter.class "| xi:include">
<!ENTITY % local.divcomponent.mix "| xi:include">
<!ENTITY % local.para.char.mix "| xi:include">
<!ENTITY % local.info.class "| xi:include">

<!ENTITY % local.common.attrib "xml:base CDATA #IMPLIED" >
]>
<book>
<xi:include href="/Library/WebServer/Documents/catterall/_SGGK/_XML/preface.xml"
xmlns:xi="http://www.w3.org/2003/XInclude" />
</book>


FIRST XINCLUFDE FILE: - preface.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE preface PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "/Applications/Utilities/oxygen/3.0/oxygen/docbook/dtd/docbookx.dtd"
[
<!ELEMENT xi:include (xi:fallback?) >
<!ATTLIST xi:include
xmlns:xi CDATA #FIXED "http://www.w3.org/2003/XInclude"
href CDATA #REQUIRED
parse (xml|text) "xml"
xpointer CDATA #IMPLIED
encoding CDATA #IMPLIED
accept CDATA #IMPLIED
accept-charset CDATA #IMPLIED
accept-language CDATA #IMPLIED >
<!ELEMENT xi:fallback ANY >
<!ATTLIST xi:fallback
xmlns:xi CDATA #FIXED "http://www.w3.org/2001/XInclude" >
<!ENTITY % local.preface.class "| xi:include">
<!ENTITY % local.part.class "| xi:include">
<!ENTITY % local.chapter.class "| xi:include">
<!ENTITY % local.divcomponent.mix "| xi:include">
<!ENTITY % local.para.char.mix "| xi:include">
<!ENTITY % local.info.class "| xi:include">
<!ENTITY % local.common.attrib "xml:base CDATA #IMPLIED" >
]>
<preface id="Preface" lang="EN">
<title>
Preface Title
</title>
<xi:include href="/Library/WebServer/Documents/catterall/_SGGK/_XML/acknowledgements.xml" xmlns:xi="http://www.w3.org/2003/XInclude" />
</preface>


SECOND XINCLUDE FILE: - acknowledgements.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "/Applications/Utilities/oxygen/3.0/oxygen/docbook/dtd/docbookx.dtd"
[
<!ELEMENT xi:include (xi:fallback?) >
<!ATTLIST xi:include
xmlns:xi CDATA #FIXED "http://www.w3.org/2003/XInclude"
href CDATA #REQUIRED
parse (xml|text) "xml"
xpointer CDATA #IMPLIED
encoding CDATA #IMPLIED
accept CDATA #IMPLIED
accept-charset CDATA #IMPLIED
accept-language CDATA #IMPLIED >
<!ELEMENT xi:fallback ANY >
<!ATTLIST xi:fallback
xmlns:xi CDATA #FIXED "http://www.w3.org/2001/XInclude" >
<!ENTITY % local.preface.class "| xi:include">
<!ENTITY % local.part.class "| xi:include">
<!ENTITY % local.chapter.class "| xi:include">
<!ENTITY % local.divcomponent.mix "| xi:include">
<!ENTITY % local.para.char.mix "| xi:include">
<!ENTITY % local.info.class "| xi:include">
<!ENTITY % local.common.attrib "xml:base CDATA #IMPLIED" >
]>
<section id="Preface_Ackno" lang="EN">
<title>
Acknowledgements Title
</title>
<xi:include href="/Library/WebServer/Documents/catterall/_SGGK/_XML/default_section.xml" xmlns:xi="http://www.w3.org/2003/XInclude" />
</section>


SECOND XINCLUDE FILE: - default_section.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"/Applications/Utilities/oxygen/3.0/oxygen/docbook/dtd/docbookx.dtd"
[
<!ELEMENT xi:include (xi:fallback?) >
<!ATTLIST xi:include
xmlns:xi CDATA #FIXED "http://www.w3.org/2001/XInclude"
href CDATA #REQUIRED
parse (xml|text) "xml"
xpointer CDATA #IMPLIED
encoding CDATA #IMPLIED
accept CDATA #IMPLIED
accept-charset CDATA #IMPLIED
accept-language CDATA #IMPLIED >
<!ELEMENT xi:fallback ANY >
<!ATTLIST xi:fallback
xmlns:xi CDATA #FIXED "http://www.w3.org/2001/XInclude" >
<!ENTITY % local.preface.class "| xi:include">
<!ENTITY % local.part.class "| xi:include">
<!ENTITY % local.chapter.class "| xi:include">
<!ENTITY % local.divcomponent.mix "| xi:include">
<!ENTITY % local.para.char.mix "| xi:include">
<!ENTITY % local.info.class "| xi:include">
<!ENTITY % local.common.attrib "xml:base CDATA #IMPLIED" >
]>
<section id="qwerty" lang="EN">
<title>
XInclude Problem - default section
</title>
<para>
this is the XInclude fallfack - default_section.xml
</para>para
</section>



HTML OUTPUT FILE:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO8859_1">
<title>
</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.62.4">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="book" lang="en">
<div class="titlepage">
<div>
</div>
<div>
</div>
<hr>
</div>
<font color="red">
&lt;xi:include&gt;&lt;/xi:include&gt;
</font>
</div>
</body>
</html>
ron
 

Postby george » Sat Jan 24, 2004 12:27 am

Hi Ron,

It seems that you are mixing XInclude namespaces you use both http://www.w3.org/2001/XInclude and http://www.w3.org/2003/XInclude. I made a simpler sample and it seems to work without problems:

Master file test.xml:
Code: Select all
<?xml version='1.0'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
   "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
[
<!ELEMENT xi:include (xi:fallback?) >
<!ATTLIST xi:include
xmlns:xi CDATA #FIXED "http://www.w3.org/2001/XInclude"
href CDATA #REQUIRED
parse (xml|text) "xml"
xpointer CDATA #IMPLIED
encoding CDATA #IMPLIED
accept CDATA #IMPLIED
accept-charset CDATA #IMPLIED
accept-language CDATA #IMPLIED >
<!ELEMENT xi:fallback ANY >
<!ATTLIST xi:fallback
xmlns:xi CDATA #FIXED "http://www.w3.org/2001/XInclude" >
<!ENTITY % local.preface.class "| xi:include">
<!ENTITY % local.part.class "| xi:include">
<!ENTITY % local.chapter.class "| xi:include">
<!ENTITY % local.divcomponent.mix "| xi:include">
<!ENTITY % local.para.char.mix "| xi:include">
<!ENTITY % local.info.class "| xi:include">

<!ENTITY % local.common.attrib "xml:base CDATA #IMPLIED" >
]>
<book>
<xi:include href="preface.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
</book>


Included file preface.xml:
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE preface PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<preface id="Preface" lang="EN">
    <title> Preface Title</title>
    <para>Preface content. </para>
</preface>


and the result file (I indented it) contains the data from the included preface.xml file:

Code: Select all
<html>
    <head>
        <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title/>
        <meta content="DocBook XSL Stylesheets V1.62.4" name="generator">
    </head>
    <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
        <div class="book" lang="en">
            <div class="titlepage">
                <div/>
                <div/>
                <hr>
            </div>
            <div class="toc">
                <p>
                    <b>Table of Contents</b>
                </p>
                <dl>
                    <dt>
                        <span class="preface">
                            <a href="#Preface"> Preface Title</a>
                        </span>
                    </dt>
                </dl>
            </div>
            <div class="preface" lang="EN">
                <div class="titlepage">
                    <div>
                        <div>
                            <h2 class="title">
                                <a name="Preface"/> Preface Title</h2>
                        </div>
                    </div>
                    <div/>
                </div>
                <p>Preface content. </p>
            </div>
        </div>
    </body>
</html>


Best Regards,
George
george
Site Admin
 
Posts: 2075
Joined: Thu Jan 09, 2003 2:58 pm

XInclude problems with DocBook and Oxygen 3

Postby catterall » Mon Jan 26, 2004 5:46 pm

Hi George

Many thanks for the help - mixing the XInclude namespaces certainly was a problem (my mistake, I tried moving from 2001 to 2003 and didn't do it completely. I've now dropped back to 2001 throughout.) However, there is a further problem.

I can now do XIncludes OK up to two levels, but it dies at a third level. Looks like you're doing enumeration instead of recursion :-).

What I am trying to do is a 'book' that XIncludes 'parts', which XInclude 'chapters', which XInclude 'sections' - i.e. at least three levels of XIincludes, and Oxygen 3.0 only seems to support two levels. (I know, its an experimental implementation of XInclude.)

So, I still have a problem using XIncludes with Oxygen 3.0. If I try a third level of XInclude, the driver file checks out as NOT well-formed, NOT valid and won't transform. The error message I get is:
'The prefix "xi" for element "xi:include" is not bound'

The set of test files below allow the XInclude to be tested up to level four by either transforming at different levels or by commenting out higher level XIncludes.

Is there any hope of at least three or preferably four levels of XInclusion in the near future?

Thanks again

Ron

Driver file - test.xml (XIncludes file Xpreface.xml)
---------------------------------------------------
<?xml version='1.0'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"/Applications/Utilities/oxygen/3.0/oxygen/docbook/dtd/docbookx.dtd"
[
<!ENTITY % xinclude SYSTEM "xinclude.mod" >
%xinclude;
<!ENTITY % local.common.attrib "xml:base CDATA #IMPLIED" >
]>
<book>
<!--
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
-->
<title>
Book Title
</title>
<xi:include href="Xpreface.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
</book>

First level XInclude file - Xpreface.xml (XIncludes file Ypreface.xml)
----------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE preface PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"/Applications/Utilities/oxygen/3.0/oxygen/docbook/dtd/docbookx.dtd"
[
<!ENTITY % xinclude SYSTEM "xinclude.mod" >
%xinclude;
<!ENTITY % local.common.attrib "xml:base CDATA #IMPLIED" >
]>
<preface id="XPreface" lang="EN">
<title>XPreface Title</title>
<para>XPreface content. </para>
<xi:include href="Ypreface.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
</preface>

Second level XInclude file - Ypreface.xml (XIncludes file Zpreface.xml)
-----------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE preface PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"/Applications/Utilities/oxygen/3.0/oxygen/docbook/dtd/docbookx.dtd"
[
<!ENTITY % xinclude SYSTEM "xinclude.mod" >
%xinclude;
<!ENTITY % local.common.attrib "xml:base CDATA #IMPLIED" >
]>
<preface id="YPreface" lang="EN">
<title>YPreface Title</title>
<para>YPreface content. </para>
<!--
<xi:include href="Zpreface.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
-->
</preface>

Third level XInclude file - Zpreface.xml (XIncludes file ZZpreface.xml)
-----------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE preface PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"/Applications/Utilities/oxygen/3.0/oxygen/docbook/dtd/docbookx.dtd"
[
<!ENTITY % xinclude SYSTEM "xinclude.mod" >
%xinclude;
<!ENTITY % local.common.attrib "xml:base CDATA #IMPLIED" >
]>
<preface id="ZPreface" lang="EN">
<title>ZPreface Title</title>
<para>ZPreface content.</para>
<!--
<xi:include href="ZZpreface.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
-->
</preface>

Fourth level XInclude file - ZZpreface.xml (no XIncludes in this file)
---------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE preface PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"/Applications/Utilities/oxygen/3.0/oxygen/docbook/dtd/docbookx.dtd"
[
<!ENTITY % xinclude SYSTEM "xinclude.mod" >
%xinclude;
<!ENTITY % local.common.attrib "xml:base CDATA #IMPLIED" >
]>
<preface id="ZZPreface" lang="EN">
<title>ZZPreface Title</title>
<para>ZZPreface content.</para>
</preface>

xinclude.mod file (to use XIncludes with DocBook 4.2 in all files)
------------------------------------------------------------------
<!ELEMENT xi:include (xi:fallback?) >
<!ATTLIST xi:include
xmlns:xi CDATA #FIXED "http://www.w3.org/2001/XInclude"
href CDATA #REQUIRED
parse (xml|text) "xml"
xpointer CDATA #IMPLIED
encoding CDATA #IMPLIED
accept CDATA #IMPLIED
accept-charset CDATA #IMPLIED
accept-language CDATA #IMPLIED >
<!ELEMENT xi:fallback ANY >
<!ATTLIST xi:fallback
xmlns:xi CDATA #FIXED "http://www.w3.org/2001/XInclude" >
<!ENTITY % local.preface.class "| xi:include" >
<!ENTITY % local.part.class "| xi:include" >
<!ENTITY % local.chapter.class "| xi:include" >
<!ENTITY % local.divcomponent.mix "| xi:include" >
<!ENTITY % local.para.char.mix "| xi:include" >
<!ENTITY % local.info.class "| xi:include" >
<!ENTITY % local.common.attrib "xml:base CDATA #IMPLIED" >
catterall
 
Posts: 41
Joined: Sat Jan 24, 2004 12:10 am
Location: Oaxaca, Mexico

Postby george » Fri Jan 30, 2004 3:47 am

This is indeed a problem. The current workaround is to modify the xinclude.mod file to define the xi prefix to http://www.w3.org/2001/XInclude namespace mapping in the local.common.attrib parameter entity as below:

Code: Select all
<!ELEMENT xi:include (xi:fallback?) >
<!ATTLIST xi:include
xmlns:xi            CDATA       #FIXED       "http://www.w3.org/2001/XInclude"
href                CDATA       #REQUIRED
parse               (xml|text)  "xml"
xpointer            CDATA       #IMPLIED
encoding            CDATA       #IMPLIED
accept              CDATA       #IMPLIED
accept-charset      CDATA       #IMPLIED
accept-language     CDATA       #IMPLIED >
<!ELEMENT xi:fallback ANY >
<!ATTLIST xi:fallback
xmlns:xi            CDATA       #FIXED "http://www.w3.org/2001/XInclude" >
<!ENTITY % local.preface.class    "| xi:include" >
<!ENTITY % local.part.class       "| xi:include" >
<!ENTITY % local.chapter.class    "| xi:include" >
<!ENTITY % local.divcomponent.mix "| xi:include" >
<!ENTITY % local.para.char.mix    "| xi:include" >
<!ENTITY % local.info.class       "| xi:include" >
<!ENTITY % local.common.attrib    "xml:base CDATA #IMPLIED
xmlns:xi            CDATA       #FIXED       'http://www.w3.org/2001/XInclude'" >


Best Regards,
George
george
Site Admin
 
Posts: 2075
Joined: Thu Jan 09, 2003 2:58 pm


Return to Common Problems

Who is online

Users browsing this forum: No registered users and 0 guests

cron