<?xml version="1.0" encoding="UTF-8"?>

<!--
This stylesheet uses FOP (http://xml.apache.org/fop/), version 0.20.5, to format the XSLT 1.0 specification document (http://www.w3.org/TR/1999/REC-xslt-19991116.xml). The result pretty closely matches the HTML presentation of that document on W3's web site. Naturally, since the output of this document is PDF, it's not entirely the same. Also, I added some things where additions seemed to be appropriate (such as lines between the syntax elements in Appendix B - I found those elements ran together too much otherwise).

This file requires pdfstyles.xsl. I generally separate the style definitions so that I can experiment with them more easily and so that I can use the same set of styles across multiple documents (a big help to ensuring consistent presentation).

Feel to copy, modify, and distribute these two files. However, please give me credit for any of my work that you retain in your new version. I am willing to update this stylesheet when good ideas arrive, and comments and questions are welcome.

Written by Jay Bryant
  e-mail: jay@bryantcs.com
  web: http://www.bryantcs.com
-->


<xsl:stylesheet
  version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:fo="http://www.w3.org/1999/XSL/Format"
  xmlns:fox="http://xml.apache.org/fop/extensions"
  xmlns:e="http://www.w3.org/1999/XSL/Spec/ElementSyntax"
  exclude-result-prefixes="e"
>

  <xsl:output
    method="xml"
    version="1.0"
    omit-xml-declaration="no"
    indent="yes"
  />

  <xsl:include href="pdfstyles.xsl"/>

  <!--
    root template
  -->
  <xsl:template match="/">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <fo:layout-master-set>
        <fo:simple-page-master
          master-name="first"
          xsl:use-attribute-sets="pagedef"
        >
          <fo:region-body region-name="first" margin-top="1in" margin-bottom="1in"/>
          <fo:region-after region-name="footer-first" extent="1in"/>
        </fo:simple-page-master>
        <fo:simple-page-master
          master-name="contents"
          xsl:use-attribute-sets="pagedef"
        >
          <fo:region-body region-name="contents" margin-top="1in" margin-bottom="1in"/>
          <fo:region-after region-name="footer-contents" extent="1in"/>
        </fo:simple-page-master>
        <fo:simple-page-master
          master-name="main"
          xsl:use-attribute-sets="pagedef"
        >
          <fo:region-body region-name="main" margin-top="1in" margin-bottom="1in"/>
          <fo:region-after region-name="footer-main" extent="1in"/>
        </fo:simple-page-master>
        <fo:simple-page-master
          master-name="back"
          xsl:use-attribute-sets="pagedef"
        >
          <fo:region-body region-name="back" margin-top="1in" margin-bottom="1in"/>
          <fo:region-after region-name="footer-back" extent="1in"/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="first">
        <fo:static-content flow-name="footer-first">
          <fo:block xsl:use-attribute-sets="footercenter">
            <fo:basic-link external-destination="http://xml.apache.org/fop/">
              <fo:external-graphic src="foplogo.jpeg"/>
            </fo:basic-link>
          </fo:block>
        </fo:static-content> 
        <fo:flow flow-name="first">
          <xsl:apply-templates select="spec/header"/>
        </fo:flow>
      </fo:page-sequence>
      <fo:page-sequence master-reference="contents" initial-page-number="1" format="i">
        <fo:static-content flow-name="footer-contents">
          <fo:block xsl:use-attribute-sets="footercenter">
            <fo:basic-link external-destination="http://xml.apache.org/fop/">
              <fo:external-graphic src="foplogo.jpeg"/>
            </fo:basic-link>
          </fo:block>
        </fo:static-content> 
        <fo:flow flow-name="contents">
          <fo:block xsl:use-attribute-sets="heading1" id="contents" break-before="page">
            Contents
          </fo:block>
          <fox:outline internal-destination="contents">
            <fox:label>Contents</fox:label>
          </fox:outline>
          <xsl:apply-templates mode="contents"/>
          <xsl:apply-templates select="spec/body" mode="bookmark"/>
        </fo:flow>
      </fo:page-sequence>
      <fo:page-sequence master-reference="main" initial-page-number="1">
        <fo:static-content flow-name="footer-main">
          <fo:table table-layout="fixed">
            <fo:table-column column-width="5in"/>
            <fo:table-column column-width="1.5in"/>
            <fo:table-body>
              <fo:table-row>
                <fo:table-cell>
                  <fo:block xsl:use-attribute-sets="footerleft">
                    <fo:basic-link external-destination="http://xml.apache.org/fop/">
                      <fo:external-graphic src="foplogo.jpeg"/>
                    </fo:basic-link>
                  </fo:block>
                </fo:table-cell>
                <fo:table-cell>
                  <fo:block xsl:use-attribute-sets="footerright">
                    <fo:page-number/> of <fo:page-number-citation ref-id="end"/>
                  </fo:block>
                </fo:table-cell>
              </fo:table-row>
            </fo:table-body>
          </fo:table>
        </fo:static-content> 
        <fo:flow flow-name="main">
          <xsl:apply-templates select="spec/body"/>
        </fo:flow>
      </fo:page-sequence>
      <fo:page-sequence master-reference="back">
        <fo:static-content flow-name="footer-back">
          <fo:table table-layout="fixed">
            <fo:table-column column-width="5in"/>
            <fo:table-column column-width="1.5in"/>
            <fo:table-body>
              <fo:table-row>
                <fo:table-cell>
                  <fo:block xsl:use-attribute-sets="footerleft">
                    <fo:basic-link external-destination="http://xml.apache.org/fop/">
                      <fo:external-graphic src="foplogo.jpeg"/>
                    </fo:basic-link>
                  </fo:block>
                </fo:table-cell>
                <fo:table-cell>
                  <fo:block xsl:use-attribute-sets="footerright">
                    <fo:page-number/> of <fo:page-number-citation ref-id="end"/>
                  </fo:block>
                </fo:table-cell>
              </fo:table-row>
            </fo:table-body>
          </fo:table>
        </fo:static-content> 
        <fo:flow flow-name="back">
          <xsl:apply-templates select="spec/back" mode="bookmark"/>
          <xsl:apply-templates select="spec/back"/>
          <fo:block id="end"/>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
  </xsl:template> <!-- match="/" -->

  <!-- Contents Templates -->
  <xsl:template match="abstract" mode="contents"/>

  <xsl:template match="arg" mode="contents"/>

  <xsl:template match="authlist" mode="contents"/>

  <xsl:template match="author" mode="contents"/>

  <xsl:template match="back" mode="contents">
    <xsl:apply-templates mode="contents"/>
  </xsl:template> <!-- match="back"" mode="contents" -->

  <xsl:template match="back/div1" mode="contents">
    <fo:block xsl:use-attribute-sets="contents1">
      <xsl:choose>
        <xsl:when test="@id">
          <fo:basic-link internal-destination="{@id}" color="#000080">
            <xsl:number count="div1" from="back" format="A."/><xsl:text> </xsl:text><xsl:value-of select="head"/>
          </fo:basic-link>
          <fo:leader leader-pattern="dots"/>
          <fo:inline font-size="11pt"><fo:page-number-citation ref-id="{@id}"/></fo:inline>
        </xsl:when>
        <xsl:otherwise>
          <fo:basic-link internal-destination="{generate-id()}" color="#000080">
            <xsl:number count="div1" from="back" format="A."/><xsl:text> </xsl:text><xsl:value-of select="head"/>
          </fo:basic-link>
          <fo:leader leader-pattern="dots"/>
          <fo:inline font-size="11pt"><fo:page-number-citation ref-id="{generate-id()}"/></fo:inline>
        </xsl:otherwise>
      </xsl:choose>
    </fo:block>
    <xsl:apply-templates mode="contents"/>
  </xsl:template> <!-- match="back/div1"" mode="contents" -->

  <xsl:template match="back/div2" mode="contents">
    <fo:block xsl:use-attribute-sets="contents2">
      <xsl:choose>
        <xsl:when test="@id">
          <fo:basic-link internal-destination="{@id}" color="#000080">
            <xsl:number count="div1|inform-div1" from="back" format="A."/><xsl:number level="multiple" count="div2" from="back" format="1."/><xsl:text> </xsl:text><xsl:value-of select="head"/>
          </fo:basic-link>
          <fo:leader leader-pattern="dots"/>
          <fo:inline font-size="11pt"><fo:page-number-citation ref-id="{@id}"/></fo:inline>
        </xsl:when>
        <xsl:otherwise>
          <fo:basic-link internal-destination="{generate-id()}" color="#000080">
            <xsl:number count="div1|inform-div1" from="back" format="A."/><xsl:number level="multiple" count="div2" from="back" format="1."/><xsl:text> </xsl:text><xsl:value-of select="head"/>
          </fo:basic-link>
          <fo:leader leader-pattern="dots"/>
          <fo:inline font-size="11pt"><fo:page-number-citation ref-id="{generate-id()}"/></fo:inline>
        </xsl:otherwise>
      </xsl:choose>
    </fo:block>
  </xsl:template> <!-- match="back/div2"" mode="contents" -->

  <xsl:template match="bibl" mode="contents"/>

  <xsl:template match="bibref" mode="contents"/>

  <xsl:template match="blist" mode="contents"/>

  <xsl:template match="body" mode="contents">
    <xsl:apply-templates mode="contents"/>
  </xsl:template> <!-- match="body"" mode="contents" -->

  <xsl:template match="body/div1" mode="contents">
    <fo:block xsl:use-attribute-sets="contents1">
      <xsl:choose>
        <xsl:when test="@id">
          <fo:basic-link internal-destination="{@id}" color="#000080">
            <xsl:number count="div1" from="body" format="1."/><xsl:text> </xsl:text><xsl:value-of select="head"/>
          </fo:basic-link>
          <fo:leader leader-pattern="dots"/>
          <fo:inline font-size="11pt"><fo:page-number-citation ref-id="{@id}"/></fo:inline>
        </xsl:when>
        <xsl:otherwise>
          <fo:basic-link internal-destination="{generate-id()}" color="#000080">
            <xsl:number count="div1" from="body" format="1."/><xsl:text> </xsl:text><xsl:value-of select="head"/>
          </fo:basic-link>
          <fo:leader leader-pattern="dots"/>
          <fo:inline font-size="11pt"><fo:page-number-citation ref-id="{generate-id()}"/></fo:inline>
        </xsl:otherwise>
      </xsl:choose>
    </fo:block>
    <xsl:apply-templates mode="contents"/>
  </xsl:template> <!-- match="body/div1"" mode="contents" -->

  <xsl:template match="body/div1/div2" mode="contents">
    <fo:block xsl:use-attribute-sets="contents2">
      <xsl:choose>
        <xsl:when test="@id">
          <fo:basic-link internal-destination="{@id}" color="#000080">
            <xsl:number level="multiple" count="div1|div2" from="body" format="1."/><xsl:text> </xsl:text><xsl:value-of select="head"/>
          </fo:basic-link>
          <fo:leader leader-pattern="dots"/>
          <fo:inline font-size="11pt"><fo:page-number-citation ref-id="{@id}"/></fo:inline>
        </xsl:when>
        <xsl:otherwise>
          <fo:basic-link internal-destination="{generate-id()}" color="#000080">
            <xsl:number level="multiple" count="div1|div2" from="body" format="1."/><xsl:text> </xsl:text><xsl:value-of select="head"/>
          </fo:basic-link>
          <fo:leader leader-pattern="dots"/>
          <fo:inline font-size="11pt"><fo:page-number-citation ref-id="{generate-id()}"/></fo:inline>
        </xsl:otherwise>
      </xsl:choose>
    </fo:block>
    <xsl:apply-templates mode="contents"/>
  </xsl:template> <!-- match="body/div1/div2"" mode="contents" -->

  <xsl:template match="body/div1/div2/div3" mode="contents">
    <fo:block xsl:use-attribute-sets="contents3">
      <xsl:choose>
        <xsl:when test="@id">
          <fo:basic-link internal-destination="{@id}" color="#000080">
            <xsl:number level="multiple" count="div1|div2|div3" from="body" format="1."/><xsl:text> </xsl:text><xsl:value-of select="head"/>
          </fo:basic-link>
          <fo:leader leader-pattern="dots"/>
          <fo:inline font-size="11pt"><fo:page-number-citation ref-id="{@id}"/></fo:inline>
        </xsl:when>
        <xsl:otherwise>
          <fo:basic-link internal-destination="{generate-id()}" color="#000080">
            <xsl:number level="multiple" count="div1|div2|div3" from="body" format="1."/><xsl:text> </xsl:text><xsl:value-of select="head"/>
          </fo:basic-link>
          <fo:leader leader-pattern="dots"/>
          <fo:inline font-size="11pt"><fo:page-number-citation ref-id="{generate-id()}"/></fo:inline>
        </xsl:otherwise>
      </xsl:choose>
    </fo:block>
  </xsl:template> <!-- match="body/div1/div2/div3"" mode="contents" -->

  <xsl:template match="code" mode="contents"/>

  <xsl:template match="day" mode="contents"/>

  <xsl:template match="e:attribute" mode="contents"/>

  <xsl:template match="e:attribute-value-template" mode="contents"/>

  <xsl:template match="e:choice" mode="contents"/>

  <xsl:template match="e:constant" mode="contents"/>

  <xsl:template match="e:data-type" mode="contents"/>

  <xsl:template match="e:element" mode="contents"/>

  <xsl:template match="e:element-syntax" mode="contents"/>

  <xsl:template match="e:element-syntax-summary" mode="contents"/>

  <xsl:template match="e:in-category" mode="contents"/>

  <xsl:template match="e:model" mode="contents"/>

  <xsl:template match="e:sequence" mode="contents"/>

  <xsl:template match="e:text" mode="contents"/>

  <xsl:template match="eg" mode="contents"/>

  <xsl:template match="email" mode="contents"/>

  <xsl:template match="emph" mode="contents"/>

  <xsl:template match="function" mode="contents"/>

  <xsl:template match="head" mode="contents"/>

  <xsl:template match="header" mode="contents"/>

  <xsl:template match="inform-div1" mode="contents">
    <fo:block xsl:use-attribute-sets="contents1">
      <xsl:choose>
        <xsl:when test="@id">
          <fo:basic-link internal-destination="{@id}" color="#000080">
            <xsl:number count="div1|inform-div1" from="back" format="A."/><xsl:text> </xsl:text><xsl:value-of select="head"/>
          </fo:basic-link>
          <fo:leader leader-pattern="dots"/>
          <fo:inline font-size="11pt"><fo:page-number-citation ref-id="{@id}"/></fo:inline>
        </xsl:when>
        <xsl:otherwise>
          <fo:basic-link internal-destination="{generate-id()}" color="#000080">
            <xsl:number count="div1|inform-div1" from="back" format="A."/><xsl:text> </xsl:text><xsl:value-of select="head"/>
          </fo:basic-link>
          <fo:leader leader-pattern="dots"/>
          <fo:inline font-size="11pt"><fo:page-number-citation ref-id="{generate-id()}"/></fo:inline>
        </xsl:otherwise>
      </xsl:choose>
    </fo:block>
    <xsl:apply-templates mode="contents"/>
  </xsl:template> <!-- match="inform-div1"" mode="contents" -->

  <xsl:template match="inform-div1/div2" mode="contents">
    <fo:block xsl:use-attribute-sets="contents2">
      <xsl:choose>
        <xsl:when test="@id">
          <fo:basic-link internal-destination="{@id}" color="#000080">
            <xsl:number count="div1|inform-div1" from="back" format="A."/><xsl:number level="multiple" count="div2" from="back" format="1."/><xsl:text> </xsl:text><xsl:value-of select="head"/>
          </fo:basic-link>
          <fo:leader leader-pattern="dots"/>
          <fo:inline font-size="11pt"><fo:page-number-citation ref-id="{@id}"/></fo:inline>
        </xsl:when>
        <xsl:otherwise>
          <fo:basic-link internal-destination="{generate-id()}" color="#000080">
            <xsl:number count="div1|inform-div1" from="back" format="A."/><xsl:number level="multiple" count="div2" from="back" format="1."/><xsl:text> </xsl:text><xsl:value-of select="head"/>
          </fo:basic-link>
          <fo:leader leader-pattern="dots"/>
          <fo:inline font-size="11pt"><fo:page-number-citation ref-id="{generate-id()}"/></fo:inline>
        </xsl:otherwise>
      </xsl:choose>
    </fo:block>
  </xsl:template> <!-- match="inform-div1/div2"" mode="contents" -->

  <xsl:template match="item" mode="contents"/>

  <xsl:template match="latestloc" mode="contents"/>

  <xsl:template match="lhs" mode="contents"/>

  <xsl:template match="loc" mode="contents"/>

  <xsl:template match="member" mode="contents"/>

  <xsl:template match="month" mode="contents"/>

  <xsl:template match="name" mode="contents"/>

  <xsl:template match="note" mode="contents"/>

  <xsl:template match="nt" mode="contents"/>

  <xsl:template match="olist" mode="contents"/>

  <xsl:template match="orglist" mode="contents"/>

  <xsl:template match="p" mode="contents"/>

  <xsl:template match="prevlocs" mode="contents"/>

  <xsl:template match="prod" mode="contents"/>

  <xsl:template match="prodgroup" mode="contents"/>

  <xsl:template match="proto" mode="contents"/>

  <xsl:template match="pubdate" mode="contents"/>

  <xsl:template match="publoc" mode="contents"/>

  <xsl:template match="quote" mode="contents"/>

  <xsl:template match="rhs" mode="contents"/>

  <xsl:template match="scrap" mode="contents"/>

  <xsl:template match="sitem" mode="contents"/>

  <xsl:template match="slist" mode="contents"/>

  <xsl:template match="specref" mode="contents"/>

  <xsl:template match="status" mode="contents"/>

  <xsl:template match="term" mode="contents"/>

  <xsl:template match="termdef" mode="contents"/>

  <xsl:template match="termref" mode="contents"/>

  <xsl:template match="title" mode="contents"/>

  <xsl:template match="ulist" mode="contents"/>

  <xsl:template match="var" mode="contents"/>

  <xsl:template match="version" mode="contents"/>

  <xsl:template match="w3c-doctype" mode="contents"/>

  <xsl:template match="xfunction" mode="contents"/>

  <xsl:template match="xnt" mode="contents"/>

  <xsl:template match="xspecref" mode="contents"/>

  <xsl:template match="xtermref" mode="contents"/>

  <xsl:template match="year" mode="contents"/>

  <!-- Bookmark Templates -->
  <xsl:template match="abstract" mode="bookmark"/>

  <xsl:template match="arg" mode="bookmark"/>

  <xsl:template match="authlist" mode="bookmark"/>

  <xsl:template match="author" mode="bookmark"/>

  <xsl:template match="back" mode="bookmark">
    <xsl:apply-templates mode="bookmark"/>
  </xsl:template><!-- match="back" mode="bookmark" -->

  <xsl:template match="back/div1" mode="bookmark">
    <xsl:choose>
      <xsl:when test="@id">
        <fox:outline internal-destination="{@id}">
          <fox:label><xsl:number count="div1|inform-div1" from="back" format="A."/><xsl:text> </xsl:text><xsl:value-of select="head"/></fox:label>
          <xsl:apply-templates mode="bookmark"/>
        </fox:outline>
      </xsl:when>
      <xsl:otherwise>
        <fox:outline internal-destination="{generate-id()}">
          <fox:label><xsl:number count="div1|inform-div1" from="back" format="A."/><xsl:text> </xsl:text><xsl:value-of select="head"/></fox:label>
          <xsl:apply-templates mode="bookmark"/>
        </fox:outline>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template><!-- match="back/div1" mode="bookmark" -->

  <xsl:template match="back/div2" mode="bookmark">
    <xsl:choose>
      <xsl:when test="@id">
        <fox:outline internal-destination="{@id}">
          <fox:label><xsl:number count="div1|inform-div1" from="back" format="A."/><xsl:number level="multiple" count="div2" from="back" format="1."/><xsl:text> </xsl:text><xsl:value-of select="head"/></fox:label>
          <xsl:apply-templates mode="bookmark"/>
        </fox:outline>
      </xsl:when>
      <xsl:otherwise>
        <fox:outline internal-destination="{generate-id()}">
          <fox:label><xsl:number count="div1|inform-div1" from="back" format="A."/><xsl:number level="multiple" count="div2" from="back" format="1."/><xsl:text> </xsl:text><xsl:value-of select="head"/></fox:label>
          <xsl:apply-templates mode="bookmark"/>
        </fox:outline>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template><!-- match="back/div2" mode="bookmark" -->

  <xsl:template match="bibl" mode="bookmark"/>

  <xsl:template match="bibref" mode="bookmark"/>

  <xsl:template match="blist" mode="bookmark"/>

  <xsl:template match="body" mode="bookmark">
    <xsl:apply-templates mode="bookmark"/>
  </xsl:template><!-- match="body" mode="bookmark" -->

  <xsl:template match="body/div1" mode="bookmark">
    <xsl:choose>
      <xsl:when test="@id">
        <fox:outline internal-destination="{@id}">
          <fox:label><xsl:number count="div1" from="body" format="1."/><xsl:text> </xsl:text><xsl:value-of select="head"/></fox:label>
          <xsl:apply-templates mode="bookmark"/>
        </fox:outline>
      </xsl:when>
      <xsl:otherwise>
        <fox:outline internal-destination="{generate-id()}">
          <fox:label><xsl:number count="div1" from="body" format="1."/><xsl:text> </xsl:text><xsl:value-of select="head"/></fox:label>
          <xsl:apply-templates mode="bookmark"/>
        </fox:outline>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template><!-- match="body/div1" mode="bookmark" -->

  <xsl:template match="body/div1/div2" mode="bookmark">
    <xsl:choose>
      <xsl:when test="@id">
        <fox:outline internal-destination="{@id}">
          <fox:label><xsl:number level="multiple" count="div1|div2" from="body" format="1."/><xsl:text> </xsl:text><xsl:value-of select="head"/></fox:label>
          <xsl:apply-templates mode="bookmark"/>
        </fox:outline>
      </xsl:when>
      <xsl:otherwise>
        <fox:outline internal-destination="{generate-id()}">
          <fox:label><xsl:number level="multiple" count="div1|div2" from="body" format="1."/><xsl:text> </xsl:text><xsl:value-of select="head"/></fox:label>
          <xsl:apply-templates mode="bookmark"/>
        </fox:outline>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template><!-- match="body/div1/div2" mode="bookmark" -->

  <xsl:template match="body/div1/div2/div3" mode="bookmark">
    <xsl:choose>
      <xsl:when test="@id">
        <fox:outline internal-destination="{@id}">
          <fox:label><xsl:number level="multiple" count="div1|div2|div3" from="body" format="1."/><xsl:text> </xsl:text><xsl:value-of select="head"/></fox:label>
          <xsl:apply-templates mode="bookmark"/>
        </fox:outline>
      </xsl:when>
      <xsl:otherwise>
        <fox:outline internal-destination="{generate-id()}">
          <fox:label><xsl:number level="multiple" count="div1|div2|div3" from="body" format="1."/><xsl:text> </xsl:text><xsl:text> </xsl:text><xsl:value-of select="head"/></fox:label>
          <xsl:apply-templates mode="bookmark"/>
        </fox:outline>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template><!-- match="body/div1/div2/div3" mode="bookmark" -->

  <xsl:template match="code" mode="bookmark"/>

  <xsl:template match="day" mode="bookmark"/>

  <xsl:template match="e:attribute" mode="bookmark"/>

  <xsl:template match="e:attribute-value-template" mode="bookmark"/>

  <xsl:template match="e:choice" mode="bookmark"/>

  <xsl:template match="e:constant" mode="bookmark"/>

  <xsl:template match="e:data-type" mode="bookmark"/>

  <xsl:template match="e:element" mode="bookmark"/>

  <xsl:template match="e:element-syntax" mode="bookmark"/>

  <xsl:template match="e:element-syntax-summary" mode="bookmark"/>

  <xsl:template match="e:in-category" mode="bookmark"/>

  <xsl:template match="e:model" mode="bookmark"/>

  <xsl:template match="e:sequence" mode="bookmark"/>

  <xsl:template match="e:text" mode="bookmark"/>

  <xsl:template match="eg" mode="bookmark"/>

  <xsl:template match="email" mode="bookmark"/>

  <xsl:template match="emph" mode="bookmark"/>

  <xsl:template match="function" mode="bookmark"/>

  <xsl:template match="head" mode="bookmark"/>

  <xsl:template match="header" mode="bookmark"/>

  <xsl:template match="inform-div1" mode="bookmark">
    <xsl:choose>
      <xsl:when test="@id">
        <fox:outline internal-destination="{@id}">
          <fox:label><xsl:number count="div1|inform-div1" from="back" format="A."/><xsl:text> </xsl:text><xsl:value-of select="head"/></fox:label>
          <xsl:apply-templates mode="bookmark"/>
        </fox:outline>
      </xsl:when>
      <xsl:otherwise>
        <fox:outline internal-destination="{generate-id()}">
          <fox:label><xsl:number count="div1|inform-div1" from="back" format="A."/><xsl:text> </xsl:text><xsl:value-of select="head"/></fox:label>
          <xsl:apply-templates mode="bookmark"/>
        </fox:outline>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template><!-- match="inform-div1" mode="bookmark" -->

  <xsl:template match="inform-div1/div2" mode="bookmark">
    <xsl:choose>
      <xsl:when test="@id">
        <fox:outline internal-destination="{@id}">
          <fox:label><xsl:number count="div1|inform-div1" from="back" format="A."/><xsl:number level="multiple" count="div2" from="back" format="1."/><xsl:text> </xsl:text><xsl:value-of select="head"/></fox:label>
          <xsl:apply-templates mode="bookmark"/>
        </fox:outline>
      </xsl:when>
      <xsl:otherwise>
        <fox:outline internal-destination="{generate-id()}">
          <fox:label><xsl:number count="div1|inform-div1" from="back" format="A."/><xsl:number level="multiple" count="div2" from="back" format="1."/><xsl:text> </xsl:text><xsl:value-of select="head"/></fox:label>
          <xsl:apply-templates mode="bookmark"/>
        </fox:outline>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template><!-- match="inform-div1/div2" mode="bookmark" -->

  <xsl:template match="item" mode="bookmark"/>

  <xsl:template match="latestloc" mode="bookmark"/>

  <xsl:template match="lhs" mode="bookmark"/>

  <xsl:template match="loc" mode="bookmark"/>

  <xsl:template match="member" mode="bookmark"/>

  <xsl:template match="month" mode="bookmark"/>

  <xsl:template match="name" mode="bookmark"/>

  <xsl:template match="note" mode="bookmark"/>

  <xsl:template match="nt" mode="bookmark"/>

  <xsl:template match="olist" mode="bookmark"/>

  <xsl:template match="orglist" mode="bookmark"/>

  <xsl:template match="p" mode="bookmark"/>

  <xsl:template match="prevlocs" mode="bookmark"/>

  <xsl:template match="prod" mode="bookmark"/>

  <xsl:template match="prodgroup" mode="bookmark"/>

  <xsl:template match="proto" mode="bookmark"/>

  <xsl:template match="pubdate" mode="bookmark"/>

  <xsl:template match="publoc" mode="bookmark"/>

  <xsl:template match="quote" mode="bookmark"/>

  <xsl:template match="rhs" mode="bookmark"/>

  <xsl:template match="scrap" mode="bookmark"/>

  <xsl:template match="sitem" mode="bookmark"/>

  <xsl:template match="slist" mode="bookmark"/>

  <xsl:template match="specref" mode="bookmark"/>

  <xsl:template match="status" mode="bookmark"/>

  <xsl:template match="term" mode="bookmark"/>

  <xsl:template match="termdef" mode="bookmark"/>

  <xsl:template match="termref" mode="bookmark"/>

  <xsl:template match="title" mode="bookmark"/>

  <xsl:template match="ulist" mode="bookmark"/>

  <xsl:template match="var" mode="bookmark"/>

  <xsl:template match="version" mode="bookmark"/>

  <xsl:template match="w3c-doctype" mode="bookmark"/>

  <xsl:template match="xfunction" mode="bookmark"/>

  <xsl:template match="xnt" mode="bookmark"/>

  <xsl:template match="xspecref" mode="bookmark"/>

  <xsl:template match="xtermref" mode="bookmark"/>

  <xsl:template match="year" mode="bookmark"/>

  <!-- Body Templates -->

  <xsl:template match="abstract">
    <fo:block xsl:use-attribute-sets="heading3" break-before="page">Abstract</fo:block>
    <xsl:apply-templates/>
  </xsl:template> <!-- match="abstract" -->

  <xsl:template match="affiliation"/>
    
  <xsl:template match="arg">
    <fo:inline font-style="italic"><xsl:value-of select="@type"/><xsl:if test="occur='opt'">?</xsl:if></fo:inline><xsl:if test="not(position()=last())">, </xsl:if>
  </xsl:template> <!-- match="arg" -->

  <xsl:template match="authlist">
    <xsl:apply-templates/>
    <!-- I couldn't find this material in the XML file anywhere, so I hard-coded it into the stylesheet. JB -->
    <fo:block xsl:use-attribute-sets="legalfirst"><fo:basic-link external-destination="http://www.w3.org/Consortium/Legal/ipr-notice-20000612#Copyright" color="darkblue">Copyright</fo:basic-link> &#169; 1999 <fo:basic-link external-destination="http://www.w3.org" color="darkblue">W3C</fo:basic-link>&#174; (<fo:basic-link external-destination="http:www.lcs.mit.edu" color="darkblue">MIT</fo:basic-link>, <fo:basic-link external-destination="http:www.inria.fr" color="darkblue">INRIA</fo:basic-link>, <fo:basic-link external-destination="http:www.keio.ac.jp" color="darkblue">Keio</fo:basic-link>), All Rights Reserved.</fo:block>
    <fo:block xsl:use-attribute-sets="legal">W3C <fo:basic-link external-destination="http://www.w3.org/Consortium/Legal/ipr-notice-20000612#Legal_Disclaimer" color="darkblue">liability</fo:basic-link>, <fo:basic-link external-destination="http://www.w3.org/Consortium/Legal/ipr-notice-20000612#W3C_Trademarks" color="darkblue">trademark</fo:basic-link>, <fo:basic-link external-destination="http://www.w3.org/Consortium/Legal/copyright-documents-19990405" color="darkblue">document use</fo:basic-link>, and <fo:basic-link external-destination="http://www.w3.org/Consortium/Legal/copyright-software-19980720" color="darkblue">software licensing rules</fo:basic-link> apply.</fo:block>
  </xsl:template> <!-- match="authlist" -->

  <xsl:template match="author">
    <fo:block xsl:use-attribute-sets="body">Author:</fo:block>
    <fo:block xsl:use-attribute-sets="bodyindent"><xsl:apply-templates/></fo:block>
  </xsl:template> <!-- match="author" -->

  <xsl:template match="back">
    <xsl:apply-templates/>
  </xsl:template> <!-- match="back" -->

  <xsl:template match="back/div1">
    <xsl:apply-templates/>
  </xsl:template> <!-- match="back/div1" -->

  <xsl:template match="back/div1/head">
    <fo:block xsl:use-attribute-sets="heading1">
      <xsl:choose>
        <xsl:when test="../@id">
          <xsl:attribute name="id"><xsl:value-of select="../@id"/></xsl:attribute>
        </xsl:when>
        <xsl:otherwise>
          <xsl:attribute name="id"><xsl:value-of select="generate-id(..)"/></xsl:attribute>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:number count="div1" from="back" format="A."/><xsl:text> </xsl:text><xsl:apply-templates/>
    </fo:block>
  </xsl:template> <!-- match="back/div1/head" -->

  <xsl:template match="back/div1/head" mode="ref">
    <fo:inline font-weight="bold">
      Appendix <xsl:number count="div1" from="back" format="A."/><xsl:text> </xsl:text><xsl:apply-templates/>
    </fo:inline>
  </xsl:template> <!-- match="back/div1/head" mode="ref" -->

  <xsl:template match="back/div2">
    <xsl:apply-templates/>
  </xsl:template> <!-- match="back/div2" -->

  <xsl:template match="back/div1/div2/head">
    <fo:block xsl:use-attribute-sets="heading2">
      <xsl:choose>
        <xsl:when test="../@id">
          <xsl:attribute name="id"><xsl:value-of select="../@id"/></xsl:attribute>
        </xsl:when>
        <xsl:otherwise>
          <xsl:attribute name="id"><xsl:value-of select="generate-id()"/></xsl:attribute>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:number count="div1" from="body" format="A."/><xsl:number level="multiple" count="div2" from="back" format="1."/><xsl:text> </xsl:text><xsl:apply-templates/>
    </fo:block>
  </xsl:template> <!-- match="back/div1/div2/head" -->

  <xsl:template match="back/div1/div2/head" mode="ref">
    <fo:inline font-weight="bold">
      <xsl:number count="div1" from="body" format="A."/><xsl:number level="multiple" count="div2" from="back" format="1."/><xsl:text> </xsl:text><xsl:apply-templates/>
    </fo:inline>
  </xsl:template> <!-- match="back/div1/div2/head" mode="ref" -->

  <xsl:template match="bibl">
    <fo:block xsl:use-attribute-sets="body" id="{@id}">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template> <!-- match="bibl" -->

  <xsl:template match="bibref">
    <xsl:variable name="ref" select="@ref"/>
    [<fo:basic-link internal-destination="{@ref}" color="#000080"><xsl:value-of select="//bibl[@id=$ref]/@key"/></fo:basic-link>]
  </xsl:template> <!-- match="bibref" -->

  <xsl:template match="blist">
    <xsl:apply-templates/>
  </xsl:template> <!-- match="blist" -->

  <xsl:template match="body">
    <xsl:apply-templates/>
  </xsl:template> <!-- match="body" -->

  <xsl:template match="body/div1">
    <xsl:apply-templates/>
  </xsl:template> <!-- match="div1" -->

  <xsl:template match="body/div1/head">
    <fo:block xsl:use-attribute-sets="heading1">
      <xsl:choose>
        <xsl:when test="../@id">
          <xsl:attribute name="id"><xsl:value-of select="../@id"/></xsl:attribute>
        </xsl:when>
        <xsl:otherwise>
          <xsl:attribute name="id"><xsl:value-of select="generate-id(..)"/></xsl:attribute>
        </xsl:otherwise>
      </xsl:choose>
      
      <xsl:number count="div1" from="body" format="1."/><xsl:text> </xsl:text><xsl:apply-templates/>
    </fo:block>
  </xsl:template> <!-- match="body/div1/head" -->

  <xsl:template match="body/div1/head" mode="ref">
    <fo:inline font-weight="bold">
      <xsl:number count="div1" from="body" format="1."/><xsl:text> </xsl:text><xsl:apply-templates/>
    </fo:inline>
  </xsl:template> <!-- match="body/div1/head" mode="ref" -->

  <xsl:template match="body/div1/div2">
    <xsl:apply-templates/>
  </xsl:template> <!-- match="body/div1/div2" -->

  <xsl:template match="body/div1/div2/head">
    <fo:block xsl:use-attribute-sets="heading2">
      <xsl:choose>
        <xsl:when test="../@id">
          <xsl:attribute name="id"><xsl:value-of select="../@id"/></xsl:attribute>
        </xsl:when>
        <xsl:otherwise>
          <xsl:attribute name="id"><xsl:value-of select="generate-id(..)"/></xsl:attribute>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:number level="multiple" count="div1|div2" from="body" format="1."/><xsl:text> </xsl:text><xsl:apply-templates/>
    </fo:block>
  </xsl:template> <!-- match="body/div1/div2/head" -->

  <xsl:template match="body/div1/div2/head" mode="ref">
    <fo:inline font-weight="bold">
      <xsl:number level="multiple" count="div1|div2" from="body" format="1."/><xsl:text> </xsl:text><xsl:apply-templates/>
    </fo:inline>
  </xsl:template> <!-- match="body/div1/div2/head" mode="ref" -->

  <xsl:template match="body/div1/div2/div3">
    <xsl:apply-templates/>
  </xsl:template> <!-- match="body/div1/div2/div3" -->

  <xsl:template match="body/div1/div2/div3/head">
    <fo:block xsl:use-attribute-sets="heading3">
      <xsl:choose>
        <xsl:when test="../@id">
          <xsl:attribute name="id"><xsl:value-of select="../@id"/></xsl:attribute>
        </xsl:when>
        <xsl:otherwise>
          <xsl:attribute name="id"><xsl:value-of select="generate-id(..)"/></xsl:attribute>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:number level="multiple" count="div1|div2|div3" from="body" format="1."/><xsl:text> </xsl:text><xsl:apply-templates/>
    </fo:block>
  </xsl:template> <!-- match="body/div1/div2/div3/head" -->

  <xsl:template match="body/div1/div2/div3/head" mode="ref">
    <fo:inline font-weight="bold">
      <xsl:number level="multiple" count="div1|div2|div3" from="body" format="1."/><xsl:text> </xsl:text><xsl:apply-templates/>
    </fo:inline>
  </xsl:template> <!-- match="body/div1/div2/div3/head" mode="ref" -->

  <xsl:template match="code">
    <fo:inline font-family="monospace"><xsl:apply-templates/></fo:inline>
  </xsl:template><!-- match="code" -->

  <xsl:template match="day">
    <xsl:text> </xsl:text><xsl:apply-templates/>
  </xsl:template><!-- match="day" -->

  <xsl:template match="e:attribute">
    <fo:block xsl:use-attribute-sets="codeblock">
      <xsl:choose>
        <xsl:when test="@required='yes'">
          <fo:inline font-weight="bold"><xsl:value-of select="@name"/></fo:inline> = <xsl:apply-templates/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="@name"/> = <xsl:apply-templates/>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:if test="not(following-sibling::e:attribute)">
        <xsl:if test="../e:empty">/</xsl:if>&gt;
      </xsl:if>
    </fo:block>
  </xsl:template> <!-- match="e:attribute" -->

  <xsl:template match="e:attribute-value-template">
    {<xsl:apply-templates/>}
  </xsl:template> <!-- match="e:attribute-value-template" -->

  <xsl:template match="e:choice">
    <fo:block xsl:use-attribute-sets="codeblock">&lt;!-- Content: (<xsl:apply-templates/>)* --&gt;</fo:block>
  </xsl:template> <!-- match="e:choice" -->

  <xsl:template match="e:constant">
    &quot;<xsl:value-of select="@value"/>&quot;<xsl:if test="following-sibling::e:constant"> | </xsl:if>
  </xsl:template> <!-- match="e:constant" -->

  <xsl:template match="e:data-type">
    <fo:inline font-style="italic"><xsl:value-of select="@name"/></fo:inline>
  </xsl:template> <!-- match="e:data-type" -->

  <xsl:template match="e:element">
    <xsl:choose>
      <xsl:when test="parent::e:element-syntax">
        <fo:block xsl:use-attribute-sets="codeblock">&lt;!-- Content: <xsl:value-of select="@name"/><xsl:if test="@repeat='zero-or-one'">?</xsl:if><xsl:if test="@repeat='zero-or-more'">*</xsl:if><xsl:if test="@repeat='one-or-more'">+</xsl:if><xsl:if test="following-sibling::e:element">, </xsl:if><xsl:if test="following-sibling::e:model">, </xsl:if> --&gt;</fo:block>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="@name"/><xsl:if test="@repeat='zero-or-one'">?</xsl:if><xsl:if test="@repeat='zero-or-more'">*</xsl:if><xsl:if test="@repeat='one-or-more'">+</xsl:if><xsl:if test="following-sibling::e:element">, </xsl:if><xsl:if test="following-sibling::e:model">, </xsl:if>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template> <!-- match="e:element" -->

  <xsl:template match="e:element-syntax">
    <fo:table table-layout="fixed" border-width="1" border-color="grey" border-style="solid" space-after.optimum="6pt">
      <fo:table-column column-width="6.5in"/>
      <fo:table-body>
        <fo:table-row>
          <fo:table-cell padding="3pt">
            <xsl:call-template name="make-listing"/>
          </fo:table-cell>
        </fo:table-row>
      </fo:table-body>
    </fo:table>
  </xsl:template> <!-- match="e:element-syntax" -->

  <xsl:template match="e:element-syntax-summary">
    <xsl:for-each select="//e:element-syntax[e:in-category]">
      <xsl:sort select="@name"/>
      <xsl:call-template name="make-listing"/>
      <xsl:if test="not(position()=last())">
        <fo:block xsl:use-attribute-sets="body">
          <fo:leader xsl:use-attribute-sets="leader"/>
        </fo:block>
      </xsl:if>
    </xsl:for-each>
  </xsl:template> <!-- match="e:element-syntax-summary" -->
  
  <xsl:template match="e:empty"/>

  <xsl:template match="e:in-category">
    <fo:block xsl:use-attribute-sets="codeblock">&lt;!-- Category: <fo:inline font-style="italic"><xsl:value-of select="@name"/></fo:inline>--&gt;</fo:block>
  </xsl:template> <!-- match="e:in-category" -->

  <xsl:template match="e:model">
    <xsl:choose>
      <xsl:when test="parent::e:element-syntax">
        <fo:block xsl:use-attribute-sets="codeblock">&lt;!-- Content: <fo:inline font-style="italic"><xsl:value-of select="@name"/> --&gt;</fo:inline></fo:block>
      </xsl:when>
      <xsl:otherwise>
        <fo:inline font-style="italic"><xsl:value-of select="@name"/></fo:inline>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template> <!-- match="e:model" -->

  <xsl:template match="e:sequence">
    <fo:block xsl:use-attribute-sets="codeblock">&lt;!-- Content: (<xsl:apply-templates/>) --&gt;</fo:block>
  </xsl:template> <!-- match="e:sequence" -->

  <xsl:template match="e:text">
    <fo:block xsl:use-attribute-sets="codeblock">&lt;!-- Content: #PCDATA --&gt;</fo:block>
  </xsl:template> <!-- match="e:text" -->

  <xsl:template match="eg">
    <fo:block xsl:use-attribute-sets="egblock">
      <xsl:if test="@role='error'">
        <xsl:attribute name="color">#C00000</xsl:attribute>
      </xsl:if>
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>

  <xsl:template match="email">
    <fo:inline color="darkblue">&lt;<fo:basic-link external-destination="{@href}"><xsl:value-of select="."/></fo:basic-link>&gt;</fo:inline>
  </xsl:template> <!-- match="email" -->

  <xsl:template match="emph">
    <fo:inline font-style="italic"><xsl:apply-templates/></fo:inline>
  </xsl:template> <!-- match="emph" -->

  <xsl:template match="function">
    <fo:basic-link internal-destination="function-{.}" color="#000080"><xsl:value-of select="."/></fo:basic-link>
  </xsl:template> <!-- match="function" -->

  <xsl:template match="header">
    <fo:block xsl:use-attribute-sets="logo"><fo:external-graphic src="http://www.w3.org/Icons/WWW/w3c_home"/></fo:block>
    <xsl:apply-templates select="*[not(self::status) and not(self::abstract)]"/>
    <xsl:apply-templates select="abstract"/>
    <xsl:apply-templates select="status"/>
    <!-- These shenanigans were necessary to flip the order of abstract and status. JB -->
  </xsl:template> <!-- match="header" -->

  <xsl:template match="inform-div1">
    <xsl:apply-templates/>
  </xsl:template> <!-- match="inform-div1" -->

  <xsl:template match="inform-div1/head">
    <fo:block xsl:use-attribute-sets="heading1">
      <xsl:choose>
        <xsl:when test="../@id">
          <xsl:attribute name="id"><xsl:value-of select="../@id"/></xsl:attribute>
        </xsl:when>
        <xsl:otherwise>
          <xsl:attribute name="id"><xsl:value-of select="generate-id(..)"/></xsl:attribute>
        </xsl:otherwise>
      </xsl:choose>
      Appendix <xsl:number count="div1|inform-div1" from="back" format="A."/><xsl:text> </xsl:text><xsl:apply-templates/>
    </fo:block>
  </xsl:template> <!-- match="inform-div1" -->

  <xsl:template match="inform-div1/div2">
    <xsl:apply-templates/>
  </xsl:template> <!-- match="inform-div1" -->

  <xsl:template match="inform-div1/div2/head">
    <fo:block xsl:use-attribute-sets="heading2">
      <xsl:choose>
        <xsl:when test="../@id">
          <xsl:attribute name="id"><xsl:value-of select="../@id"/></xsl:attribute>
        </xsl:when>
        <xsl:otherwise>
          <xsl:attribute name="id"><xsl:value-of select="generate-id(..)"/></xsl:attribute>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:number count="div1|inform-div1" from="back" format="A."/><xsl:number level="multiple" count="div2" from="back" format="1."/><xsl:text> </xsl:text><xsl:apply-templates/>
    </fo:block>
  </xsl:template> <!-- match="inform-div1" -->

  <xsl:template match="language"/>

  <xsl:template match="langusage"/>

  <xsl:template match="latestloc">
    <fo:block xsl:use-attribute-sets="body">Latest version:</fo:block>
    <fo:block xsl:use-attribute-sets="bodyindent"><xsl:apply-templates/></fo:block>
  </xsl:template> <!-- match="latestloc" -->

  <xsl:template match="lhs">
    <fo:block xsl:use-attribute-sets="body" text-align="right"><xsl:value-of select="."/></fo:block>
  </xsl:template> <!-- match="lhs" -->

  <xsl:template match="loc">
    <fo:basic-link external-destination="{@href}" color="#000080">
      <xsl:apply-templates/>
    </fo:basic-link>
  </xsl:template> <!-- match="loc" -->

  <xsl:template name="make-listing">
    <xsl:apply-templates select="e:in-category"/>
    <xsl:choose>
      <xsl:when test="e:attribute and e:empty">
        <!-- Let the e:attribute template close the element.-->
        <fo:block xsl:use-attribute-sets="codeblock" font-weight="bold">&lt;xsl:<xsl:value-of select="@name"/></fo:block>
        <xsl:apply-templates select="*[not(self::e:in-category)]"/>
      </xsl:when>
      <xsl:when test="e:attribute and not(e:empty)">
        <!-- Let the e:attribute template close the tag. Then process the children and close the element. -->
        <fo:block xsl:use-attribute-sets="codeblock" font-weight="bold">&lt;xsl:<xsl:value-of select="@name"/></fo:block>
        <xsl:apply-templates select="*[not(self::e:in-category)]"/>
        <fo:block xsl:use-attribute-sets="codeblock" font-weight="bold">&lt;/xsl:<xsl:value-of select="@name"/>&gt;</fo:block>
      </xsl:when>
      <xsl:when test="not(e:attribute) and e:empty">
        <!-- Just close the element. -->
        <fo:block xsl:use-attribute-sets="codeblock" font-weight="bold">&lt;xsl:<xsl:value-of select="@name"/>/&gt;</fo:block>
      </xsl:when>
      <xsl:when test="not(e:attribute) and not(e:empty)">
        <!-- Close the tag, process the children, and close the element. -->
        <fo:block xsl:use-attribute-sets="codeblock" font-weight="bold">&lt;xsl:<xsl:value-of select="@name"/>&gt;</fo:block>
        <xsl:apply-templates select="*[not(self::e:in-category)]"/>
        <fo:block xsl:use-attribute-sets="codeblock" font-weight="bold">&lt;/xsl:<xsl:value-of select="@name"/>&gt;</fo:block>
      </xsl:when>
      <xsl:otherwise>
        <xsl:message>Ruh roh! Troubles at <xsl:value-of select="ancestor::e:element-syntax/@name"/></xsl:message>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template> <!-- name="make-listing" -->

  <xsl:template match="member">
    <xsl:value-of select="name"/>, <xsl:value-of select="affiliation"/><xsl:if test="role"> (<xsl:value-of select="role"/>)</xsl:if>;
  </xsl:template> <!-- match="member" -->

  <xsl:template match="month">
    <xsl:text> </xsl:text><xsl:apply-templates/>
  </xsl:template> <!-- match="month" -->

  <xsl:template match="name">
    <xsl:value-of select="."/><xsl:text> </xsl:text>
  </xsl:template> <!-- match="name" -->

  <xsl:template match="note">
    <fo:table table-layout="fixed">
      <fo:table-column column-width=".5in"/>
      <fo:table-column column-width="6in"/>
      <fo:table-body>
        <fo:table-row>
          <fo:table-cell>
            <fo:block xsl:use-attribute-sets="body">
              <fo:inline font-weight="bold">Note:</fo:inline>
            </fo:block>
          </fo:table-cell>
          <fo:table-cell>
            <xsl:apply-templates/>
          </fo:table-cell>
        </fo:table-row>
      </fo:table-body>
    </fo:table>
  </xsl:template> <!-- match="note" -->

  <xsl:template match="nt">
    <fo:basic-link internal-destination="{@def}" color="#000080"><xsl:value-of select="."/></fo:basic-link>
  </xsl:template> <!-- match="nt" -->

  <xsl:template match="olist">
    <fo:list-block>
      <xsl:apply-templates/>
    </fo:list-block>
  </xsl:template> <!-- match="olist" -->

  <xsl:template match="olist/item">
    <fo:list-item>
      <fo:list-item-label end-indent="label-end()">
        <fo:block xsl:use-attribute-sets="listbody" relative-align="before"><xsl:number format="1."/></fo:block>
      </fo:list-item-label>
      <fo:list-item-body start-indent="body-start()">
        <xsl:apply-templates/>
      </fo:list-item-body>
    </fo:list-item>
  </xsl:template> <!-- match="ulist/item" -->

  <xsl:template match="orglist">
    <fo:block xsl:use-attribute-sets="body"><xsl:apply-templates/></fo:block>
  </xsl:template> <!-- match="orglist" -->

  <xsl:template match="p">
    <fo:block xsl:use-attribute-sets="body"><xsl:apply-templates/></fo:block>
  </xsl:template> <!-- match="p" -->

  <xsl:template match="prevlocs">
    <fo:block xsl:use-attribute-sets="body">Previous versions:</fo:block>
    <xsl:for-each select="loc">
      <fo:block xsl:use-attribute-sets="tightlist">
        <xsl:if test="position() = 1"><xsl:attribute name="space-before.optimum">3pt</xsl:attribute></xsl:if>
        <xsl:apply-templates select="."/>
      </fo:block>
    </xsl:for-each>
  </xsl:template> <!-- match="prevlocs" -->

  <xsl:template match="prod">
    <fo:table-row>
      <fo:table-cell><fo:block xsl:use-attribute-sets="body">[<xsl:number/>]</fo:block></fo:table-cell>
      <fo:table-cell><xsl:apply-templates select="lhs"/></fo:table-cell>
      <fo:table-cell><fo:block xsl:use-attribute-sets="body">&#160;</fo:block></fo:table-cell>
      <fo:table-cell><xsl:apply-templates select="rhs"/></fo:table-cell>
    </fo:table-row>
  </xsl:template> <!-- match="prod" -->

  <xsl:template match="prodgroup">
    <fo:table table-layout="fixed">
      <fo:table-column column-width=".5in"/>
      <fo:table-column column-width="2in"/>
      <fo:table-column column-width=".25in"/>
      <fo:table-column column-width="3.75in"/>
      <fo:table-body>
        <xsl:apply-templates/>
      </fo:table-body>
    </fo:table>
  </xsl:template> <!-- match="prodgroup" -->

  <xsl:template match="proto">
    <fo:block xsl:use-attribute-sets="body" id="function-{@name}">
      <fo:inline font-weight="bold">Function: </fo:inline>
      <fo:inline font-style="italic"><xsl:value-of select="@return-type"/></fo:inline>
      <xsl:text> </xsl:text><xsl:value-of select="@name"/>(<xsl:apply-templates/>)
    </fo:block>
  </xsl:template> <!-- match="proto" -->

  <xsl:template match="pubdate">
    <xsl:apply-templates/>
  </xsl:template> <!-- match="pubdate" -->

  <xsl:template match="publoc">
    <fo:block xsl:use-attribute-sets="body">This version:</fo:block>
    <fo:block xsl:use-attribute-sets="bodyindent"><xsl:apply-templates select="loc[not(@role)]"/></fo:block>
    <fo:block xsl:use-attribute-sets="tightlist">Available formats:
      <xsl:for-each select="loc[@role]">
        <xsl:apply-templates select="."/>
        <xsl:if test="not(position() = last())"><xsl:text>, </xsl:text></xsl:if>
      </xsl:for-each>
    </fo:block>
  </xsl:template> <!-- match="publoc" -->

  <xsl:template match="quote">
    &quot;<xsl:apply-templates/>&quot;
  </xsl:template> <!-- match="quote" -->

  <xsl:template match="revisiondesc"/>

  <xsl:template match="rhs">
    <fo:block xsl:use-attribute-sets="body"><xsl:apply-templates/></fo:block>
  </xsl:template> <!-- match="rhs" -->

  <xsl:template match="role"/>

  <xsl:template match="scrap">
    <xsl:apply-templates/>
  </xsl:template> <!-- match="scrap" -->

  <xsl:template match="scrap/head">
    <fo:block xsl:use-attribute-sets="body" font-weight="bold" color="#000080" id="{generate-id(..)}">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template> <!-- match="scrap" -->

  <xsl:template match="sitem">
    <fo:list-item>
      <fo:list-item-label end-indent="label-end()">
        <fo:block xsl:use-attribute-sets="listbody" relative-align="before">-</fo:block>
      </fo:list-item-label>
      <fo:list-item-body start-indent="body-start()">
        <fo:block xsl:use-attribute-sets="listbody"><xsl:apply-templates/></fo:block>
      </fo:list-item-body>
    </fo:list-item>
  </xsl:template> <!-- match="sitem" -->

  <xsl:template match="slist">
    <fo:list-block>
      <xsl:apply-templates/>
    </fo:list-block>
  </xsl:template> <!-- match="slist" -->

  <xsl:template match="spec"/>

  <xsl:template match="specref">
    <xsl:variable name="ref" select="@ref"/>
    <fo:basic-link internal-destination="{@ref}" color="#000080">
      &#167; <xsl:apply-templates select="//*[@id=$ref]/head" mode="ref"/>
    </fo:basic-link> on page&#160;<fo:page-number-citation ref-id="{$ref}"/>
  </xsl:template> <!-- match="specref" -->

  <xsl:template match="status">
    <fo:block xsl:use-attribute-sets="heading3">Status</fo:block>
    <xsl:apply-templates/>
  </xsl:template> <!-- match="status" -->

  <xsl:template match="term">
    <fo:inline font-style="italic"><xsl:value-of select="."/></fo:inline>
  </xsl:template> <!-- match="term" -->

  <xsl:template match="termdef">
    <fo:inline id="{@id}"><xsl:apply-templates/></fo:inline>
  </xsl:template> <!-- match="termdef" -->

  <xsl:template match="termref">
    <fo:basic-link internal-destination="{@def}" color="#000080"><xsl:value-of select="."/></fo:basic-link>
  </xsl:template> <!-- match="termref" -->

  <xsl:template match="title">
    <fo:block xsl:use-attribute-sets="doctitle1"><xsl:value-of select="."/></fo:block>
  </xsl:template> <!-- match="title" -->

  <xsl:template match="ulist">
    <fo:list-block>
      <xsl:apply-templates/>
    </fo:list-block>
  </xsl:template> <!-- match="ulist" -->

  <xsl:template match="ulist/item">
    <fo:list-item>
      <fo:list-item-label end-indent="label-end()">
        <fo:block xsl:use-attribute-sets="listbody" relative-align="before">&#8226;</fo:block>
      </fo:list-item-label>
      <fo:list-item-body start-indent="body-start()">
        <xsl:apply-templates/>
      </fo:list-item-body>
    </fo:list-item>
  </xsl:template> <!-- match="ulist/item" -->

  <xsl:template match="var">
    <fo:inline font-family="monospace"><xsl:apply-templates/></fo:inline>
  </xsl:template> <!-- match="var" -->

  <xsl:template match="version">
    <fo:block xsl:use-attribute-sets="doctitle2"><xsl:value-of select="."/></fo:block>
  </xsl:template> <!-- match="version" -->

  <xsl:template match="w3c-designation"/>
    
  <xsl:template match="w3c-doctype">
    <fo:block xsl:use-attribute-sets="doctitle3"><xsl:value-of select="."/><xsl:apply-templates select="../pubdate"/></fo:block>
  </xsl:template> <!-- match="w3c-doctype" -->

  <xsl:template match="xfunction">
    <fo:basic-link external-destination="{@href}#function-{.}" color="#000080"><xsl:value-of select="."/></fo:basic-link>
  </xsl:template> <!-- match="xfunction" -->

  <xsl:template match="xnt">
    <fo:basic-link external-destination="{@href}" color="#000080"><xsl:value-of select="."/></fo:basic-link>
  </xsl:template> <!-- match="xnt" -->

  <xsl:template match="xspecref">
    <fo:basic-link external-destination="{@href}" color="#000080"><xsl:value-of select="."/></fo:basic-link>
  </xsl:template> <!-- match="xspecref" -->

  <xsl:template match="xtermref">
    <fo:basic-link external-destination="{@href}" color="#000080"><xsl:value-of select="."/></fo:basic-link>
  </xsl:template> <!-- match="xtermref" -->

  <xsl:template match="year">
    <xsl:text> </xsl:text><xsl:apply-templates/>
  </xsl:template> <!-- match="year" -->

</xsl:stylesheet>