[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] Creating a Olink master document
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
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]