<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:import href="xmlspec.xsl"/>
    <!-- <xsl:import href="changelog.xsl"/> -->
    <!-- The changelog parameter is set to the document . -->
    <xsl:param name="changelogdoc"/>
    <!--xsl:variable name="changelog" select="doc($changelogdoc)"/-->
    <xsl:output method="xml" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" indent="no"/>

    <!--xsl:template match="inform-div1[head='Change Log']/p">
        <xsl:apply-templates select="$changelogdoc"> </xsl:apply-templates>
    </xsl:template-->
    <!--
    <xsl:template match="inform-div1[head='Change Log']/p">
        <xsl:apply-templates 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 xmlns="http://www.w3.org/1999/xhtml">
            <a xmlns="http://www.w3.org/1999/xhtml">
                <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 xmlns="http://www.w3.org/1999/xhtml" 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 xmlns="http://www.w3.org/1999/xhtml" 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 xmlns="http://www.w3.org/1999/xhtml">
            <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 xmlns="http://www.w3.org/1999/xhtml">
                    <a xmlns="http://www.w3.org/1999/xhtml" href="http://dev.w3.org/2008/video/mediaann/%7B@href%7D">
                        <xsl:value-of select="@href"/>
                    </a>
                </cite>
                <xsl:text>.)</xsl:text>
            </xsl:if>
        </dd>
    </xsl:template>

    <xsl:template name="css">
<!-- by wonsuk
	
        <style xmlns="http://www.w3.org/1999/xhtml" type="text/css"> /*<![CDATA[*/

/* added for ontology doc by wonsuk */
table { border-collapse:collapse;
border-spacing: 0px;
margin-top: +1em;
margin-bottom: +1em;}

td    { vertical-align:top; font-size:10pt;text-align:left; padding: 0.4em;}
th    { vertical-align:top; font-size:12pt; text-align:left;  margin: +0.8em;position: inherit;padding: 0.4em;}
hr {margin-top: +1em;margin-bottom: +1em;}
  
.ro-header { height:0.8cm; background-color:#99ccff;}
.ro-odd   { height:0.6cm; background-color:#d5daef;}
.ro-even  { height:0.6cm; background-color:#b8bbc9;}

.cell { font-family:Arial; vertical-align:top; text-align:left; font-size:10pt; font-style:normal;  text-decoration:none  }

.ma { font-family:Arial; vertical-align:top; text-align:left; font-size:10pt; font-style:normal;  font-weight: bold;}

/* added for ontology doc by wonsuk */

code           { font-family: monospace; }

div.constraint,
div.issue,
div.note,
div.notice     { margin-left: 2em; }

ol.enumar      { list-style-type: decimal; }
ol.enumla      { list-style-type: lower-alpha; }
ol.enumlr      { list-style-type: lower-roman; }
ol.enumua      { list-style-type: upper-alpha; }
ol.enumur      { list-style-type: upper-roman; }

dt.label       { display: run-in; }

li, p           { margin-top: 0.3em;
                 margin-bottom: 0.3em; }

.diff-chg       { background-color: yellow; }
.diff-del       { background-color: red; text-decoration: line-through;}
.diff-add       { background-color: lime; }

table          { empty-cells: show; }

table caption {
        font-weight: normal;
        font-style: italic;
        text-align: left;
        margin-bottom: .5em;
}

div.issue {
  color: red;
}
.rfc2119 {
  font-variant: small-caps;
}

div.exampleInner pre { margin-left: 1em;
                       margin-top: 0em; margin-bottom: 0em}
div.exampleOuter {border: 4px double gray;
                  margin: 0em; padding: 0em}
div.exampleInner { background-color: #d5dee3;
                   border-top-width: 4px;
                   border-top-style: double;
                   border-top-color: #d3d3d3;
                   border-bottom-width: 4px;
                   border-bottom-style: double;
                   border-bottom-color: #d3d3d3;
                   padding: 4px; margin: 0em }
div.exampleWrapper { margin: 4px }
div.exampleHeader { font-weight: bold;
                    margin: 4px}

div.boxedtext {
   border: solid #bebebe 1px;
   margin: 2em 1em 1em 2em;
 }

span.practicelab {
   margin: 1.5em 0.5em 1em 1em;
   font-weight: bold;
   font-style: italic;
 }

span.practicelab   { background: #dfffff; }

 span.practicelab {
   position: relative;
   padding: 0 0.5em;
   top: -1.5em;
 }
p.practice
{
   margin: 1.5em 0.5em 1em 1em;
 }

@media screen {
 p.practice {
   position: relative;
   top: -2em;
   padding: 0;
   margin: 1.5em 0.5em -1em 1em;
}
}
/*]]>*/ <xsl:value-of select="$additional.css"/>
        </style>
end by wonsuk -->	
	
        <link xmlns="http://www.w3.org/1999/xhtml" rel="stylesheet" type="text/css">
            <xsl:attribute name="href">
                <xsl:text>http://www.w3.org/2008/WebVideo/Annotations/drafts/ontology10/CR/ma-ont-spec.css</xsl:text>
                <!--xsl:choose>
                    <xsl:when test="/spec/@role='editors-copy'">ma-ont-spec</xsl:when>
                    <xsl:otherwise>
                        <xsl:choose-->
                            <!-- Editor's review drafts are a special case. -->
                            <!--xsl:when test="/spec/@w3c-doctype='review'          or contains(/spec/header/w3c-doctype, 'Editor')">ma-ont-spec</xsl:when>
                            <xsl:when test="/spec/@w3c-doctype='wd'">W3C-WD</xsl:when>
                            <xsl:when test="/spec/@w3c-doctype='rec'">W3C-REC</xsl:when>
                            <xsl:when test="/spec/@w3c-doctype='pr'">W3C-PR</xsl:when>
                            <xsl:when test="/spec/@w3c-doctype='per'">W3C-PER</xsl:when>
                            <xsl:when test="/spec/@w3c-doctype='cr'">W3C-CR</xsl:when>
                            <xsl:when test="/spec/@w3c-doctype='note'">W3C-NOTE</xsl:when>
                            <xsl:when test="/spec/@w3c-doctype='wgnote'">W3C-WG-NOTE</xsl:when>
                            <xsl:when test="/spec/@w3c-doctype='memsub'">W3C-Member-SUBM</xsl:when>
                            <xsl:when test="/spec/@w3c-doctype='teamsub'">W3C-Team-SUBM</xsl:when>
                            <xsl:otherwise>ma-ont-spec</xsl:otherwise>
                        </xsl:choose>
                    </xsl:otherwise>
                </xsl:choose>
                <xsl:text>.css</xsl:text-->
            </xsl:attribute>
        </link>
        <link xmlns="http://www.w3.org/1999/xhtml" rel="stylesheet" type="text/css">
            <xsl:attribute name="href">
                <xsl:text>http://www.w3.org/StyleSheets/TR/W3C-WD.css</xsl:text>
            </xsl:attribute>
        </link>
    </xsl:template>

    <xsl:template match="specref">
        <xsl:param name="target" select="key('ids', @ref)[1]"/>

        <xsl:choose>
            <xsl:when test="not($target)">
                <xsl:message>
                    <xsl:text>specref to non-existent ID: </xsl:text>
                    <xsl:value-of select="@ref"/>
                </xsl:message>
            </xsl:when>
            <xsl:when test="$target[local-name()='p' and @role='practice']">
                <a xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:attribute name="href">
                        <xsl:call-template name="href.target">
                            <xsl:with-param name="target" select="id(@ref)"/>
                        </xsl:call-template>
                    </xsl:attribute>
                    <b xmlns="http://www.w3.org/1999/xhtml">
                        <xsl:apply-templates select="id(@ref)" mode="number"/>
                        <xsl:apply-templates select="id(@ref)/quote[1]" mode="text"/>
                    </b>
                </a>
            </xsl:when>
            <xsl:when test="local-name($target)='issue'">
                <xsl:text>[</xsl:text>
                <a xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:attribute name="href">
                        <xsl:call-template name="href.target">
                            <xsl:with-param name="target" select="id(@ref)"/>
                        </xsl:call-template>
                    </xsl:attribute>
                    <b xmlns="http://www.w3.org/1999/xhtml">
                        <xsl:text>Issue </xsl:text>
                        <xsl:apply-templates select="id(@ref)" mode="number"/>
                        <xsl:text>: </xsl:text>
                        <xsl:for-each select="id(@ref)/head">
                            <xsl:apply-templates/>
                        </xsl:for-each>
                    </b>
                </a>
                <xsl:text>]</xsl:text>
            </xsl:when>
            <xsl:when test="starts-with(local-name($target), 'div')">
                <a xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:attribute name="href">
                        <xsl:call-template name="href.target">
                            <xsl:with-param name="target" select="id(@ref)"/>
                        </xsl:call-template>
                    </xsl:attribute>                    
                    <b xmlns="http://www.w3.org/1999/xhtml">
                        <xsl:apply-templates select="id(@ref)" mode="divnum"/>
                        <xsl:apply-templates select="id(@ref)/head" mode="text"/>
                    </b>
                </a>
            </xsl:when>
            <xsl:when test="starts-with(local-name($target), 'inform-div')">
                <a xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:attribute name="href">
                        <xsl:call-template name="href.target">
                            <xsl:with-param name="target" select="id(@ref)"/>
                        </xsl:call-template>
                    </xsl:attribute>
                    <b xmlns="http://www.w3.org/1999/xhtml">
                        <xsl:apply-templates select="id(@ref)" mode="divnum"/>
                        <xsl:apply-templates select="id(@ref)/head" mode="text"/>
                    </b>
                </a>
            </xsl:when>
            <xsl:when test="local-name($target) = 'vcnote'">
                <b xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:text>[VC: </xsl:text>
                    <a xmlns="http://www.w3.org/1999/xhtml">
                        <xsl:attribute name="href">
                            <xsl:call-template name="href.target">
                                <xsl:with-param name="target" select="id(@ref)"/>
                            </xsl:call-template>
                        </xsl:attribute>
                        <xsl:apply-templates select="id(@ref)/head" mode="text"/>
                    </a>
                    <xsl:text>]</xsl:text>
                </b>
            </xsl:when>
            <xsl:when test="local-name($target) = 'prod'">
                <b xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:text>[PROD: </xsl:text>
                    <a xmlns="http://www.w3.org/1999/xhtml">
                        <xsl:attribute name="href">
                            <xsl:call-template name="href.target">
                                <xsl:with-param name="target" select="id(@ref)"/>
                            </xsl:call-template>
                        </xsl:attribute>
                        <xsl:apply-templates select="$target" mode="number-simple"/>
                    </a>
                    <xsl:text>]</xsl:text>
                </b>
            </xsl:when>
            <xsl:when test="local-name($target) = 'label'">
                <b xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:text>[</xsl:text>
                    <a xmlns="http://www.w3.org/1999/xhtml">
                        <xsl:attribute name="href">
                            <xsl:call-template name="href.target">
                                <xsl:with-param name="target" select="id(@ref)"/>
                            </xsl:call-template>
                        </xsl:attribute>
                        <xsl:value-of select="$target"/>
                    </a>
                    <xsl:text>]</xsl:text>
                </b>
            </xsl:when>
            <!-- MJH added table spec refs -->
            <xsl:when test="local-name($target) = 'table'">
                <a xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:attribute name="href">
                        <xsl:call-template name="href.target">
                            <xsl:with-param name="target" select="id(@ref)"/>
                        </xsl:call-template>
                    </xsl:attribute>
                    <xsl:text>Table </xsl:text>
                    <xsl:apply-templates select="id(@ref)/caption" mode="divnum"/>
                    <!-- uncomment the following two line to add table captions to references -->
                    <!--<xsl:text>, "</xsl:text>
	  <xsl:apply-templates select="id(@ref)/caption" mode="text"/>
	  <xsl:text>"</xsl:text>
	  -->
                </a>
            </xsl:when>
            <xsl:when test="local-name($target) = 'example'">
                <a xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:attribute name="href">
                        <xsl:call-template name="href.target">
                            <xsl:with-param name="target" select="id(@ref)"/>
                        </xsl:call-template>
                    </xsl:attribute>
                    <xsl:text>Example </xsl:text>
                    <xsl:apply-templates select="id(@ref)/head" mode="divnum"/>
                </a>
            </xsl:when>
            <xsl:when test="local-name($target) = 'graphic'">
                <a xmlns="http://www.w3.org/1999/xhtml">
                    <xsl:attribute name="href">
                        <xsl:call-template name="href.target">
                            <xsl:with-param name="target" select="id(@ref)"/>
                        </xsl:call-template>
                    </xsl:attribute>
                    <xsl:text>Figure </xsl:text>
                    <xsl:apply-templates select="id(@ref)" mode="divnum"/>
                </a>
            </xsl:when>
            <xsl:otherwise>
                <xsl:message>
                    <xsl:text>Unsupported specref to </xsl:text>
                    <xsl:value-of select="local-name($target)"/>
                    <xsl:text> [</xsl:text>
                    <xsl:value-of select="@ref"/>
                    <xsl:text>] </xsl:text>
                    <xsl:text> (Contact stylesheet maintainer).</xsl:text>
                </xsl:message>
                <b xmlns="http://www.w3.org/1999/xhtml">
                    <a xmlns="http://www.w3.org/1999/xhtml">
                        <xsl:attribute name="href">
                            <xsl:call-template name="href.target">
                                <xsl:with-param name="target" select="key('ids', @ref)"/>
                            </xsl:call-template>
                        </xsl:attribute>
                        <xsl:text>???</xsl:text>
                    </a>
                </b>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>
