1 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
2 | xmlns:exsl="http://exslt.org/common"
|
---|
3 | xmlns:xlink="http://www.w3.org/1999/xlink"
|
---|
4 | xmlns="http://docbook.org/ns/docbook"
|
---|
5 | version="1.0"
|
---|
6 | exclude-result-prefixes="exsl">
|
---|
7 |
|
---|
8 | <!-- ********************************************************************
|
---|
9 | $Id: topic-maker-chunk.xsl,v 1.7 2012-04-16 00:29:35 bobs Exp $
|
---|
10 | ********************************************************************
|
---|
11 | -->
|
---|
12 |
|
---|
13 | <xsl:import href="topic-maker.xsl"/>
|
---|
14 |
|
---|
15 | <xsl:import href="../xhtml/chunk-common.xsl"/>
|
---|
16 |
|
---|
17 | <xsl:include href="../xhtml/chunk-code.xsl"/>
|
---|
18 |
|
---|
19 | <xsl:param name="root.id.suffix">-info</xsl:param>
|
---|
20 | <xsl:param name="root.as.resourceref" select="1"/>
|
---|
21 |
|
---|
22 | <xsl:template match="/" priority="1">
|
---|
23 | <xsl:apply-templates select="/" mode="process.root"/>
|
---|
24 |
|
---|
25 | <xsl:call-template name="make.assembly"/>
|
---|
26 |
|
---|
27 | </xsl:template>
|
---|
28 |
|
---|
29 | <xsl:template name="chunk-element-content">
|
---|
30 | <xsl:param name="content">
|
---|
31 | <xsl:apply-imports/>
|
---|
32 | </xsl:param>
|
---|
33 |
|
---|
34 | <xsl:copy-of select="$content"/>
|
---|
35 | </xsl:template>
|
---|
36 |
|
---|
37 | <xsl:template name="make.assembly">
|
---|
38 | <xsl:variable name="content">
|
---|
39 | <assembly xmlns:xlink="http://www.w3.org/1999/xlink">
|
---|
40 | <xsl:call-template name="make.resources"/>
|
---|
41 | <xsl:call-template name="make.structure"/>
|
---|
42 | </assembly>
|
---|
43 | </xsl:variable>
|
---|
44 |
|
---|
45 | <xsl:variable name="filename">
|
---|
46 | <xsl:if test="$manifest.in.base.dir != 0">
|
---|
47 | <xsl:value-of select="$base.dir"/>
|
---|
48 | </xsl:if>
|
---|
49 | <xsl:value-of select="$assembly.filename"/>
|
---|
50 | </xsl:variable>
|
---|
51 |
|
---|
52 | <xsl:call-template name="write.chunk">
|
---|
53 | <xsl:with-param name="content" select="$content"/>
|
---|
54 | <xsl:with-param name="filename" select="$filename"/>
|
---|
55 | <xsl:with-param name="indent">yes</xsl:with-param>
|
---|
56 | </xsl:call-template>
|
---|
57 |
|
---|
58 | </xsl:template>
|
---|
59 |
|
---|
60 | <xsl:template name="make.structure">
|
---|
61 | <xsl:param name="root" select="/*[1]"/>
|
---|
62 |
|
---|
63 | <xsl:param name="root.resourceref">
|
---|
64 | <xsl:call-template name="object.id">
|
---|
65 | <xsl:with-param name="object" select="$root"/>
|
---|
66 | </xsl:call-template>
|
---|
67 | </xsl:param>
|
---|
68 |
|
---|
69 | <xsl:choose>
|
---|
70 | <xsl:when test="$root.as.resourceref = 0">
|
---|
71 | <structure>
|
---|
72 | <xsl:attribute name="type">
|
---|
73 | <xsl:value-of select="local-name($root)"/>
|
---|
74 | </xsl:attribute>
|
---|
75 | <xsl:attribute name="xml:id">
|
---|
76 | <xsl:value-of select="$root.resourceref"/>
|
---|
77 | </xsl:attribute>
|
---|
78 |
|
---|
79 | <xsl:copy-of select="($root/title | $root/info/title)[1]"/>
|
---|
80 |
|
---|
81 | <!-- Put the title and info stuff in a content-only module -->
|
---|
82 | <module resourceref="{$root.resourceref}{$root.id.suffix}" contentonly="true"/>
|
---|
83 | <xsl:apply-templates select="$root/*" mode="module.list"/>
|
---|
84 | </structure>
|
---|
85 | </xsl:when>
|
---|
86 | <xsl:otherwise>
|
---|
87 | <structure>
|
---|
88 | <xsl:attribute name="resourceref">
|
---|
89 | <xsl:value-of select="$root.resourceref"/>
|
---|
90 | </xsl:attribute>
|
---|
91 |
|
---|
92 | <output renderas="{local-name($root)}"/>
|
---|
93 |
|
---|
94 | <xsl:apply-templates select="$root/*" mode="module.list"/>
|
---|
95 | </structure>
|
---|
96 | </xsl:otherwise>
|
---|
97 | </xsl:choose>
|
---|
98 | </xsl:template>
|
---|
99 |
|
---|
100 | <xsl:template match="*" mode="module.list">
|
---|
101 | <xsl:variable name="is.chunk">
|
---|
102 | <xsl:call-template name="chunk">
|
---|
103 | <xsl:with-param name="node" select="."/>
|
---|
104 | </xsl:call-template>
|
---|
105 | </xsl:variable>
|
---|
106 |
|
---|
107 | <!-- generate an output element for renderas? -->
|
---|
108 | <xsl:variable name="src.element" select="concat(' ', local-name(.), ' ')"/>
|
---|
109 |
|
---|
110 | <xsl:variable name="is.topic">
|
---|
111 | <xsl:choose>
|
---|
112 | <xsl:when test="contains($topic.list, $src.element)">1</xsl:when>
|
---|
113 | <xsl:otherwise>0</xsl:otherwise>
|
---|
114 | </xsl:choose>
|
---|
115 | </xsl:variable>
|
---|
116 |
|
---|
117 | <xsl:if test="$is.chunk = 1">
|
---|
118 | <module>
|
---|
119 | <xsl:attribute name="resourceref">
|
---|
120 | <xsl:call-template name="object.id"/>
|
---|
121 | </xsl:attribute>
|
---|
122 |
|
---|
123 | <xsl:if test="$is.topic = 1">
|
---|
124 | <output renderas="{local-name()}"/>
|
---|
125 | </xsl:if>
|
---|
126 |
|
---|
127 | <xsl:apply-templates select="*" mode="module.list"/>
|
---|
128 | </module>
|
---|
129 | </xsl:if>
|
---|
130 | </xsl:template>
|
---|
131 |
|
---|
132 | <xsl:template name="make.resources">
|
---|
133 | <resources>
|
---|
134 | <!-- Add xml:base from $base.dir if manifest not in base.dir -->
|
---|
135 | <xsl:if test="string-length($base.dir) != 0 and
|
---|
136 | $manifest.in.base.dir = 0">
|
---|
137 | <xsl:attribute name="xml:base">
|
---|
138 | <!-- strip off trailing slash for xml:base -->
|
---|
139 | <xsl:choose>
|
---|
140 | <xsl:when test="substring($base.dir, string-length($base.dir),1) = '/'">
|
---|
141 | <xsl:value-of select="substring($base.dir, 1, string-length($base.dir) -1)"/>
|
---|
142 | </xsl:when>
|
---|
143 | <xsl:otherwise>
|
---|
144 | <xsl:value-of select="$base.dir"/>
|
---|
145 | </xsl:otherwise>
|
---|
146 | </xsl:choose>
|
---|
147 | </xsl:attribute>
|
---|
148 | </xsl:if>
|
---|
149 | <xsl:apply-templates select="/*[1]" mode="resource.list"/>
|
---|
150 | </resources>
|
---|
151 | </xsl:template>
|
---|
152 |
|
---|
153 | <xsl:template match="*" mode="resource.list">
|
---|
154 | <xsl:variable name="is.chunk">
|
---|
155 | <xsl:call-template name="chunk">
|
---|
156 | <xsl:with-param name="node" select="."/>
|
---|
157 | </xsl:call-template>
|
---|
158 | </xsl:variable>
|
---|
159 |
|
---|
160 | <xsl:if test="$is.chunk = 1">
|
---|
161 | <resource>
|
---|
162 | <xsl:attribute name="fileref">
|
---|
163 | <!--
|
---|
164 | <xsl:if test="$manifest.in.base.dir = 0">
|
---|
165 | <xsl:value-of select="$base.dir"/>
|
---|
166 | </xsl:if>
|
---|
167 | -->
|
---|
168 | <xsl:apply-templates select="." mode="chunk-filename"/>
|
---|
169 | </xsl:attribute>
|
---|
170 |
|
---|
171 | <xsl:attribute name="xml:id">
|
---|
172 | <xsl:call-template name="object.id"/>
|
---|
173 | </xsl:attribute>
|
---|
174 |
|
---|
175 | <xsl:variable name="title">
|
---|
176 | <xsl:apply-templates select="." mode="title.markup"/>
|
---|
177 | </xsl:variable>
|
---|
178 | <xsl:if test="string-length($title) != 0">
|
---|
179 | <description>
|
---|
180 | <xsl:value-of select="$title"/>
|
---|
181 | </description>
|
---|
182 | </xsl:if>
|
---|
183 |
|
---|
184 | </resource>
|
---|
185 | </xsl:if>
|
---|
186 |
|
---|
187 | <xsl:apply-templates select="*" mode="resource.list"/>
|
---|
188 | </xsl:template>
|
---|
189 |
|
---|
190 | <!-- special case for root id on structure element -->
|
---|
191 | <xsl:template match="/*" mode="resource.list">
|
---|
192 | <xsl:param name="root.resourceref">
|
---|
193 | <xsl:call-template name="object.id">
|
---|
194 | <xsl:with-param name="object" select="."/>
|
---|
195 | </xsl:call-template>
|
---|
196 | </xsl:param>
|
---|
197 |
|
---|
198 | <resource>
|
---|
199 | <xsl:attribute name="fileref">
|
---|
200 | <xsl:apply-templates select="." mode="chunk-filename"/>
|
---|
201 | </xsl:attribute>
|
---|
202 | <xsl:attribute name="xml:id">
|
---|
203 | <xsl:choose>
|
---|
204 | <xsl:when test="$root.as.resourceref = 0">
|
---|
205 | <xsl:value-of select="concat($root.resourceref,$root.id.suffix)"/>
|
---|
206 | </xsl:when>
|
---|
207 | <xsl:otherwise>
|
---|
208 | <xsl:value-of select="$root.resourceref"/>
|
---|
209 | </xsl:otherwise>
|
---|
210 | </xsl:choose>
|
---|
211 | </xsl:attribute>
|
---|
212 | </resource>
|
---|
213 | <xsl:apply-templates select="*" mode="resource.list"/>
|
---|
214 | </xsl:template>
|
---|
215 |
|
---|
216 | <!-- This one must be here because of the template in chunk-code.xsl -->
|
---|
217 | <xsl:template match="@fileref" priority="1">
|
---|
218 | <xsl:copy-of select="."/>
|
---|
219 | </xsl:template>
|
---|
220 |
|
---|
221 | </xsl:stylesheet>
|
---|