This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Re: XSL: Docbook to foreign DTD
- From: Bob Stayton <bobs at caldera dot com>
- To: Jochen Hein <jochen at jochen dot org>, docbook-apps at lists dot oasis-open dot org
- Date: Thu, 03 Jan 2002 16:52:18 -0800
- Subject: Re: DOCBOOK-APPS: XSL: Docbook to foreign DTD
- References: <87lmfftck1.fsf@delphi.lan-ks.de>
On Thu, Jan 03, 2002 at 09:16:46PM +0100, Jochen Hein wrote:
>
> I'm converting Docbook into a given DTD and have problems mapping
> xref. It looks pretty easy:
> Docbook: <xref linkend="something"/> is going to be
> <xref xlink:href="something"/> in the foreign DTD.
>
> My template
>
> <xsl:template match="xref">
> <xref>
> <xsl:attribute name="xlink:href"><xsl:value-of select="@linkend"/></xsl:attribute>
> </xref>
> </xsl:template>
>
> generates <xref href="something"/>, so I assume that gives me problems
> with some sort of namespace. So my question is, how do I generate an
> attribute name with a colon? I don't think I'll have luck in changing
> the foreign DTD...
You need to make a couple of changes to get the
namespace into the attribute name. First, you need to
declare the namespace and prefix in your stylesheet:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.0">
Then you need to remove the "xlink:" prefix from the
name attribute value, and add a namespace attribute to the
<xsl:attribute> element:
<xref>
<xsl:attribute name="href"
namespace="http://www.w3.org/1999/xlink">
<xsl:value-of select="@id"/></xsl:attribute>
</xref>
Then your output will produce <xref xlink:href="something"/>
and the namespace and prefix will be declared in some
output ancestor using a xmlns:xlink attribute.
The namespace URI must match the one declared in the
stylesheet, and then it uses the declared prefix.
This works with xsltproc and saxon.
Bob Stayton 400 Encinal Street
Publications Architect Santa Cruz, CA 95060
Technical Publications voice: (831) 427-7796
Caldera International, Inc. fax: (831) 429-1887
email: bobs@caldera.com