rebase: add missing args
[gtk-doc.git] / devhelp2.xsl
blob37c235a03255a59c83b3c5709c8b103de30034e8
1 <?xml version='1.0'?> <!--*- mode: xml -*-->
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 version='1.0'
4 xmlns="http://www.devhelp.net/book"
5 xmlns:str="http://exslt.org/strings"
6 exclude-result-prefixes="str">
8 <xsl:template name="generate.devhelp2">
9 <xsl:call-template name="write.chunk">
10 <xsl:with-param name="filename">
11 <xsl:choose>
12 <xsl:when test="$gtkdoc.bookname">
13 <xsl:value-of select="$gtkdoc.bookname"/>
14 </xsl:when>
15 <xsl:otherwise>
16 <xsl:text>book</xsl:text>
17 </xsl:otherwise>
18 </xsl:choose>
19 <xsl:text>.devhelp2</xsl:text>
20 </xsl:with-param>
21 <xsl:with-param name="method" select="'xml'"/>
22 <xsl:with-param name="indent" select="'yes'"/>
23 <xsl:with-param name="encoding" select="'utf-8'"/>
24 <xsl:with-param name="doctype-public"/>
25 <xsl:with-param name="content">
26 <xsl:call-template name="devhelp2"/>
27 </xsl:with-param>
28 </xsl:call-template>
29 </xsl:template>
31 <xsl:variable name="gtkdoc.refsect2" select="//refsect2"/>
33 <xsl:template name="devhelp2">
34 <xsl:variable name="title">
35 <xsl:apply-templates select="." mode="generate.devhelp2.toc.title.mode"/>
36 </xsl:variable>
37 <xsl:variable name="link">
38 <xsl:call-template name="href.target"/>
39 </xsl:variable>
40 <xsl:variable name="author">
41 <xsl:if test="articleinfo|bookinfo">
42 <xsl:apply-templates mode="generate.devhelp2.authors"
43 select="articleinfo|bookinfo"/>
44 </xsl:if>
45 </xsl:variable>
46 <xsl:variable name="online">
47 <xsl:value-of select="/book/bookinfo/releaseinfo/ulink[@role='online-location']/@url"/>
48 </xsl:variable>
49 <xsl:variable name="toc.nodes" select="part|reference|preface|chapter|
50 appendix|article|bibliography|
51 glossary|index|refentry|
52 bridgehead|sect1"/>
54 <book title="{$title}" link="{$link}" author="{$author}" name="{$gtkdoc.bookname}" version="2" language="c">
55 <xsl:if test="$online != ''">
56 <xsl:attribute name="online"><xsl:value-of select="$online"/></xsl:attribute>
57 </xsl:if>
58 <xsl:if test="$toc.nodes">
59 <chapters>
60 <xsl:apply-templates select="$toc.nodes"
61 mode="generate.devhelp2.toc.mode"/>
62 </chapters>
63 </xsl:if>
64 <functions>
65 <xsl:apply-templates select="$gtkdoc.refsect2[@role]"
66 mode="generate.devhelp2.index.mode"/>
67 <xsl:apply-templates select="$gtkdoc.refsect2/refsect3[@role='enum_members']/informaltable/tgroup/tbody/row[@role='constant']"
68 mode="generate.devhelp2.index.mode"/>
69 <xsl:apply-templates select="$gtkdoc.refsect2/refsect3[@role='struct_members']/informaltable/tgroup/tbody/row[@role='member']"
70 mode="generate.devhelp2.index.mode"/>
71 </functions>
72 </book>
73 </xsl:template>
75 <xsl:template match="*" mode="generate.devhelp2.toc.mode">
76 <xsl:variable name="title">
77 <xsl:apply-templates select="." mode="generate.devhelp2.toc.title.mode"/>
78 </xsl:variable>
79 <xsl:variable name="target">
80 <xsl:variable name="anchor" select="title/anchor"/>
81 <xsl:choose>
82 <xsl:when test="$anchor">
83 <xsl:call-template name="href.target">
84 <xsl:with-param name="object" select="$anchor"/>
85 </xsl:call-template>
86 </xsl:when>
87 <xsl:otherwise>
88 <xsl:call-template name="href.target"/>
89 </xsl:otherwise>
90 </xsl:choose>
91 </xsl:variable>
93 <sub name="{$title}" link="{$target}">
94 <xsl:apply-templates select="section|sect1|
95 refentry|refsect|
96 bridgehead|part|chapter|glossary|index"
97 mode="generate.devhelp2.toc.mode"/>
98 </sub>
99 </xsl:template>
101 <xsl:template match="*" mode="generate.devhelp2.index.mode">
102 <xsl:variable name="title" select="title|
103 term/literal|
104 entry[@role='enum_member_name']/para|
105 entry[@role='struct_member_name']/para/structfield/@id"/>
106 <xsl:variable name="anchor" select="title/anchor|
107 entry[@role='enum_member_name']/para|
108 entry[@role='struct_member_name']/para/structfield"/>
109 <xsl:variable name="type" select="@role"/>
110 <xsl:variable name="condition" select="@condition"/>
111 <xsl:variable name="target">
112 <xsl:choose>
113 <xsl:when test="$anchor">
114 <xsl:call-template name="href.target">
115 <xsl:with-param name="object" select="$anchor"/>
116 </xsl:call-template>
117 </xsl:when>
118 <xsl:otherwise>
119 <xsl:call-template name="href.target"/>
120 </xsl:otherwise>
121 </xsl:choose>
122 </xsl:variable>
123 <keyword type="{$type}" name="{$title}" link="{$target}">
124 <xsl:if test="$condition">
125 <xsl:for-each select="str:split($condition,'|')">
126 <xsl:variable name="attrname">
127 <xsl:value-of select="substring-before(.,':')"/>
128 </xsl:variable>
129 <xsl:choose>
130 <xsl:when test="string-length($attrname)=0">
131 <xsl:variable name="attrname2">
132 <xsl:value-of select="."/>
133 </xsl:variable>
134 <xsl:attribute name="{$attrname2}"/>
135 </xsl:when>
136 <xsl:otherwise>
137 <xsl:attribute name="{$attrname}">
138 <xsl:value-of select="substring-after(.,':')"/>
139 </xsl:attribute>
140 </xsl:otherwise>
141 </xsl:choose>
142 </xsl:for-each>
143 </xsl:if>
144 </keyword>
145 </xsl:template>
147 <!-- get title -->
148 <xsl:template match="article" mode="generate.devhelp2.toc.title.mode">
149 <xsl:value-of select="articleinfo/title"/>
150 </xsl:template>
151 <xsl:template match="book" mode="generate.devhelp2.toc.title.mode">
152 <xsl:value-of select="bookinfo/title"/>
153 </xsl:template>
154 <xsl:template match="refentry" mode="generate.devhelp2.toc.title.mode">
155 <xsl:value-of select="refmeta/refentrytitle"/>
156 </xsl:template>
157 <xsl:template match="*" mode="generate.devhelp2.toc.title.mode">
158 <xsl:value-of select="title"/>
159 </xsl:template>
161 <!-- generate list of authors ... -->
162 <xsl:template match="articleinfo|bookinfo" mode="generate.devhelp2.authors">
163 <xsl:for-each select="authorgroup/author">
164 <xsl:value-of select="firstname"/>
165 <xsl:text> </xsl:text>
166 <xsl:value-of select="surname"/>
167 <xsl:if test="not(last())">
168 <xsl:text>, </xsl:text>
169 </xsl:if>
170 </xsl:for-each>
171 </xsl:template>
173 </xsl:stylesheet>