This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: XSL: Docbook to foreign DTD


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]