Autogenerate doxy-header and footer from template in doclib/SConscript
[senf.git] / senfscons / xrefhtml.xslt
1 <?xml version="1.0" encoding="utf-8"?>\r
2 <xsl:stylesheet\r
3   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
4   xmlns:fn="http://senf.berlios.de/xml/Extensions"\r
5   xmlns:exsl="http://exslt.org/common"\r
6   xmlns:str="http://exslt.org/strings"\r
7   xmlns:func="http://exslt.org/functions"\r
8   extension-element-prefixes="str fn exsl func"\r
9   version="1.0">\r
10 \r
11   <xsl:include href="functions.xsl"/>\r
12 \r
13   <xsl:output method="html"/>\r
14   <xsl:strip-space elements="*"/>\r
15   <xsl:param name="title" select="''"/>\r
16   <xsl:param name="types" select="'bug todo'"/>\r
17 \r
18   <xsl:template match="/">\r
19     <div class="xref">\r
20       <h1><xsl:value-of select="$title"/></h1>\r
21       <xsl:variable name="doc" select="."/>\r
22       <div class="nav">\r
23         <xsl:text> -- </xsl:text>\r
24         <xsl:for-each select="str:split($types)">\r
25           <xsl:element name="a">\r
26             <xsl:attribute name="href">#<xsl:value-of select="."/></xsl:attribute>\r
27             <xsl:value-of select="translate(.,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/><xsl:text>S</xsl:text>\r
28           </xsl:element>\r
29           <xsl:text> -- </xsl:text>\r
30         </xsl:for-each>\r
31       </div>\r
32       <xsl:for-each select="str:split($types)">\r
33         <xsl:variable name="type" select="string(.)"/>\r
34         <xsl:element name="div">\r
35           <xsl:attribute name="class"><xsl:value-of select="$type"/></xsl:attribute>\r
36           <xsl:element name="a">\r
37             <xsl:attribute name="name"><xsl:value-of select="$type"/></xsl:attribute>\r
38             <h2>Open <xsl:value-of select="translate($type,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>s</h2>\r
39           </xsl:element>\r
40           <xsl:for-each select="$doc//xreflist[@type=$type]">\r
41             <xsl:sort select="@module"/>\r
42             <h3><xsl:value-of select="@module"/> module</h3>\r
43             <dl>\r
44               <xsl:apply-templates/>\r
45             </dl>\r
46           </xsl:for-each>\r
47         </xsl:element>\r
48       </xsl:for-each>\r
49     </div>\r
50   </xsl:template>\r
51 \r
52   <xsl:template match="compound">\r
53     <dt>\r
54       <xsl:element name="a">\r
55         <xsl:attribute name="href"><xsl:value-of select="fn:id2url(@id)"/></xsl:attribute>\r
56         <b><xsl:value-of select="@name"/></b>\r
57       </xsl:element>\r
58     </dt>\r
59     <dd>\r
60       <xsl:apply-templates/>\r
61     </dd>\r
62   </xsl:template>\r
63 \r
64   <xsl:template match="item">\r
65     <p><xsl:apply-templates/></p>\r
66   </xsl:template>\r
67   \r
68   <!-- ====================================================================== -->\r
69   <!-- Helper functions                                                       -->\r
70 \r
71   <fn:nsquote>\r
72     <fn:replacement>\r
73       <fn:match>_1_1</fn:match>\r
74       <fn:replace>_2</fn:replace>\r
75     </fn:replacement>\r
76   </fn:nsquote>\r
77 \r
78   <xsl:variable name="nsquote" select="document('')//fn:nsquote/fn:replacement"/>\r
79   \r
80   <func:function name="fn:id2url">\r
81     <xsl:param name="id"/>\r
82     <!-- Yuck ... I HATE this .. why doesn't xsltproc support XPath 2.0 ... grmpf -->\r
83     <xsl:variable name="quoted">\r
84       <xsl:apply-templates select="str:replace($id,$nsquote/fn:match,$nsquote/fn:replace)"/>\r
85     </xsl:variable>\r
86     <xsl:variable name="anchor" select="substring-after($quoted,'_1')"/>\r
87     <xsl:variable name="file">\r
88       <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
89     </xsl:variable>\r
90     <xsl:variable name="sep" select="substring('#',2-number(boolean($anchor)))"/>\r
91     <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
92   </func:function>\r
93 \r
94 </xsl:stylesheet>\r