b9c6e7c3c51e6956b2e33f1fee25795fdc170631
[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:variable name="type" select="string(.)"/>\r
26           <xsl:if test="$doc//xreflist[@type=$type]">\r
27             <xsl:element name="a">\r
28               <xsl:attribute name="href">#<xsl:value-of select="."/></xsl:attribute>\r
29               <xsl:value-of select="translate(.,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/><xsl:text>S</xsl:text>\r
30             </xsl:element>\r
31             <xsl:text> -- </xsl:text>\r
32           </xsl:if>\r
33         </xsl:for-each>\r
34       </div>\r
35       <xsl:for-each select="str:split($types)">\r
36         <xsl:variable name="type" select="string(.)"/>\r
37         <xsl:if test="$doc//xreflist[@type=$type]">\r
38           <xsl:element name="div">\r
39             <xsl:attribute name="class"><xsl:value-of select="$type"/></xsl:attribute>\r
40             <xsl:element name="a">\r
41               <xsl:attribute name="name"><xsl:value-of select="$type"/></xsl:attribute>\r
42               <h2>Open <xsl:value-of select="translate($type,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>s</h2>\r
43             </xsl:element>\r
44             <xsl:for-each select="$doc//xreflist[@type=$type]">\r
45               <xsl:sort select="@module"/>\r
46               <h3><xsl:value-of select="@module"/> module</h3>\r
47               <dl>\r
48                 <xsl:apply-templates/>\r
49               </dl>\r
50             </xsl:for-each>\r
51           </xsl:element>\r
52         </xsl:if>\r
53       </xsl:for-each>\r
54     </div>\r
55   </xsl:template>\r
56 \r
57   <xsl:template match="compound">\r
58     <dt>\r
59       <xsl:element name="a">\r
60         <xsl:attribute name="href"><xsl:value-of select="fn:id2url(@id)"/></xsl:attribute>\r
61         <b><xsl:value-of select="@name"/></b>\r
62       </xsl:element>\r
63     </dt>\r
64     <dd>\r
65       <xsl:apply-templates/>\r
66     </dd>\r
67   </xsl:template>\r
68 \r
69   <xsl:template match="item">\r
70     <p><xsl:apply-templates/></p>\r
71   </xsl:template>\r
72   \r
73   <!-- ====================================================================== -->\r
74   <!-- Helper functions                                                       -->\r
75 \r
76   <fn:nsquote>\r
77     <fn:replacement>\r
78       <fn:match>_1_1</fn:match>\r
79       <fn:replace>_2</fn:replace>\r
80     </fn:replacement>\r
81   </fn:nsquote>\r
82 \r
83   <xsl:variable name="nsquote" select="document('')//fn:nsquote/fn:replacement"/>\r
84   \r
85   <func:function name="fn:id2url">\r
86     <xsl:param name="id"/>\r
87     <!-- Yuck ... I HATE this .. why doesn't xsltproc support XPath 2.0 ... grmpf -->\r
88     <xsl:variable name="quoted">\r
89       <xsl:apply-templates select="str:replace($id,$nsquote/fn:match,$nsquote/fn:replace)"/>\r
90     </xsl:variable>\r
91     <xsl:variable name="anchor" select="substring-after($quoted,'_1')"/>\r
92     <xsl:variable name="file">\r
93       <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
94     </xsl:variable>\r
95     <xsl:variable name="sep" select="substring('#',2-number(boolean($anchor)))"/>\r
96     <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
97   </func:function>\r
98 \r
99 </xsl:stylesheet>\r