This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Re: [docbook-apps] Creating a Olink master document
- From: Jens Stavnstrup <js at ddre dot dk>
- To: Bob Stayton <bobs at sco dot com>
- Cc: docbook-apps at lists dot oasis-open dot org
- Date: Mon, 8 Dec 2003 09:41:46 +0100 (CET)
- Subject: Re: [docbook-apps] Creating a Olink master document
- Reply-to: Jens Stavnstrup <js at ddre dot dk>
Bob,
Thank. I realized afterwards, that I should have mentioned I am using
Saxon 6.5.2.
I did remove the #default namespace desclration from the
exclude-result-prefixes, but it did not work until I also removed the
xmlns attribute from the xi:include element.
In the resulting xml, the xmsns="xi:..." is actually included, don't ask
me why.
I did not want to put the xmlns: attribute in the root element, since only
the xi:include belongs to this namespace. I guess for now I must just try
until things works. I thinks I understand namespaces, but sometimes seeing
the result of Saxon I doubt.
Regards,
Jens
On Sun, 7 Dec 2003, Bob Stayton wrote:
> On Sun, Dec 07, 2003 at 09:55:20AM +0100, Jens Stavnstrup wrote:
> > All,
> >
> > In order to be able to create a Olink master document dynamically, I
> > use XInclude statements instead of Entities. However, the solution
> > seems to produce multiple namespace declarations. How do I get rid of
> > the extra namespace specfication ?
> >
> > My document specification is defined in documents.xml, the stylesheet
> > in makeolinks.xsl
> >
> >
> > -------------
> > documents.xml
> > -------------
> >
> > <?xml version="1.0"?>
> > <documents>
> > <directory dir="volume1">
> > <docinfo id="vol1">
> > </docinfo>
> > </directory>
> >
> >
> > <directory dir="volume2">
> > <docinfo id="vol2">
> > </docinfo>
> > </directory>
> >
> > </documents>
> >
> >
> > -------------
> > makeolinks.xsl
> > --------------
> >
> > <?xml version="1.0"?>
> >
> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> > xmlns:xi="http://www.w3.org/2001/XInclude"
> > version='1.1'
> > exclude-result-prefixes="#default xi">
> >
> > <!--
> >
> > Creates the olinks masterdatabase.
> >
> > -->
> >
> > <xsl:output method="xml" version="1.0" encoding="utf-8"
> > indent="yes"
> > doctype-system="targetdatabase.dtd"/>
> >
> >
> > <xsl:template match="documents">
> > <targetset>
> > <targetsetinfo></targetsetinfo>
> > <sitemap>
> > <dir name="..">
> > <xsl:apply-templates/>
> > </dir>
> > </sitemap>
> > </targetset>
> > </xsl:template>
> >
> >
> > <xsl:template match="directory">
> > <dir>
> > <xsl:attribute name="name">
> > <xsl:value-of select="@dir"/>
> > </xsl:attribute>
> > <xsl:apply-templates/>
> > </dir>
> > </xsl:template>
> >
> >
> > <xsl:template match="docinfo">
> > <document>
> > <xsl:attribute name="targetdoc">
> > <xsl:value-of select="@id"/>
> > </xsl:attribute>
> > <xsl:variable name="href">
> > <xsl:value-of select="@id"/>
> > <xsl:text>-target.db</xsl:text>
> > </xsl:variable>
> > <xi:include xmlns="http://www.w3.org/2001/XInclude" href="{$href}"/>
> > </document>
> > </xsl:template>
> >
> >
> > </xsl:stylesheet>
> >
> >
> > ------------------
> > Resulting document
> > ------------------
> >
> > <?xml version="1.0" encoding="utf-8"?>
> >
> > <!DOCTYPE targetset
> > SYSTEM "../schema/dtd/targetdatabase.dtd">
> > <targetset>
> > <targetsetinfo> This is the target database document used to create
> > cross-references between document in the NATO C3 Technical
> > Architecture.</targetsetinfo>
> > <sitemap>
> > <dir name="..">
> >
> >
> > <dir name="volume1">
> >
> > <document targetdoc="vol1">
> > <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" xmlns="http://www.w3.org/2001/XInclude" href="vol1-target.db"/>
> > </document>
> >
> > </dir>
> >
> >
> >
> > <dir name="volume2">
> >
> > <document targetdoc="vol2">
> > <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" xmlns="http://www.w3.org/2001/XInclude" href="vol2-target.db"/>
> > </document>
> >
> > </dir>
> >
> > </dir>
> > </sitemap>
> > </targetset>
>
> When I process your files with xsltproc version 1.1.0,
> I don't get double namespace declarations. However,
> it also complained about the #default namespace not
> being declared. When I remove that, it processes fine.
>
> Another way to do it is to just use the declaration
> of the xi namespace only in the stylesheet's
> root element and let the processor handle the
> output namespace declarations. For example:
>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xi="http://www.w3.org/2001/XInclude"
> version='1.1'>
>
> ...
>
> xsl:template match="docinfo">
> <document>
> <xsl:attribute name="targetdoc">
> <xsl:value-of select="@id"/>
> </xsl:attribute>
> <xsl:variable name="href">
> <xsl:value-of select="@id"/>
> <xsl:text>-target.db</xsl:text>
> </xsl:variable>
> <xi:include href="{$href}"/>
> </document>
> </xsl:template>
>
> When I use this, I get xmlns:xi in the
> output <targetset> element, which is sufficient
> to declare it for the entire document.
>
> It is not a requirement that the xmlns:xi be in
> each <xi:include> element, just that it be in
> scope when the xi: prefix is used. In my
> book, I put the xmlns:xi in each include element
> so I can validate the DocBook document.
> You could put the xmlns:xi in the document's
> root element, but then you have to enhance the DTD
> to permit that attribute in all those elements.
>
> --
>
> 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
>
To unsubscribe from this list, send a post to docbook-apps-unsubscribe@lists.oasis-open.org, or visit http://www.oasis-open.org/mlmanage/.