This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Re: Problem with XInclude
- From: Bob Stayton <bobs at caldera dot com>
- To: rich_b_nz at clear dot net dot nz, docbook-apps at lists dot oasis-open dot org
- Date: Wed, 20 Nov 2002 01:25:45 -0800
- Subject: Re: DOCBOOK-APPS: Problem with XInclude
- References: <3ddb4707.303d.0@clear.net.nz>
On Wed, Nov 20, 2002 at 09:25:43PM +1200, Richard Barrington wrote:
> > I just tried to use XInclude in my DocBook/XML marked up book to
> > include listings from external files into <programlisting> sections,
> > but all I get out of
> >
> > <xi:include href="Test.php" parse="text" />
> >
> > is
> >
> > <xi:include></xi:include>
> >
> > in the output and
> >
> > No template matches xi:include in programlisting.
> >
> > as a warning from Saxon 6.5.2.
> >
> >--
> > Sebastian Bergmann
>
>
> Saxon 6.5.2 doesn't do xinclude "out of the box". You cantry the xincluder plugin
> from http://xincluder.sourceforge.net/ or maybe you can use something like this
> stylesheet first:
>
> <?xml version="1.0" encoding="utf-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xi="http://www.w3.org/2001/XInclude">
>
> <!-- initial generator -->
> <xsl:template match="/">
> <xsl:apply-templates/>
> </xsl:template>
>
> <!-- simply copy everything -->
> <xsl:template match="@*|*|text()|processing-instruction()">
> <xsl:copy>
> <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
>
> </xsl:copy>
> </xsl:template>
>
> <!-- base reference for xincludes
> a smarter person may be able to do without it -->
> <xsl:param name="basedir" select="."/>
>
> <!-- resolve the xi:includes in leau of a real xincluder -->
> <xsl:template match="xi:include">
> <xsl:apply-templates select="document(concat($basedir,../@xml:base,@href))"/>
>
> </xsl:template>
>
> </xsl:stylesheet>
>
Another approach is to use xmllint, which is part of
the libxml2 library, to resolve xincludes:
xmllint --xinclude book.xml > resolvedbook.xml
and then feed resolvedbook.xml to saxon. xmllint's xinclude
processor handles the more flexible xpointer syntax to
select part of an included document.
While you are at it you could add xmllint's
--postvalid option to validate the resolved document.
Or you could switch to xsltproc with the --xinclude option,
which handles xincludes natively as it processes the stylesheet.
But it lacks some of the stylesheet extension functions that
saxon supports.
--
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