<?xml version="1.0"?>

<!--
Stylesheet for conversion UpCast 3.0.9 -> DocBook

** PROVIDED AS-IS, NO WARRANTIES, NO SUPPORT! **

_______________________________
Important setting up of UpCast:

Filter:                          XML (generic DTD)

________________________
Configuration of filter:

Namespace for upCast Elements:   uc
Table model:                     CALS (XML-EM/OASIS)

Updated for upCast 3.0.9:        Christian Roth, cr@infinity-loop.de

$Revision: 1.2 $
$Date: 2005/11/25 01:22:51 $
$Author: iloop $
-->

<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:uc="http://www.infinity-loop.de/upcast/generic-dtd-v30"
  exclude-result-prefixes="uc"
  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="uc:document">
  <article>
     <xsl:apply-templates/>
  </article>
</xsl:template>

<xsl:template match="uc:documentinfo">
  <!-- nop -->
</xsl:template>

<xsl:template match="uc:part">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="uc:section">
  <xsl:variable name="content" select="." />
  <xsl:if test="$content != ''">
    <section>
      <title>
        <xsl:value-of select="uc:heading"/>
      </title>
      <xsl:apply-templates/>
    </section>
  </xsl:if>
</xsl:template>

<xsl:template match="uc:heading">
  <!-- nop -->
</xsl:template>

<xsl:template match="uc:par[not (uc:image)]">
  <para>
    <xsl:apply-templates/>
  </para>
</xsl:template>

<xsl:template match="uc:inline">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="uc:plain">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="uc:hidden">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="uc: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="uc:item">
  <listitem>
    <xsl:apply-templates/>
  </listitem>
</xsl:template>

<xsl:template match="uc:table">
  <informaltable>
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates/>
  </informaltable>
</xsl:template>

<xsl:template match="uc:tgroup">
  <tgroup>
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates/>
  </tgroup>
</xsl:template>

<xsl:template match="uc:colspec">
  <colspec>
    <xsl:copy-of select="@*"/>
  </colspec>
</xsl:template>

<xsl:template match="uc:thead">
  <thead>
    <xsl:apply-templates/>
  </thead>
</xsl:template>

<xsl:template match="uc:tbody">
  <tbody>
    <xsl:apply-templates/>
  </tbody>
</xsl:template>

<xsl:template match="uc:row">
  <row>
    <xsl:apply-templates/>
  </row>
</xsl:template>

<xsl:template match="uc:entry">

<xsl:variable name="align" select="uc: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="uc:image | uc:par/uc:image">
  <mediaobject>
    <imageobject>
      <imagedata>
        <xsl:attribute name="fileref">
          <xsl:value-of select="@src"/>
        </xsl:attribute>
      </imagedata>
    </imageobject>
  </mediaobject>
</xsl:template>

<xsl:template match="uc:subdoc">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="uc:reference">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="uc:footnote">
  <footnote>
    <xsl:apply-templates/>
  </footnote>
</xsl:template>

<xsl:template match="uc:textbox">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="uc:annotation">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="uc:gentext">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="uc:target">
  <anchor>
    <xsl:attribute name="id">
      <xsl:value-of select="@name"/>
    </xsl:attribute>
  </anchor>
</xsl:template>

<xsl:template match="uc:url">
  <ulink>
    <xsl:attribute name="url">
      <xsl:value-of select="@name" />
    </xsl:attribute>
    <xsl:apply-templates/>
  </ulink>
</xsl:template>

<xsl:template match="uc:newline">
  <!-- nop -->
</xsl:template>

<xsl:template match="uc:pagebreak">
  <!-- nop -->
</xsl:template>

<xsl:template match="uc:newcolumn">
  <!-- nop -->
</xsl:template>

<xsl:template match="uc: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="uc:pageheader">
  <!-- nop -->
</xsl:template>

<xsl:template match="uc:pagefooter">
  <!-- nop -->
</xsl:template>

<xsl:template match="uc:toc">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="uc:formtext">
  <!-- nop -->
</xsl:template>

<xsl:template match="uc:formcheckbox">
  <!-- nop -->
</xsl:template>

<xsl:template match="uc:formdropdown">
  <!-- nop -->
</xsl:template>

</xsl:stylesheet>
