<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:import href="xmlspec.xsl"/>
    <xsl:import href="changelog.xsl"/>
    <xsl:output method="html" encoding="utf-8"
        doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
        doctype-system="http://www.w3.org/TR/html4/loose.dtd" indent="no"/>
    <!-- overriding default empty root template to allow passthru of the changelog parameter -->
    <xsl:template match="/">
        <xsl:param name="changelog"/>
        <xsl:apply-templates>
            <xsl:with-param name="changelog" select="$changelog"/>
        </xsl:apply-templates>
    </xsl:template>
    <xsl:template match="inform-div1[head='Change Log']/div2/p[@role]">
        <xsl:variable name="changelog" select="@role"/>
        <xsl:apply-templates select="document('changelog.xml')">
            <xsl:with-param name="changelog" select="$changelog"/>
        </xsl:apply-templates>
    </xsl:template>
    <!-- bibref: reference to a bibliographic entry -->
    <!-- make a link to the bibl -->
    <!-- if the bibl has a key, put it in square brackets; otherwise use
       the bibl's ID -->
    <xsl:template match="bibref">
        <!--<xsl:text>[</xsl:text> -->
        <cite>
            <a>
                <xsl:attribute name="href">
                    <xsl:call-template name="href.target">
                        <xsl:with-param name="target" select="id(@ref)"/>
                    </xsl:call-template>
                </xsl:attribute>
                <xsl:choose>
                    <xsl:when test="id(@ref)/@key">
                        <xsl:value-of select="id(@ref)/@key"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of select="@ref"/>
                    </xsl:otherwise>
                </xsl:choose>
            </a>
        </cite>
        <!--<xsl:text>]</xsl:text> -->
    </xsl:template>
    <xsl:template match="bibl">
        <dt class="label">
            <xsl:attribute name="class">
                <xsl:choose>
                    <xsl:when test="@diff and $show.diff.markup != 0">
                        <xsl:text>diff-</xsl:text>
                        <xsl:value-of select="@diff"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:text>label</xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:attribute>
            <xsl:if test="@id">
                <a name="{@id}"/>
            </xsl:if>
            <xsl:text>[</xsl:text>
            <xsl:choose>
                <xsl:when test="@key">
                    <xsl:value-of select="@key"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="@id"/>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:text>] </xsl:text>
        </dt>
        <dd>
            <xsl:if test="@diff and $show.diff.markup != 0">
                <xsl:attribute name="class">
                    <xsl:text>diff-</xsl:text>
                    <xsl:value-of select="@diff"/>
                </xsl:attribute>
            </xsl:if>
            <xsl:apply-templates/>
            <xsl:if test="not(titleref) and @href">
                <xsl:text> (See </xsl:text>
                <cite>
                    <a href="{@href}">
                        <xsl:value-of select="@href"/>
                    </a>
                </cite>
                <xsl:text>.)</xsl:text>
            </xsl:if>
        </dd>
    </xsl:template>
    <xsl:template match="titleref">
        <xsl:choose>
            <xsl:when test="../@href">
                <cite>
                    <a href="{../@href}">
                        <xsl:apply-templates/>
                    </a>
                </cite>
            </xsl:when>
            <xsl:otherwise>
                <cite>
                    <xsl:apply-templates/>
                </cite>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template match="b">
        <b>
            <xsl:apply-templates/>
        </b>
    </xsl:template>
    <xsl:template match="u">
        <u>
            <xsl:apply-templates/>
        </u>
    </xsl:template>
    <xsl:template match="i">
        <i>
            <xsl:apply-templates/>
        </i>
    </xsl:template>
</xsl:stylesheet>

