first small steps to MPEG/DVB support...
[senf.git] / senfscons / xrefhtml.xslt
index 3d4dcbc..b9c6e7c 100644 (file)
@@ -4,7 +4,8 @@
   xmlns:fn="http://senf.berlios.de/xml/Extensions"\r
   xmlns:exsl="http://exslt.org/common"\r
   xmlns:str="http://exslt.org/strings"\r
-  extension-element-prefixes="str fn exsl"\r
+  xmlns:func="http://exslt.org/functions"\r
+  extension-element-prefixes="str fn exsl func"\r
   version="1.0">\r
 \r
   <xsl:include href="functions.xsl"/>\r
   <xsl:output method="html"/>\r
   <xsl:strip-space elements="*"/>\r
   <xsl:param name="title" select="''"/>\r
+  <xsl:param name="types" select="'bug todo'"/>\r
 \r
   <xsl:template match="/">\r
-    <h1><xsl:value-of select="$title"/></h1>\r
-    <xsl:apply-templates/>\r
+    <div class="xref">\r
+      <h1><xsl:value-of select="$title"/></h1>\r
+      <xsl:variable name="doc" select="."/>\r
+      <div class="nav">\r
+        <xsl:text> -- </xsl:text>\r
+        <xsl:for-each select="str:split($types)">\r
+          <xsl:variable name="type" select="string(.)"/>\r
+          <xsl:if test="$doc//xreflist[@type=$type]">\r
+            <xsl:element name="a">\r
+              <xsl:attribute name="href">#<xsl:value-of select="."/></xsl:attribute>\r
+              <xsl:value-of select="translate(.,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/><xsl:text>S</xsl:text>\r
+            </xsl:element>\r
+            <xsl:text> -- </xsl:text>\r
+          </xsl:if>\r
+        </xsl:for-each>\r
+      </div>\r
+      <xsl:for-each select="str:split($types)">\r
+        <xsl:variable name="type" select="string(.)"/>\r
+        <xsl:if test="$doc//xreflist[@type=$type]">\r
+          <xsl:element name="div">\r
+            <xsl:attribute name="class"><xsl:value-of select="$type"/></xsl:attribute>\r
+            <xsl:element name="a">\r
+              <xsl:attribute name="name"><xsl:value-of select="$type"/></xsl:attribute>\r
+              <h2>Open <xsl:value-of select="translate($type,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>s</h2>\r
+            </xsl:element>\r
+            <xsl:for-each select="$doc//xreflist[@type=$type]">\r
+              <xsl:sort select="@module"/>\r
+              <h3><xsl:value-of select="@module"/> module</h3>\r
+              <dl>\r
+                <xsl:apply-templates/>\r
+              </dl>\r
+            </xsl:for-each>\r
+          </xsl:element>\r
+        </xsl:if>\r
+      </xsl:for-each>\r
+    </div>\r
   </xsl:template>\r
 \r
-  <xsl:template match="xreflist">\r
-    <xsl:if test="string(preceding::xreflist[1]/@module)!=string(@module)">\r
-      <xsl:if test="preceding::xreflist">\r
-        <hr/>\r
-      </xsl:if>\r
-      <h2>The <xsl:element name="a">\r
-        <xsl:attribute name="href">../../<xsl:value-of select="@module"/>/doc/html/index.html</xsl:attribute>\r
-        <xsl:value-of select="@module"/>\r
-      </xsl:element> module</h2>\r
-    </xsl:if>\r
-    <xsl:element name="dl">\r
-      <xsl:attribute name="class"><xsl:value-of select="@type"/></xsl:attribute>\r
-      <dt><h3><xsl:value-of select="translate(@type,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> items</h3></dt>\r
+  <xsl:template match="compound">\r
+    <dt>\r
+      <xsl:element name="a">\r
+        <xsl:attribute name="href"><xsl:value-of select="fn:id2url(@id)"/></xsl:attribute>\r
+        <b><xsl:value-of select="@name"/></b>\r
+      </xsl:element>\r
+    </dt>\r
+    <dd>\r
       <xsl:apply-templates/>\r
-    </xsl:element>\r
+    </dd>\r
   </xsl:template>\r
 \r
+  <xsl:template match="item">\r
+    <p><xsl:apply-templates/></p>\r
+  </xsl:template>\r
+  \r
+  <!-- ====================================================================== -->\r
+  <!-- Helper functions                                                       -->\r
+\r
   <fn:nsquote>\r
     <fn:replacement>\r
       <fn:match>_1_1</fn:match>\r
 \r
   <xsl:variable name="nsquote" select="document('')//fn:nsquote/fn:replacement"/>\r
   \r
-  <xsl:template match="compound">\r
+  <func:function name="fn:id2url">\r
+    <xsl:param name="id"/>\r
     <!-- Yuck ... I HATE this .. why doesn't xsltproc support XPath 2.0 ... grmpf -->\r
     <xsl:variable name="quoted">\r
-      <xsl:apply-templates select="str:replace(@id,$nsquote/fn:match,$nsquote/fn:replace)"/>\r
+      <xsl:apply-templates select="str:replace($id,$nsquote/fn:match,$nsquote/fn:replace)"/>\r
     </xsl:variable>\r
     <xsl:variable name="anchor" select="substring-after($quoted,'_1')"/>\r
     <xsl:variable name="file">\r
       <xsl:apply-templates select="str:replace(substring($quoted,1,string-length($quoted) - number(boolean($anchor))*2 - string-length($anchor)),$nsquote/fn:replace,$nsquote/fn:match)"/>\r
     </xsl:variable>\r
     <xsl:variable name="sep" select="substring('#',2-number(boolean($anchor)))"/>\r
-    <dt>\r
-      <xsl:element name="a">\r
-        <xsl:attribute name="href">../../<xsl:value-of select="ancestor::xreflist/@module"/>/doc/html/<xsl:value-of select="$file"/>.html<xsl:value-of select="$sep"/><xsl:value-of select="$anchor"/></xsl:attribute>\r
-        <b><xsl:value-of select="@name"/></b>\r
-      </xsl:element>\r
-    </dt>\r
-    <dd>\r
-      <xsl:apply-templates/>\r
-    </dd>\r
-  </xsl:template>\r
-\r
-  <xsl:template match="item">\r
-    <p><xsl:apply-templates/></p>\r
-  </xsl:template>\r
+    <func:result>../../<xsl:value-of select="ancestor::xreflist/@module"/>/doc/html/<xsl:value-of select="$file"/>.html<xsl:value-of select="$sep"/><xsl:value-of select="$anchor"/></func:result>\r
+  </func:function>\r
 \r
 </xsl:stylesheet>\r