home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="ISO-8859-1" ?>
- <!-- xslspec.xsl 1.3 99/01/11 SMI; Style Sheet for the XML and XSL Recommendations and Working Drafts; written by Eduardo Gutentag -->
- <!-- xmlspec.xsl 1.5 1999/04/17 04:13:52 jjc Exp $ Hacked by James Clark -->
- <!-- $Id:$ Modified to output TeXML -->
- <!-- XSL Style sheet, DTD omitted -->
- <xsl:stylesheet
- xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
- resultns="">
-
- <!--
- +++++++++++++++++++++++++
-
- Inclusions
-
- +++++++++++++++++++++++++
- -->
-
- <xsl:template match="/">
- <xsl:apply-templates match="spec"/>
- </xsl:template>
-
- <!--
- *******************************************************************
-
- Basic framework to format W3C specs (as in the XML spec)
-
- *******************************************************************
- -->
- <xsl:template match="spec">
- <TeXML>
- <cmd name="documentclass">
- <parm>article</parm>
- </cmd>
- <cmd name="title">
- <parm>
- <xsl:value-of select="header/title"/>
- <xsl:value-of select="header/version"/>
- </parm>
- </cmd>
- <cmd name="author">
- <parm>
- <xsl:value-of select="w3c-doctype"/>
- <xsl:text> </xsl:text>
- <xsl:value-of select="pubdate/day"/>
- <xsl:text> </xsl:text>
- <xsl:value-of select="pubdate/month"/>
- <xsl:text> </xsl:text>
- <xsl:value-of select="pubdate/year"/>
- </parm>
- </cmd>
- <env name="document">
- <cmd name="maketitle"/>
- <xsl:apply-templates/>
- </env>
- </TeXML>
- </xsl:template>
-
- <!--
- *******************************************************************
-
- Prologue
-
- *******************************************************************
- -->
-
- <xsl:template match="header">
- <xsl:apply-templates select="publoc"/>
- <xsl:apply-templates select="latestloc"/>
- <xsl:apply-templates select="prevlocs"/>
- <xsl:apply-templates select="authlist"/>
- <xsl:call-template name="copyright"/>
- <xsl:apply-templates select="abstract"/>
- <xsl:apply-templates select="status"/>
- </xsl:template>
-
- <xsl:template match="publoc">
- <cmd name="section*"><parm>This version:</parm></cmd>
- <env name="itemize">
- <xsl:apply-templates/>
- </env>
- </xsl:template>
-
- <xsl:template match="publoc/loc" priority="1">
- <cmd name="item"/><xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="latestloc">
- <cmd name="section*"><parm>Latest version:</parm></cmd>
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="prevlocs">
- <cmd name="section*"><parm>Previous versions:</parm></cmd>
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="authlist">
- <cmd name="section*">
- <parm>
- <xsl:text>Editor</xsl:text>
- <xsl:if test="count(author)>1">s</xsl:if>
- <xsl:text>:</xsl:text>
- </parm>
- </cmd>
- <xsl:choose>
- <xsl:when test="count(author)>1">
- <env name="itemize">
- <xsl:apply-templates mode="authors"/>
- </env>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates mode="author"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template match="author" mode="authors">
- <cmd name="item"/><xsl:apply-templates mode=""/>
- </xsl:template>
-
- <xsl:template match="author" mode="author">
- <xsl:apply-templates mode=""/>
- </xsl:template>
-
- <xsl:template match="author/name">
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="author/affiliation">
- <xsl:text>, </xsl:text>
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="author/email">
- <cmd name="textit">
- <parm>
- <xsl:apply-templates/>
- </parm>
- </cmd>
- </xsl:template>
-
- <xsl:template match="abstract">
- <cmd name="section*"><parm>Abstract</parm></cmd>
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="status">
- <cmd name="section*"><parm>Status of this document</parm></cmd>
- <xsl:apply-templates/>
- </xsl:template>
-
- <!--
- *******************************************************************
-
- Real body work
-
- *******************************************************************
- -->
-
- <xsl:template match="body">
- <cmd name="section*"><parm>Table of contents</parm></cmd>
- <xsl:call-template name="toc"/>
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="back">
- <xsl:apply-templates/>
- </xsl:template>
-
- <!-- This is a rather perverse way of dealing with the divs (should
- apply-templates in the div, then have a template rule for each
- div/head) but it's a good way of playing with modes...
- -->
- <xsl:template match="div1|inform-div1">
- <cmd name="part*">
- <parm>
- <xsl:choose>
- <xsl:when test="from-ancestors(back)">
- <xsl:number format="A. "
- count="div1|inform-div1"/>
- </xsl:when>
- <xsl:when test="from-ancestors(body)">
- <xsl:number format="1. "/>
- </xsl:when>
- </xsl:choose>
- <xsl:apply-templates select="head" mode="header"/>
- </parm>
- </cmd>
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="div2">
- <cmd name="section*">
- <parm>
- <xsl:choose>
- <xsl:when test="from-ancestors(back)">
- <xsl:number
- level="multi"
- count="inform-div1|div1|div2"
- format="A.1 "/>
- </xsl:when>
- <xsl:when test="from-ancestors(body)">
- <xsl:number
- level="multi"
- count="div1|div2"
- format="1.1 "/>
- </xsl:when>
- </xsl:choose>
- <xsl:apply-templates select="head" mode="header"/>
- </parm>
- </cmd>
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="div3">
- <cmd name="subsection*">
- <parm>
- <xsl:choose>
- <xsl:when test="from-ancestors(back)">
- <xsl:number
- level="multi"
- count="inform-div1|div1|div2|div3"
- format="A.1 "/>
- </xsl:when>
- <xsl:when test="from-ancestors(body)">
- <xsl:number
- level="multi"
- count="div1|div2|div3"
- format="1.1 "/>
- </xsl:when>
- </xsl:choose>
- <xsl:apply-templates select="head" mode="header"/>
- </parm>
- </cmd>
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="div4">
- <cmd name="subsubsection">
- <parm>
- <xsl:choose>
- <xsl:when test="from-ancestors(back)">
- <xsl:number
- level="multi"
- count="inform-div1|div1|div2|div3|div4"
- format="A.1.1 "/>
- </xsl:when>
- <xsl:when test="from-ancestors(body)">
- <xsl:number
- level="multi"
- count="div1|div2|div3|div4"
- format="1.1.1 "/>
- </xsl:when>
- </xsl:choose>
- <xsl:apply-templates select="head" mode="header"/>
- </parm>
- </cmd>
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="head" priority="1">
- </xsl:template>
-
- <xsl:template match="head" mode="header">
- <xsl:apply-templates/>
- </xsl:template>
-
- <!--
- *******************************************************************
-
- Blocks
-
- *******************************************************************
- -->
- <xsl:template match="item/p" priority="1">
- <xsl:apply-templates/>
- <cmd name="par"/>
- </xsl:template>
-
- <xsl:template match="p">
- <xsl:apply-templates/>
- <cmd name="par"/>
- </xsl:template>
-
- <xsl:template match="eg">
- <env name="verbatim"><verb>
- <xsl:apply-templates/>
- </verb></env>
- </xsl:template>
-
- <xsl:template match="ednote">
- <env name="quote">
- <cmd name="textbf"><parm>Ed. Note: </parm></cmd>
- <xsl:apply-templates/>
- </env>
- </xsl:template>
-
- <xsl:template match="edtext">
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="issue">
- <env name="quote">
- <cmd name="textbf"><parm>Issue (<xsl:value-of select="substring-after(@id,'-')"/>): </parm></cmd>
- <xsl:apply-templates/>
- </env>
- </xsl:template>
-
- <xsl:template match="note">
- <env name="quote">
- <cmd name="textbf"><parm>NOTE: </parm></cmd>
- <xsl:apply-templates/>
- </env>
- </xsl:template>
-
- <xsl:template match="issue/p|note/p">
- <xsl:apply-templates/>
- </xsl:template>
-
- <!--
- *******************************************************************
-
- Productions
-
- *******************************************************************
- -->
- <xsl:template match="scrap">
- <xsl:if test="string(head)">
- <cmd name="textbf"><parm><xsl:value-of select="head"/></parm></cmd>
- </xsl:if>
- <cmd name="par"/>
- <env name="tabular">
- <group>lllll</group>
- <cmd name="noalign"><parm><cmd name="hrule"/></parm></cmd>
- <xsl:apply-templates select="prodgroup|prod"/>
- <cmd name="noalign"><parm><cmd name="hrule"/></parm></cmd>
- </env>
- </xsl:template>
-
- <xsl:template match="prod">
- <!-- select elements that start a row -->
- <xsl:apply-templates select="
- *[from-self(lhs)
- or ((from-self(vc) or from-self(wfc) or from-self(com))
- and not(from-preceding-siblings(*[1][from-self(rhs)])))
- or (from-self(rhs)
- and not(from-preceding-siblings(*[1][from-self(lhs)])))]
- "/>
- </xsl:template>
-
- <xsl:template match="lhs">
- <xsl:number from="body" level="any" format="[1]"/>
- <spec cat="align"/>
- <xsl:apply-templates/>
- <spec cat="align"/>
- <xsl:text>::=</xsl:text>
- <spec cat="align"/>
- <xsl:for-each select="from-following-siblings(*[1])">
- <xsl:apply-templates mode="cell" select="."/>
- <spec cat="align"/>
- <xsl:apply-templates mode="cell" select="from-following-siblings(*[1][from-self(vc) or from-self(wfc) or from-self(com)])"/>
- </xsl:for-each>
- <cmd name="cr"/>
- </xsl:template>
-
- <xsl:template match="rhs">
- <spec cat="align"/>
- <spec cat="align"/>
- <spec cat="align"/>
- <xsl:apply-templates mode="cell" select="."/>
- <spec cat="align"/>
- <xsl:apply-templates mode="cell" select="from-following-siblings(*[1][from-self(vc) or from-self(wfc) or from-self(com)])"/>
- <cmd name="cr"/>
- </xsl:template>
-
- <xsl:template match="vc|wfc|com">
- <spec cat="align"/>
- <spec cat="align"/>
- <spec cat="align"/>
- <spec cat="align"/>
- <xsl:apply-templates mode="cell" select="."/>
- <cmd name="cr"/>
- </xsl:template>
-
- <xsl:template match="prodgroup">
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="com" mode="cell">
- <xsl:text>/*</xsl:text>
- <xsl:apply-templates/>
- <xsl:text>*/</xsl:text>
- </xsl:template>
-
- <xsl:template match="rhs" mode="cell">
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="vc" mode="cell">
- <xsl:text>[VC: </xsl:text>
- <xsl:value-of select="id(@def)/head"/>
- <xsl:text> ]</xsl:text>
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="wfc" mode="cell">
- <xsl:text>[WFC: </xsl:text>
- <xsl:value-of select="id(@def)/head"/>
- <xsl:text>]</xsl:text>
- <xsl:apply-templates/>
- </xsl:template>
-
- <!--
- *******************************************************************
-
- References
-
- *******************************************************************
- -->
- <xsl:template match="p/loc" priority="1">
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="loc">
- <xsl:apply-templates/>
- <cmd name="par"/>
- </xsl:template>
-
- <xsl:template match="bibref">
- <xsl:text>[</xsl:text>
- <xsl:value-of select="id(@ref)/@key"/>
- <xsl:apply-templates/>
- <xsl:text>]</xsl:text>
- </xsl:template>
-
- <xsl:template match="specref">
- <xsl:text>[</xsl:text>
- <cmd name="textbf">
- <parm>
- <xsl:for-each select="id(@ref)/head">
- <xsl:choose>
- <xsl:when test="from-ancestors(back)">
- <xsl:number
- level="multi"
- count="inform-div1|div1|div2|div3|div4"
- format="A.1 "/>
- </xsl:when>
- <xsl:when test="from-ancestors(body)">
- <xsl:number
- level="multi"
- count="div1|div2|div3|div4"
- format="1.1 "/>
- </xsl:when>
- </xsl:choose>
- <xsl:apply-templates/>
- </xsl:for-each>
- </parm>
- </cmd>
- <xsl:apply-templates/>
- <xsl:text>]</xsl:text>
- </xsl:template>
-
- <xsl:template match="termref">
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="titleref">
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="termdef">
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="vcnote">
- <cmd name="textbf">
- <parm>Validity Constraint: <xsl:value-of select="head"/></parm>
- </cmd>
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="wfcnote">
- <cmd name="textbf">
- <parm>Well Formedness Constraint: <xsl:value-of select="head"/></parm>
- </cmd>
- <xsl:apply-templates/>
- </xsl:template>
-
- <!--
- *******************************************************************
-
- Inlines
-
- *******************************************************************
- -->
- <xsl:template match="termdef">
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="term">
- <cmd name="textbf"><parm><xsl:apply-templates/></parm></cmd>
- </xsl:template>
-
- <xsl:template match="orglist/member[1]" priority="2">
- <xsl:apply-templates select="*"/>
- </xsl:template>
-
- <xsl:template match="orglist/member">
- <xsl:text>; </xsl:text>
- <xsl:apply-templates select="*"/>
- </xsl:template>
-
- <xsl:template match="orglist/member/affiliation">
- <xsl:text>, </xsl:text>
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="orglist/member/role">
- <xsl:text> (</xsl:text>
- <xsl:apply-templates/>
- <xsl:text>)</xsl:text>
- </xsl:template>
-
- <xsl:template match="code">
- <cmd name="texttt">
- <parm>
- <xsl:apply-templates/>
- </parm>
- </cmd>
- </xsl:template>
-
- <xsl:template match="emph">
- <cmd name="textit"><parm><xsl:apply-templates/></parm></cmd>
- </xsl:template>
-
- <!--
- *******************************************************************
-
- Lists
-
- *******************************************************************
- -->
- <xsl:template match="blist">
- <env name="description">
- <xsl:apply-templates/>
- </env>
- </xsl:template>
-
- <xsl:template match="slist">
- <env name="itemize">
- <xsl:apply-templates/>
- </env>
- </xsl:template>
-
- <xsl:template match="sitem">
- <cmd name="item"/>
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="blist/bibl">
- <cmd name="item">
- <opt>
- <xsl:value-of select="@key"/>
- </opt>
- </cmd>
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="olist">
- <env name="enumerate">
- <xsl:apply-templates/>
- </env>
- </xsl:template>
-
- <xsl:template match="ulist">
- <env name="itemize">
- <xsl:apply-templates/>
- </env>
- </xsl:template>
-
- <xsl:template match="glist">
- <env name="description">
- <xsl:apply-templates/>
- </env>
- </xsl:template>
-
- <xsl:template match="item">
- <cmd name="item"/>
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="label">
- <cmd name="item">
- <opt>
- <cmd name="textbf"><parm><xsl:apply-templates/></parm></cmd>
- </opt>
- </cmd>
- </xsl:template>
-
- <xsl:template match="def">
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="orglist">
- <xsl:apply-templates select="*"/>
- </xsl:template>
-
- <xsl:template match="olist">
- <env name="enumerate">
- <xsl:apply-templates/>
- </env>
- </xsl:template>
-
-
- <!--
- *******************************************************************
-
- Empty templates
-
- *******************************************************************
- -->
- <xsl:template match="w3c-designation">
- </xsl:template>
-
- <xsl:template match="w3c-doctype">
- </xsl:template>
-
- <xsl:template match="header/pubdate">
- </xsl:template>
-
- <xsl:template match="spec/header/title">
- </xsl:template>
-
- <xsl:template match="revisiondesc">
- </xsl:template>
-
- <xsl:template match="pubstmt">
- </xsl:template>
-
- <xsl:template match="sourcedesc">
- </xsl:template>
-
- <xsl:template match="langusage">
- </xsl:template>
-
- <xsl:template match="version">
- </xsl:template>
-
- <!--
- *******************************************************************
-
- Macros
-
-
- *******************************************************************
- -->
-
- <xsl:template name="copyright">
- Copyright (c) 1998 W3C
- (MIT, INRIA, Keio), All Rights Reserved. W3C
- <cmd name="par"/>
- </xsl:template>
-
- <xsl:template name="toc">
- <env name="tabbing">
- <cmd name="vrule"/> width 0.375in <ctrl ch="="/>
- <cmd name="vrule"/> width 0.375in <ctrl ch="="/>
- <cmd name="kill"/>
- <xsl:for-each select="/spec/body/div1">
- <xsl:number format="1. "/>
- <xsl:call-template name="makeref"/>
- <ctrl ch="\"/>
-
- <xsl:for-each select="div2">
- <ctrl ch=">"/>
- <xsl:number
- level="multi"
- count="div1|div2"
- format="1.1 "/>
- <xsl:call-template name="makeref"/>
- <ctrl ch="\"/>
- <xsl:for-each select="div3">
- <ctrl ch=">"/>
- <ctrl ch=">"/>
- <xsl:number
- level="multi"
- count="div1|div2|div3"
- format="1.1 "/>
- <xsl:call-template name="makeref"/>
- <ctrl ch="\"/>
- </xsl:for-each>
- </xsl:for-each>
- </xsl:for-each>
-
- <cmd name="textbf"><parm>Appendices</parm></cmd>
-
- <xsl:for-each select="/spec/back/div1 | /spec/back/inform-div1">
- <xsl:number format="A. "
- count="div1|inform-div1"/>
- <xsl:call-template name="makeref"/>
- <ctrl ch="\"/>
-
- <xsl:for-each select="div2">
- <ctrl ch=">"/>
- <xsl:number
- level="multi"
- count="div1|div2"
- format="A.1 "/>
- <xsl:call-template name="makeref"/>
- <ctrl ch="\"/>
-
- <xsl:for-each select="div3">
- <ctrl ch=">"/>
- <ctrl ch=">"/>
- <xsl:number
- level="multi"
- count="div1|div2|div3"
- format="A.1 "/>
- <xsl:call-template name="makeref"/>
- <ctrl ch="\"/>
- </xsl:for-each>
- </xsl:for-each>
- </xsl:for-each>
- </env>
- </xsl:template>
-
- <xsl:template name="makeref">
- <xsl:value-of select="head"/>
- </xsl:template>
-
- <xsl:template name="nt">
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template name="xnt">
- <xsl:apply-templates/>
- </xsl:template>
-
- <xsl:template match="quote">
- <xsl:text>``</xsl:text>
- <xsl:apply-templates/>
- <xsl:text>''</xsl:text>
- </xsl:template>
-
- </xsl:stylesheet>
-