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: transforming DocBook


On Sun, Feb 10, 2002 at 03:37:08PM +0100, Jochen Hein wrote:
> 
> I'm still struggling with a DocBook to foreign DTD translation.  All
> earlier tips have helped me, so thanks to all of you.  What I have to
> do know is the following:
> 
> Docbook has the content model:
> <appendix><title>a title</title>...</appendix>
> <appendix><title>a second title</title>...</appendix>
> <appendix><title>a third title</title>...</appendix>
> 
> What I have to generate is:
> <appendix>
> <chapter><title>a title</title>...</chapter>
> <chapter><title>a second title</title>...</chapter>
> <chapter><title>a third title</title>...</chapter>
> </appendix>
> 
> Currently I misuse a <part> in Docbook, but I'd like to avoid that.
> I do find the first appendix with XSL, but I don't seem to get it
> done.  Any ideas?

Sure, you can have the first appendix process all
of its following-siblings, like this:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
        version="1.0">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="appendix[1]">
  <appendix>
    <chapter>
      <xsl:apply-templates/>
    </chapter>
    <xsl:for-each select="following-sibling::appendix">
      <chapter>
        <xsl:apply-templates/>
      </chapter>
    </xsl:for-each>
  </appendix>
</xsl:template>

<xsl:template match="appendix[position() != 1]">
</xsl:template>

<xsl:template match="title">
  <xsl:copy-of select="."/>
</xsl:template>

</xsl:stylesheet>

The empty <xsl:template match="appendix[position() != 1]">
makes sure you don't double process the other appendixes.


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]