Handle DESTDIR= case.
[gtk-doc.git] / devhelp2.xsl
blobdecf2135b3d398cbd7730f48ca0252c7d314ea0c
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="content">
25 <xsl:call-template name="devhelp2"/>
26 </xsl:with-param>
27 </xsl:call-template>
28 </xsl:template>
30 <xsl:template name="devhelp2">
31 <xsl:variable name="title">
32 <xsl:apply-templates select="." mode="generate.devhelp2.toc.title.mode"/>
33 </xsl:variable>
34 <xsl:variable name="link">
35 <xsl:call-template name="href.target"/>
36 </xsl:variable>
37 <xsl:variable name="author">
38 <xsl:if test="articleinfo|bookinfo">
39 <xsl:apply-templates mode="generate.devhelp2.authors"
40 select="articleinfo|bookinfo"/>
41 </xsl:if>
42 </xsl:variable>
43 <xsl:variable name="toc.nodes" select="part|reference|preface|chapter|
44 appendix|article|bibliography|
45 glossary|index|refentry|
46 bridgehead|sect1"/>
48 <book title="{$title}" link="{$link}" author="{$author}" name="{$gtkdoc.bookname}" version="2">
49 <xsl:if test="$toc.nodes">
50 <chapters>
51 <xsl:apply-templates select="$toc.nodes"
52 mode="generate.devhelp2.toc.mode"/>
53 </chapters>
54 </xsl:if>
55 <functions>
56 <xsl:apply-templates select="//refsect2"
57 mode="generate.devhelp2.index.mode"/>
58 </functions>
59 </book>
60 </xsl:template>
62 <xsl:template match="*" mode="generate.devhelp2.toc.mode">
63 <xsl:variable name="title">
64 <xsl:apply-templates select="." mode="generate.devhelp2.toc.title.mode"/>
65 </xsl:variable>
66 <xsl:variable name="target">
67 <xsl:variable name="anchor" select="title/anchor"/>
68 <xsl:choose>
69 <xsl:when test="$anchor">
70 <xsl:call-template name="href.target">
71 <xsl:with-param name="object" select="$anchor"/>
72 </xsl:call-template>
73 </xsl:when>
74 <xsl:otherwise>
75 <xsl:call-template name="href.target"/>
76 </xsl:otherwise>
77 </xsl:choose>
78 </xsl:variable>
80 <sub name="{$title}" link="{$target}">
81 <xsl:apply-templates select="section|sect1|
82 refentry|refsect|
83 bridgehead|part|chapter"
84 mode="generate.devhelp2.toc.mode"/>
85 </sub>
86 </xsl:template>
88 <xsl:template match="*" mode="generate.devhelp2.index.mode">
89 <xsl:variable name="title" select="title"/>
90 <xsl:variable name="anchor" select="title/anchor"/>
91 <xsl:variable name="type" select="title/anchor/@role"/>
92 <xsl:variable name="condition" select="title/anchor/@condition"/>
93 <xsl:variable name="target">
94 <xsl:choose>
95 <xsl:when test="$anchor">
96 <xsl:call-template name="href.target">
97 <xsl:with-param name="object" select="$anchor"/>
98 </xsl:call-template>
99 </xsl:when>
100 <xsl:otherwise>
101 <xsl:call-template name="href.target"/>
102 </xsl:otherwise>
103 </xsl:choose>
104 </xsl:variable>
105 <keyword type="{$type}" name="{$title}" link="{$target}">
106 <xsl:if test="$condition">
107 <xsl:for-each select="str:split($condition,'|')">
108 <xsl:variable name="attrname">
109 <xsl:value-of select="substring-before(.,':')"/>
110 </xsl:variable>
111 <xsl:choose>
112 <xsl:when test="string-length($attrname)=0">
113 <xsl:variable name="attrname2">
114 <xsl:value-of select="."/>
115 </xsl:variable>
116 <xsl:attribute name="{$attrname2}"/>
117 </xsl:when>
118 <xsl:otherwise>
119 <xsl:attribute name="{$attrname}">
120 <xsl:value-of select="substring-after(.,':')"/>
121 </xsl:attribute>
122 </xsl:otherwise>
123 </xsl:choose>
124 </xsl:for-each>
125 </xsl:if>
126 </keyword>
127 </xsl:template>
129 <!-- get title -->
130 <xsl:template match="article" mode="generate.devhelp2.toc.title.mode">
131 <xsl:value-of select="articleinfo/title"/>
132 </xsl:template>
133 <xsl:template match="book" mode="generate.devhelp2.toc.title.mode">
134 <xsl:value-of select="bookinfo/title"/>
135 </xsl:template>
136 <xsl:template match="refentry" mode="generate.devhelp2.toc.title.mode">
137 <xsl:value-of select="refmeta/refentrytitle"/>
138 </xsl:template>
139 <xsl:template match="*" mode="generate.devhelp2.toc.title.mode">
140 <xsl:value-of select="title"/>
141 </xsl:template>
143 <!-- generate list of authors ... -->
144 <xsl:template match="articleinfo|bookinfo" mode="generate.devhelp2.authors">
145 <xsl:for-each select="authorgroup/author">
146 <xsl:value-of select="firstname"/>
147 <xsl:text> </xsl:text>
148 <xsl:value-of select="surname"/>
149 <xsl:if test="not(last())">
150 <xsl:text>, </xsl:text>
151 </xsl:if>
152 </xsl:for-each>
153 </xsl:template>
155 </xsl:stylesheet>