- From: Michael Smith via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 01 May 2009 13:53:17 +0000
- To: public-html-commits@w3.org
Update of /sources/public/html5/markup/tools
In directory hutz:/tmp/cvs-serv29902/tools
Modified Files:
specgen.xsl
Added Files:
toc.xsl
Log Message:
fixed problem with TOC skip link, move TOC-generating XSL code to separate file
Index: specgen.xsl
===================================================================
RCS file: /sources/public/html5/markup/tools/specgen.xsl,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- specgen.xsl 1 May 2009 11:08:00 -0000 1.27
+++ specgen.xsl 1 May 2009 13:53:15 -0000 1.28
@@ -4,24 +4,20 @@
xmlns:date="http://exslt.org/dates-and-times"
exclude-result-prefixes='h date'
version='1.0' id='xslt'>
-
<xsl:output method='html' encoding='us-ascii'
doctype-public='-//W3C//DTD HTML 4.01//EN'
doctype-system='http://www.w3.org/TR/html4/strict.dtd'
media-type='text/html; charset=us-ascii'
indent="yes"/>
-
+ <xsl:include href="toc.xsl"/>
<xsl:include href="chunker.xsl"/>
<xsl:param name="chunk" select="0"/>
<xsl:param name="TOC-file"/>
-
<xsl:key name="id" match="*" use="@id"/>
<xsl:key name="chunk-for-id" match="*[@id]" use="ancestor::h:section[child::h:h2[@class='element-head']]
|ancestor::h:section[(count(ancestor::h:section)=0 and not(@id='elements'))]"/>
-
<xsl:variable name='sectionsID'>this_sections</xsl:variable>
<xsl:variable name='appendicesID'>appendices</xsl:variable>
-
<xsl:variable name='id' select='/*/h:head/h:meta[@name="revision"]/@content'/>
<xsl:variable name='rev' select='substring-before(substring-after(substring-after($id, " "), " "), " ")'/>
<xsl:variable name='toc-marker' select='//h:*[@id = "toc"][1]'/>
@@ -33,7 +29,6 @@
<xsl:variable name="previous-nodeset" select="$info/h:*[@id = 'versions']/h:*[contains(@class,'previous')]"/>
<xsl:variable name="person-nodeset" select='$info/h:*[@id="editors"]/h:*[@ class="person"]'/>
<xsl:variable name="groupinfo-nodeset" select="$info/h:*[@id = 'groupinfo']"/>
-
<xsl:template match='/'>
<!-- * <xsl:if test='$maturity = "ED"'> -->
<!-- * <xsl:comment> * </xsl:comment> -->
@@ -43,14 +38,12 @@
<!-- * </xsl:if> -->
<xsl:apply-templates select='/*'/>
</xsl:template>
-
<xsl:template match='h:*'>
<xsl:element name="{name()}" namespace="{namespace-uri()}">
<xsl:copy-of select='@*[namespace-uri()="" or namespace-uri="http://www.w3.org/XML/1998/namespace"]'/>
<xsl:apply-templates select='node()'/>
</xsl:element>
</xsl:template>
-
<xsl:template match='h:head'>
<head>
<xsl:copy-of select='@*[namespace-uri()="" or namespace-uri="http://www.w3.org/XML/1998/namespace"]'/>
@@ -75,7 +68,6 @@
<xsl:text> </xsl:text>
</head>
</xsl:template>
-
<!-- * suppress meta@charset -->
<xsl:template match="h:meta[@charset]"/>
<!-- * suppress duplication of ED CSS link -->
@@ -86,7 +78,6 @@
<xsl:template match="h:*[@id = 'info']"/>
<!-- * remove source admonition -->
<xsl:template match="*[@id = 'source-admonition']" priority="10"/>
-
<xsl:template name='monthName'>
<xsl:param name='n' select='1'/>
<xsl:param name='s' select='"January February March April May June July August September October November December "'/>
@@ -103,7 +94,6 @@
</xsl:otherwise>
</xsl:choose>
</xsl:template>
-
<xsl:template match="h:body">
<body>
<xsl:copy-of select='@*[namespace-uri()="" or namespace-uri="http://www.w3.org/XML/1998/namespace"]'/>
@@ -111,7 +101,6 @@
<xsl:apply-templates/>
</body>
</xsl:template>
-
<xsl:template name='top'>
<div class='head'>
<!-- * CHANGE_ME_BACK -->
@@ -208,7 +197,6 @@
</div>
<hr/>
</xsl:template>
-
<xsl:template name='date'>
<xsl:variable name='date'>
<xsl:value-of select='substring($this, string-length($this) - 8, 8)'/>
@@ -232,7 +220,6 @@
</xsl:otherwise>
</xsl:choose>
</xsl:template>
-
<xsl:template name='maturity'>
<xsl:choose>
<xsl:when test='$maturity="FPWD"'>First Public Working Draft</xsl:when>
@@ -247,7 +234,6 @@
<xsl:otherwise>Editor’s Draft</xsl:otherwise>
</xsl:choose>
</xsl:template>
-
<xsl:template name='maturity-short'>
<xsl:choose>
<xsl:when test='$maturity="FPWD"'>Working Draft</xsl:when>
@@ -262,14 +248,12 @@
<xsl:otherwise>Editor’s Draft</xsl:otherwise>
</xsl:choose>
</xsl:template>
-
<xsl:template match="h:*[@id = 'abstract']">
<div id="abstract">
<xsl:apply-templates/>
<!-- * <xsl:call-template name="revision-note"/> -->
</div>
</xsl:template>
-
<xsl:template name='revision-note'>
<xsl:if test='$maturity="ED"'>
<div class='ednote'>
@@ -279,7 +263,6 @@
</div>
</xsl:if>
</xsl:template>
-
<xsl:template match="h:*[@id = 'status']">
<div>
<xsl:copy-of select='@*[namespace-uri()="" or namespace-uri="http://www.w3.org/XML/1998/namespace"]'/>
@@ -287,7 +270,6 @@
<xsl:call-template name="sotd"/>
</div>
</xsl:template>
-
<xsl:template name='sotd'>
<xsl:variable name='w3c-ipp' select='$groupinfo-nodeset/*[@id = "w3c-ipp"]'/>
<xsl:variable name='comments-address' select='$groupinfo-nodeset/*[@id = "comments-address"]'/>
@@ -412,27 +394,6 @@
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
-
- <xsl:template match="h:*[@id = 'toc']">
- <xsl:text> </xsl:text>
- <div id='toc'>
- <xsl:copy-of select='@*[namespace-uri()="" or namespace-uri="http://www.w3.org/XML/1998/namespace"]'/>
- <xsl:apply-templates select='node()'/>
- <xsl:call-template name="toc"/>
- </div>
- </xsl:template>
-
- <xsl:template name='toc'>
- <xsl:for-each select='//*[@id=$sectionsID]'>
- <xsl:call-template name='toc1'/>
- </xsl:for-each>
- <xsl:for-each select='//*[@id=$appendicesID]'>
- <xsl:call-template name='toc1'>
- <xsl:with-param name='alpha' select='true()'/>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:template>
-
<xsl:template match='processing-instruction("sref")'>
<xsl:variable name='id' select='string(.)'/>
<xsl:variable name='s' select='//*[@id=$id]/self::h:section'/>
@@ -445,7 +406,6 @@
<xsl:otherwise>@@</xsl:otherwise>
</xsl:choose>
</xsl:template>
-
<xsl:template match='processing-instruction("sdir")'>
<xsl:variable name='id' select='string(.)'/>
<xsl:choose>
@@ -454,88 +414,7 @@
<xsl:otherwise>@@</xsl:otherwise>
</xsl:choose>
</xsl:template>
-
<xsl:template match='processing-instruction()|comment()'/>
-
- <xsl:template name='toc1'>
- <xsl:param name='prefix'/>
- <xsl:param name='alpha'/>
- <xsl:variable name='subsections' select='h:section[not(contains(@class,"no-toc"))]'/>
- <xsl:if test='$subsections'>
- <ul>
- <xsl:text> </xsl:text>
- <xsl:for-each select='h:section[not(contains(@class,"no-toc"))]'>
- <xsl:variable name='number'>
- <xsl:value-of select='$prefix'/>
- <xsl:if test='$prefix'>.</xsl:if>
- <xsl:choose>
- <xsl:when test='$alpha'><xsl:number value='position()' format='A'/></xsl:when>
- <xsl:otherwise><xsl:value-of select='position()'/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name='frag'>
- <xsl:choose>
- <xsl:when test='@id'><xsl:value-of select='@id'/></xsl:when>
- <xsl:otherwise><xsl:value-of select='generate-id(.)'/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name='section-id'>
- <xsl:choose>
- <xsl:when test='$chunk=0'/>
- <xsl:otherwise>
- <xsl:value-of select="
- key('id',$frag)[ancestor-or-self::h:section[@id='elements']]/@id
- |key('id',$frag)/ancestor-or-self::h:section[count(ancestor::h:section)=0 and not(@id='elements')]/@id
- "/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name='filename'>
- <xsl:choose>
- <xsl:when test='$chunk=0'/>
- <xsl:when test="$section-id=''">
- <xsl:message>
- <xsl:text>UNDEFINED: </xsl:text>
- <xsl:value-of select="$frag"/>
- <xsl:text> in </xsl:text>
- <xsl:value-of select="ancestor-or-self::h:section[child::h:h2[@class='element-head']]/@id
- |ancestor::h:section[(count(ancestor::h:section)=0 and not(@id='elements'))]/@id"/>
- <xsl:text>.html</xsl:text>
- </xsl:message>
- </xsl:when>
- <xsl:otherwise>
- <xsl:message>
- <xsl:value-of select="concat($section-id,'.html')"/>
- </xsl:message>
- <xsl:value-of select="concat($section-id,'.html')"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <li id='{$frag}-toc'>
- <a href='{$filename}#{$frag}'>
- <xsl:if test="not(contains(@class,'no-number'))">
- <xsl:value-of select='$number'/>
- <xsl:text>. </xsl:text>
- </xsl:if>
- <xsl:copy-of select='(h:h2|h:h3|h:h4|h:h5|h:h6)/node()'/>
- </a>
- <xsl:if test='h:h2[@class = "element-head"]
- and .//*[@class = "obsolete"]'>
- <xsl:text> </xsl:text>
- <span class="obsolete">(obsolete)</span>
- </xsl:if>
- <xsl:text> </xsl:text>
- <xsl:call-template name='toc1'>
- <xsl:with-param name='prefix' select='$number'/>
- </xsl:call-template>
- </li>
- <xsl:text> </xsl:text>
- </xsl:for-each>
- </ul>
- <xsl:text> </xsl:text>
- </xsl:if>
- </xsl:template>
-
<xsl:template name='section-number'>
<xsl:param name='section'/>
<xsl:param name='sections' select="//*[@id = $sectionsID]"/>
@@ -566,7 +445,6 @@
</xsl:when>
</xsl:choose>
</xsl:template>
-
<xsl:template match='h:h2[
not(../@id = "abstract")
and not(../@id="status")
@@ -607,11 +485,17 @@
<a class="hash" href="#{$myid}">#</a>
<xsl:if test='not(parent::h:*[contains(@class,"no-toc")])'>
<xsl:text> </xsl:text>
- <a class="toc-bak" href="{$TOC-file}#{$myid}-toc">T</a>
+ <xsl:choose>
+ <xsl:when test="not($chunk=0)">
+ <a class="toc-bak" href="{$TOC-file}#{$myid}-toc">T</a>
+ </xsl:when>
+ <xsl:otherwise>
+ <a class="toc-bak" href="#{$myid}-toc">T</a>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:if>
</xsl:element>
</xsl:template>
-
<xsl:template match='h:*[@class="ednote"]'>
<div>
<xsl:copy-of select='@*[namespace-uri()="" or namespace-uri="http://www.w3.org/XML/1998/namespace"]'/>
@@ -619,7 +503,6 @@
<xsl:apply-templates select='node()'/>
</div>
</xsl:template>
-
<!-- * <xsl:template match='h:*[@class="example"]'> -->
<!-- * <div> -->
<!-- * <xsl:copy-of select='@*[namespace-uri()="" or namespace-uri="http://www.w3.org/XML/1998/namespace"]'/> -->
@@ -627,7 +510,6 @@
<!-- * <xsl:apply-templates select='node()'/> -->
<!-- * </div> -->
<!-- * </xsl:template> -->
-
<!-- * <xsl:template match='h:*[@class="note"]'> -->
<!-- * <div> -->
<!-- * <xsl:copy-of select='@*[namespace-uri()="" or namespace-uri="http://www.w3.org/XML/1998/namespace"]'/> -->
@@ -635,7 +517,6 @@
<!-- * <xsl:apply-templates select='node()'/> -->
<!-- * </div> -->
<!-- * </xsl:template> -->
-
<xsl:template match='h:section'>
<xsl:variable name="content">
<div>
@@ -661,9 +542,7 @@
</xsl:otherwise>
</xsl:choose>
</xsl:template>
-
<xsl:template match='*'/>
-
<xsl:template match="h:a[@href[starts-with(.,'#')]]">
<!-- * href ID references in chunked output need to become intra-file -->
<!-- * references to IDs that are to targets in other files; so this -->
@@ -703,5 +582,9 @@
</xsl:otherwise>
</xsl:choose>
</xsl:template>
-
+ <xsl:template match="h:div[@id='tocjump']">
+ <div id="tocjump" class="skip-link" style="text-align: center">
+ <a href="{$TOC-file}#toc">Skip to Table of Contents</a>
+ </div>
+ </xsl:template>
</xsl:stylesheet>
--- NEW FILE: toc.xsl ---
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:h='http://www.w3.org/1999/xhtml'
xmlns='http://www.w3.org/1999/xhtml'
version='1.0' id='xslt'>
<xsl:template match="h:*[@id = 'toc']">
<xsl:text> </xsl:text>
<div id='toc'>
<xsl:copy-of select='@*[namespace-uri()="" or namespace-uri="http://www.w3.org/XML/1998/namespace"]'/>
<xsl:apply-templates select='node()'/>
<xsl:call-template name="toc"/>
</div>
</xsl:template>
<xsl:template name='toc'>
<xsl:for-each select='//*[@id=$sectionsID]'>
<xsl:call-template name='toc1'/>
</xsl:for-each>
<xsl:for-each select='//*[@id=$appendicesID]'>
<xsl:call-template name='toc1'>
<xsl:with-param name='alpha' select='true()'/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name='toc1'>
<xsl:param name='prefix'/>
<xsl:param name='alpha'/>
<xsl:variable name='subsections' select='h:section[not(contains(@class,"no-toc"))]'/>
<xsl:if test='$subsections'>
<ul>
<xsl:text> </xsl:text>
<xsl:for-each select='h:section[not(contains(@class,"no-toc"))]'>
<xsl:variable name='number'>
<xsl:value-of select='$prefix'/>
<xsl:if test='$prefix'>.</xsl:if>
<xsl:choose>
<xsl:when test='$alpha'><xsl:number value='position()' format='A'/></xsl:when>
<xsl:otherwise><xsl:value-of select='position()'/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name='frag'>
<xsl:choose>
<xsl:when test='@id'><xsl:value-of select='@id'/></xsl:when>
<xsl:otherwise><xsl:value-of select='generate-id(.)'/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name='section-id'>
<xsl:choose>
<xsl:when test='$chunk=0'/>
<xsl:otherwise>
<xsl:value-of select="
key('id',$frag)[ancestor-or-self::h:section[@id='elements']]/@id
|key('id',$frag)/ancestor-or-self::h:section[count(ancestor::h:section)=0 and not(@id='elements')]/@id
"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name='filename'>
<xsl:choose>
<xsl:when test='$chunk=0'/>
<xsl:otherwise>
<xsl:value-of select="concat($section-id,'.html')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<li id='{$frag}-toc'>
<a href='{$filename}#{$frag}'>
<xsl:if test="not(contains(@class,'no-number'))">
<xsl:value-of select='$number'/>
<xsl:text>. </xsl:text>
</xsl:if>
<xsl:copy-of select='(h:h2|h:h3|h:h4|h:h5|h:h6)/node()'/>
</a>
<xsl:if test='h:h2[@class = "element-head"]
and .//*[@class = "obsolete"]'>
<xsl:text> </xsl:text>
<span class="obsolete">(obsolete)</span>
</xsl:if>
<xsl:text> </xsl:text>
<xsl:call-template name='toc1'>
<xsl:with-param name='prefix' select='$number'/>
</xsl:call-template>
</li>
<xsl:text> </xsl:text>
</xsl:for-each>
</ul>
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Received on Friday, 1 May 2009 13:53:29 UTC