This is the mail archive of the
docbook@lists.oasis-open.org
mailing list for the DocBook project.
RE: Upcast to Docbook?
- From: Johann Richard <Johann dot richard at dspfactory dot ch>
- To: martin dot gautier at myrnham dot co dot uk, docbook at lists dot oasis-open dot org
- Date: Wed, 21 Aug 2002 12:51:15 +0200
- Subject: RE: DOCBOOK: Upcast to Docbook?
Infinity-loop provided me w/ some sample stylesheet for uPcast when I asked for. I included it in the mail, see below. Might need some minor modifs but basically works quite well!
Kind regards,
johann richard
*** upcast2dbk30.xsl ***
<?xml version="1.0"?>
<!--
Stylesheet for conversion UpCast 3.0 -> DocBook
Important setting up of UpCast:
Filter: XML (generic DTD)
Configuration of filter:
Namespace for upCast Elements: upcast
Table model: CALS (XML-EM/OASIS)
$Revision: 2.1 $
$Date: 2001/08/29 $
$Author: Pavel Zampach, zampach@volny.cz $
-->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:upcast="http://www.infinity-loop.de/DTD/upcast/V3.0/"
exclude-result-prefixes="upcast"
version="1.0">
<xsl:output
method="xml"
doctype-public="-//OASIS//DTD DocBook XML V4.1.2//EN"
doctype-system="http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd"
indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="upcast:document">
<article>
<xsl:apply-templates/>
</article>
</xsl:template>
<xsl:template match="upcast:documentinfo">
<!-- nop -->
</xsl:template>
<xsl:template match="upcast:part">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="upcast:section">
<xsl:variable name="content" select="." />
<xsl:if test="$content != ''">
<section>
<title>
<xsl:value-of select="upcast:heading"/>
</title>
<xsl:apply-templates/>
</section>
</xsl:if>
</xsl:template>
<xsl:template match="upcast:heading">
<!-- nop -->
</xsl:template>
<xsl:template match="upcast:par[not (upcast:image)]">
<para>
<xsl:apply-templates/>
</para>
</xsl:template>
<xsl:template match="upcast:inline">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="upcast:plain">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="upcast:hidden">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="upcast:list">
<xsl:variable name="type" select="@listtype"/>
<xsl:choose>
<xsl:when test="$type='disc' or $type=''">
<itemizedlist>
<xsl:apply-templates/>
</itemizedlist>
</xsl:when>
<xsl:otherwise>
<orderedlist>
<xsl:attribute name="numeration">
<xsl:choose>
<xsl:when test="$type='roman-uppercase'">upperroman</xsl:when>
<xsl:when test="$type='roman-lowercase'">lowerroman</xsl:when>
<xsl:when test="$type='alphabetic-uppercase'">upperalpha</xsl:when>
<xsl:when test="$type='alphabetic-lowercase'">loweralpha</xsl:when>
<xsl:otherwise>arabic</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates/>
</orderedlist>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="upcast:item">
<listitem>
<xsl:apply-templates/>
</listitem>
</xsl:template>
<xsl:template match="upcast:table">
<informaltable>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</informaltable>
</xsl:template>
<xsl:template match="upcast:tgroup">
<tgroup>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</tgroup>
</xsl:template>
<xsl:template match="upcast:colspec">
<colspec>
<xsl:copy-of select="@*"/>
</colspec>
</xsl:template>
<xsl:template match="upcast:thead">
<thead>
<xsl:apply-templates/>
</thead>
</xsl:template>
<xsl:template match="upcast:tbody">
<tbody>
<xsl:apply-templates/>
</tbody>
</xsl:template>
<xsl:template match="upcast:row">
<row>
<xsl:apply-templates/>
</row>
</xsl:template>
<xsl:template match="upcast:entry">
<xsl:variable name="align" select="upcast:par[1]/@halign"/>
<entry>
<xsl:copy-of select="@*"/>
<xsl:if test="$align != ''">
<xsl:attribute name="align">
<xsl:choose>
<xsl:when test="$align='justified'">justify</xsl:when>
<xsl:otherwise><xsl:value-of select="$align"/></xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates/>
</entry>
</xsl:template>
<xsl:template match="upcast:image | upcast:par/upcast:image">
<mediaobject>
<imageobject>
<imagedata>
<xsl:attribute name="fileref">
<xsl:value-of select="@src"/>
</xsl:attribute>
</imagedata>
</imageobject>
</mediaobject>
</xsl:template>
<xsl:template match="upcast:subdoc">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="upcast:reference">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="upcast:footnote">
<footnote>
<xsl:apply-templates/>
</footnote>
</xsl:template>
<xsl:template match="upcast:textbox">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="upcast:annotation">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="upcast:gentext">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="upcast:target">
<anchor>
<xsl:attribute name="id">
<xsl:value-of select="@name"/>
</xsl:attribute>
</anchor>
</xsl:template>
<xsl:template match="upcast:url">
<ulink>
<xsl:attribute name="url">
<xsl:value-of select="@name" />
</xsl:attribute>
<xsl:apply-templates/>
</ulink>
</xsl:template>
<xsl:template match="upcast:newline">
<!-- nop -->
</xsl:template>
<xsl:template match="upcast:pagebreak">
<!-- nop -->
</xsl:template>
<xsl:template match="upcast:newcolumn">
<!-- nop -->
</xsl:template>
<xsl:template match="upcast:indextarget">
<indexterm>
<xsl:choose>
<xsl:when test="@entryLevel1">
<primary>
<xsl:value-of select="@entryLevel1"/>
</primary>
</xsl:when>
<xsl:when test="@entryLevel2">
<secondary>
<xsl:value-of select="@entryLevel2"/>
</secondary>
</xsl:when>
<xsl:when test="@entryLevel3">
<tertiary>
<xsl:value-of select="@entryLevel3"/>
</tertiary>
</xsl:when>
<xsl:otherwise>
<!-- nop -->
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates/>
</indexterm>
</xsl:template>
<xsl:template match="upcast:pageheader">
<!-- nop -->
</xsl:template>
<xsl:template match="upcast:pagefooter">
<!-- nop -->
</xsl:template>
<xsl:template match="upcast:toc">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="upcast:formtext">
<!-- nop -->
</xsl:template>
<xsl:template match="upcast:formcheckbox">
<!-- nop -->
</xsl:template>
<xsl:template match="upcast:formdropdown">
<!-- nop -->
</xsl:template>
</xsl:stylesheet>
<!-- **** upcast2dbk30.xsl *** -->
********************************************
Johann Richard
IC & DSP Design Engineer
Dspfactory SA
Champs-Montants 12a
2074 Marin-Epagnier
Switzerland
Tel: +41 32 755 7462
Fax: +41 32 755 7401
e-mail: mailto:johann.richard@dspfactory.ch
http://www.dspfactory.com
********************************************