]> granicus.if.org Git - docbook-dsssl/commitdiff
Support the new generate.id.attributes parameter to prevent generating both div ID...
authorNorman Walsh <ndw@nwalsh.com>
Sun, 10 Mar 2002 22:30:17 +0000 (22:30 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Sun, 10 Mar 2002 22:30:17 +0000 (22:30 +0000)
xsl/html/component.xsl
xsl/html/division.xsl
xsl/html/glossary.xsl
xsl/html/index.xsl
xsl/html/param.ent
xsl/html/param.xweb
xsl/params/generate.id.attributes.xml [new file with mode: 0644]

index f1eea4c3ce6d157a83db915e7af2c9f7b3890ad0..a7ca1a4130ef56549c94a3bfde2c79af6dd2c4b7 100644 (file)
 
 <xsl:template match="colophon">
   <div class="{name(.)}">
+    <xsl:if test="$generate.id.attributes != 0">
+      <xsl:attribute name="id">
+        <xsl:call-template name="object.id"/>
+      </xsl:attribute>
+    </xsl:if>
+
     <xsl:call-template name="component.separator"/>
     <xsl:call-template name="component.title"/>
     <xsl:call-template name="component.subtitle"/>
 
 <xsl:template match="preface">
   <div class="{name(.)}">
+    <xsl:if test="$generate.id.attributes != 0">
+      <xsl:attribute name="id">
+        <xsl:call-template name="object.id"/>
+      </xsl:attribute>
+    </xsl:if>
+
     <xsl:call-template name="component.separator"/>
     <xsl:call-template name="preface.titlepage"/>
     <xsl:if test="$generate.preface.toc != '0'">
 
 <xsl:template match="chapter">
   <div class="{name(.)}">
+    <xsl:if test="$generate.id.attributes != 0">
+      <xsl:attribute name="id">
+        <xsl:call-template name="object.id"/>
+      </xsl:attribute>
+    </xsl:if>
+
     <xsl:call-template name="component.separator"/>
     <xsl:call-template name="chapter.titlepage"/>
     <xsl:if test="$generate.chapter.toc != '0'">
 
 <xsl:template match="appendix">
   <div class="{name(.)}">
+    <xsl:if test="$generate.id.attributes != 0">
+      <xsl:attribute name="id">
+        <xsl:call-template name="object.id"/>
+      </xsl:attribute>
+    </xsl:if>
+
     <xsl:call-template name="component.separator"/>
     <xsl:call-template name="appendix.titlepage"/>
     <xsl:if test="$generate.appendix.toc != '0'">
 
 <xsl:template match="article/appendix">
   <div class="{name(.)}">
+    <xsl:if test="$generate.id.attributes != 0">
+      <xsl:attribute name="id">
+        <xsl:call-template name="object.id"/>
+      </xsl:attribute>
+    </xsl:if>
+
     <xsl:call-template name="section.heading">
       <xsl:with-param name="level" select="2"/>
       <xsl:with-param name="title">
 
 <xsl:template match="article">
   <div class="{name(.)}">
+    <xsl:if test="$generate.id.attributes != 0">
+      <xsl:attribute name="id">
+        <xsl:call-template name="object.id"/>
+      </xsl:attribute>
+    </xsl:if>
+
     <xsl:call-template name="article.titlepage"/>
     <xsl:if test="$generate.article.toc != '0'">
       <xsl:call-template name="component.toc"/>
index fa9a7138baf13f96aece3e9e3d3b8934e6abd361..a648ad9fa74c7bdc2491bc39908f24178c652134 100644 (file)
 
 <xsl:template match="set">
   <div class="{name(.)}">
+    <xsl:if test="$generate.id.attributes != 0">
+      <xsl:attribute name="id">
+        <xsl:call-template name="object.id"/>
+      </xsl:attribute>
+    </xsl:if>
+
     <xsl:call-template name="set.titlepage"/>
     <xsl:if test="$generate.set.toc != '0'">
       <xsl:call-template name="set.toc"/>
 
 <xsl:template match="book">
   <div class="{name(.)}">
+    <xsl:if test="$generate.id.attributes != 0">
+      <xsl:attribute name="id">
+        <xsl:call-template name="object.id"/>
+      </xsl:attribute>
+    </xsl:if>
+
     <xsl:call-template name="book.titlepage"/>
     <xsl:apply-templates select="dedication" mode="dedication"/>
     <xsl:if test="$generate.book.toc != '0'">
 
 <xsl:template match="part">
   <div class="{name(.)}">
+    <xsl:if test="$generate.id.attributes != 0">
+      <xsl:attribute name="id">
+        <xsl:call-template name="object.id"/>
+      </xsl:attribute>
+    </xsl:if>
+
     <xsl:call-template name="part.titlepage"/>
     <xsl:if test="not(partintro) and $generate.part.toc != '0'">
       <xsl:call-template name="division.toc"/>
 
 <xsl:template match="partintro">
   <div class="{name(.)}">
+    <xsl:if test="$generate.id.attributes != 0">
+      <xsl:attribute name="id">
+        <xsl:call-template name="object.id"/>
+      </xsl:attribute>
+    </xsl:if>
+
     <xsl:call-template name="partintro.titlepage"/>
     <xsl:apply-templates/>
     <xsl:if test="$generate.part.toc != '0'">
index c83c7fa4ebe80ab99488ecf9e4bc91f2122cc8e5..1357229967c598deb5d1b2925d0a10a919cbd2d1 100644 (file)
 <!-- ==================================================================== -->
 
 <xsl:template match="glossary">
-  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+  <div class="{name(.)}">
+    <xsl:if test="$generate.id.attributes != 0">
+      <xsl:attribute name="id">
+        <xsl:call-template name="object.id"/>
+      </xsl:attribute>
+    </xsl:if>
 
-  <div id="{$id}" class="{name(.)}">
     <xsl:call-template name="glossary.titlepage"/>
 
     <xsl:choose>
@@ -215,7 +219,6 @@ GlossEntry ::=
 <!-- Glossary collection -->
 
 <xsl:template match="glossary[@role='auto']" priority="2">
-  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
   <xsl:variable name="terms" select="//glossterm[not(parent::glossdef)]|//firstterm"/>
   <xsl:variable name="collection" select="document($glossary.collection, .)"/>
 
@@ -226,7 +229,13 @@ GlossEntry ::=
     </xsl:message>
   </xsl:if>
 
-  <div id="{$id}" class="{name(.)}">
+  <div class="{name(.)}">
+    <xsl:if test="$generate.id.attributes != 0">
+      <xsl:attribute name="id">
+        <xsl:call-template name="object.id"/>
+      </xsl:attribute>
+    </xsl:if>
+
     <xsl:call-template name="glossary.titlepage"/>
 
     <xsl:choose>
index 53a0df60b1469b333034562f048b6d4cd3e3b897..879aab8484fe06b8a04585d66e2e54e30e2dd5bd 100644 (file)
 
   <xsl:if test="count(*)>0 or $generate.index != '0'">
     <div class="{name(.)}">
+      <xsl:if test="$generate.id.attributes != 0">
+        <xsl:attribute name="id">
+          <xsl:call-template name="object.id"/>
+        </xsl:attribute>
+      </xsl:if>
+
       <xsl:call-template name="anchor"/>
       <xsl:call-template name="index.titlepage"/>
       <xsl:apply-templates/>
 
 <xsl:template match="indexdiv">
   <div class="{name(.)}">
+    <xsl:if test="$generate.id.attributes != 0">
+      <xsl:attribute name="id">
+        <xsl:call-template name="object.id"/>
+      </xsl:attribute>
+    </xsl:if>
+
     <xsl:call-template name="anchor"/>
     <xsl:apply-templates mode="not-indexentrys"/>
     <dl>
index 311881d148de830d0c09d8217ebbd66bb26dbbb1..81a08f1bede23316ee9be183b25aaf975101d1cb 100644 (file)
@@ -45,6 +45,7 @@
 <!ENTITY generate.chapter.toc SYSTEM "../params/generate.chapter.toc.xml">
 <!ENTITY generate.component.toc SYSTEM "../params/generate.component.toc.xml">
 <!ENTITY generate.division.toc SYSTEM "../params/generate.division.toc.xml">
+<!ENTITY generate.id.attributes SYSTEM "../params/generate.id.attributes.xml">
 <!ENTITY generate.index SYSTEM "../params/generate.index.xml">
 <!ENTITY generate.legalnotice.link SYSTEM "../params/generate.legalnotice.link.xml">
 <!ENTITY generate.part.toc SYSTEM "../params/generate.part.toc.xml">
index f5379c8a3175e6517ed3d36ebe648f5952ce50c5..818f58078cf083dbe0b62b4c5c90e99a490aed37 100644 (file)
@@ -151,6 +151,7 @@ to be incomplete. Don't forget to read the source, too :-)</para>
 &make.valid.html;
 &html.cleanup;
 &draft.watermark.image;
+&generate.id.attributes;
 </reference>
 
 <reference><title>XSLT Processing</title>
@@ -360,6 +361,7 @@ around all these parameters.</para>
 <src:fragref linkend="generate.chapter.toc.frag"/>
 <src:fragref linkend="generate.component.toc.frag"/>
 <src:fragref linkend="generate.division.toc.frag"/>
+<src:fragref linkend="generate.id.attributes.frag"/>
 <src:fragref linkend="generate.index.frag"/>
 <src:fragref linkend="generate.legalnotice.link.frag"/>
 <src:fragref linkend="generate.part.toc.frag"/>
diff --git a/xsl/params/generate.id.attributes.xml b/xsl/params/generate.id.attributes.xml
new file mode 100644 (file)
index 0000000..6c638dc
--- /dev/null
@@ -0,0 +1,54 @@
+<refentry id="generate.id.attributes">
+<refmeta>
+<refentrytitle>generate.id.attributes</refentrytitle>
+<refmiscinfo role="type"></refmiscinfo>
+</refmeta>
+<refnamediv>
+<refname>generate.id.attributes</refname>
+<refpurpose></refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+<src:fragment id='generate.id.attributes.frag'>
+<xsl:param name="generate.id.attributes" select="0"/>
+</src:fragment>
+</refsynopsisdiv>
+
+<refsect1><title>Description</title>
+
+<para>If non-zero, the HTML stylesheet will generate ID attributes on
+containers. For example, the markup:</para>
+
+<screen><![CDATA[<section id="foo"><title>Some Title</title>
+<para>Some para.</para>
+</section>]]></screen>
+
+<para>might produce:</para>
+
+<screen><![CDATA[<div class="section" id="foo">
+<h2>Some Title</h2>
+<p>Some para.</p>
+</div>]]></screen>
+
+<para>The alternative is to generate anchors:</para>
+
+<screen><![CDATA[<div class="section">
+<h2><a name="foo"></a>Some Title</h2>
+<p>Some para.</p>
+</div>]]></screen>
+
+<para>Because the <sgmltag class="attribute">name</sgmltag> attribute of
+the <sgmltag>a</sgmltag> element and the <sgmltag class="attribute">id</sgmltag>
+attribute of other tags are both of type <quote>ID</quote>, producing both
+generates invalid documents.</para>
+
+<para>As of version 1.50, you can use this switch to control which type of
+identifier is generated. For backwards-compatibility, generating
+<sgmltag>a</sgmltag> anchors is preferred.</para>
+
+<para>Note: at present, this switch is incompletely implemented.
+Disabling ID attributes will suppress them, but enabling ID attributes
+will not suppress the anchors.</para>
+
+</refsect1>
+</refentry>