<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="/document/title" />
<xsl:template match="/document/docinfo" />
<xsl:template match="/document/topic" />
<xsl:template match="field_list" />
<xsl:template match="comment" />
<xsl:template match="emphasis">
<em><xsl:apply-templates /></em>
</xsl:template>
<xsl:template match="literal">
<tt><xsl:apply-templates /></tt>
</xsl:template>
<xsl:template match="reference">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:choose>
<xsl:when test="@refid">
<xsl:value-of select="concat('#', @refid)" />
</xsl:when>
<xsl:when test="@refuri">
<xsl:value-of select="@refuri" />
</xsl:when>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="strong">
<strong><xsl:apply-templates /></strong>
</xsl:template>
<xsl:template match="image">
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="@uri" />
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:value-of select="@alt" />
</xsl:attribute>
<xsl:attribute name="width">
<xsl:value-of select="@width" />
</xsl:attribute>
<xsl:attribute name="height">
<xsl:value-of select="@height" />
</xsl:attribute>
</xsl:element>
</xsl:template>
<xsl:template match="line_block">
<div class="line-block">
<xsl:apply-templates />
</div>
</xsl:template>
<xsl:template match="line_block/line">
<xsl:apply-templates /><br />
</xsl:template>
<xsl:template match="literal_block">
<div class="literal-block"><xsl:apply-templates /></div>
</xsl:template>
<xsl:template match="literal_block/br">
<br />
</xsl:template>
<xsl:template match="paragraph">
<p><xsl:apply-templates /></p>
</xsl:template>
<xsl:template match="substitution_definition" />
<xsl:template match="block_quote">
<blockquote>
<xsl:apply-templates/>
</blockquote>
<xsl:if test="./attribution">
<div class="cite">
<span class="cite_label">Source: </span>
<cite><xsl:apply-templates select="attribution/*|attribution/text()" /></cite>
</div>
</xsl:if>
</xsl:template>
<xsl:template match="block_quote/attribution" />
<xsl:template match="footnote_reference">
<xsl:element name="a">
<xsl:attribute name="class">footnoteref</xsl:attribute>
<xsl:attribute name="id">
<xsl:text>footnote-backref-</xsl:text>
<xsl:value-of select="@ids" />
</xsl:attribute>
<xsl:attribute name="href">
<xsl:text>#footnote-</xsl:text>
<xsl:value-of select="@refid" />
</xsl:attribute>
<xsl:text>[</xsl:text>
<xsl:apply-templates />
<xsl:text>]</xsl:text>
</xsl:element>
</xsl:template>
<xsl:template match="footnote">
<xsl:element name="div">
<xsl:attribute name="class">footnote</xsl:attribute>
<xsl:attribute name="id">
<xsl:text>footnote-</xsl:text>
<xsl:value-of select="@ids" />
</xsl:attribute>
<xsl:element name="a">
<xsl:attribute name="class">footnotereturn</xsl:attribute>
<xsl:attribute name="href">
<xsl:text>#footnote-backref-</xsl:text>
<xsl:value-of select="@backrefs" />
</xsl:attribute>
<xsl:attribute name="title">
<xsl:text>return to content</xsl:text>
</xsl:attribute>
<xsl:text>#</xsl:text>
<xsl:value-of select="label" />
<xsl:text>: </xsl:text>
</xsl:element>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="footnote/label" />
<xsl:template match="bullet_list">
<ul><xsl:apply-templates /></ul>
</xsl:template>
<xsl:template match="enumerated_list">
<ol><xsl:apply-templates /></ol>
</xsl:template>
<xsl:template match="list_item">
<li><xsl:apply-templates /></li>
</xsl:template>
<xsl:template match="list_item/paragraph">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="definition_list">
<dl><xsl:apply-templates /></dl>
</xsl:template>
<xsl:template match="definition_list_item/term">
<dt><xsl:apply-templates /></dt>
</xsl:template>
<xsl:template match="definition_list_item/definition">
<dd><xsl:apply-templates /></dd>
</xsl:template>
<xsl:template match="option_list">
<table class="option-list" cellpadding="0" cellspacing="0">
<tr>
<th>Option</th>
<th>Description</th>
</tr>
<xsl:apply-templates />
</table>
</xsl:template>
<xsl:template match="option_list_item">
<tr><xsl:apply-templates /></tr>
</xsl:template>
<xsl:template match="option_group">
<td>
<xsl:for-each select="option">
<xsl:apply-templates select="." /><br />
</xsl:for-each>
</td>
</xsl:template>
<xsl:template match="option_group/option">
<span class="option-string"><xsl:value-of select="option_string" /></span>
<xsl:if test="option_argument">
<span class="option-delimiter"><xsl:value-of select="option_argument/@delimiter" /></span>
<span class="option-argument"><xsl:value-of select="option_argument" /></span>
</xsl:if>
</xsl:template>
<xsl:template match="option_list_item/description">
<td><xsl:apply-templates /></td>
</xsl:template>
<xsl:template match="raw[@format='html']">
<xsl:value-of select="." disable-output-escaping="yes" />
</xsl:template>
<xsl:template match="section/title">
<xsl:element name="{concat('h', format-number(count(ancestor::section), '#'))}">
<xsl:attribute name="id">
<xsl:value-of select="parent::section/@ids" />
</xsl:attribute>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="table">
<table cellpadding="0" cellspacing="0"><xsl:apply-templates /></table>
</xsl:template>
<xsl:template match="thead">
<thead><xsl:apply-templates /></thead>
</xsl:template>
<xsl:template match="thead/row">
<tr><xsl:apply-templates /></tr>
</xsl:template>
<xsl:template match="thead/row/entry">
<xsl:element name="th">
<xsl:if test="@morecols">
<xsl:attribute name="colspan">
<xsl:value-of select="format-number(1 + @morecols, '#')" />
</xsl:attribute>
</xsl:if>
<xsl:if test="@morerows">
<xsl:attribute name="rowspan">
<xsl:value-of select="format-number(1 + @morerows, '#')" />
</xsl:attribute>
</xsl:if>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="tbody">
<tbody><xsl:apply-templates /></tbody>
</xsl:template>
<xsl:template match="tbody/row">
<tr><xsl:apply-templates /></tr>
</xsl:template>
<xsl:template match="tbody/row/entry">
<xsl:element name="td">
<xsl:if test="@morecols">
<xsl:attribute name="colspan">
<xsl:value-of select="format-number(1 + @morecols, '#')" />
</xsl:attribute>
</xsl:if>
<xsl:if test="@morerows">
<xsl:attribute name="rowspan">
<xsl:value-of select="format-number(1 + @morerows, '#')" />
</xsl:attribute>
</xsl:if>
<xsl:if test="ancestor::table/preceding-sibling::*[1]/field/field_name[text()='table-cell-halign']">
<xsl:attribute name="align">
<xsl:value-of select="ancestor::table/preceding-sibling::*[1]/field/field_name[text()='table-cell-halign']/../field_body/paragraph" />
</xsl:attribute>
</xsl:if>
<xsl:if test="ancestor::table/preceding-sibling::*[1]/field/field_name[text()='table-cell-valign']">
<xsl:attribute name="valign">
<xsl:value-of select="ancestor::table/preceding-sibling::*[1]/field/field_name[text()='table-cell-valign']/../field_body/paragraph" />
</xsl:attribute>
</xsl:if>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
</xsl:stylesheet>