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"
6 exclude-result-prefixes="exsl">
8 <!-- ********************************************************************
9 $Id: topic-maker-chunk.xsl,v 1.7 2012-04-16 00:29:35 bobs Exp $
10 ********************************************************************
13 <xsl:import href="topic-maker.xsl"/>
15 <xsl:import href="../xhtml/chunk-common.xsl"/>
17 <xsl:include href="../xhtml/chunk-code.xsl"/>
19 <xsl:param name="root.id.suffix">-info</xsl:param>
20 <xsl:param name="root.as.resourceref" select="1"/>
22 <xsl:template match="/" priority="1">
23 <xsl:apply-templates select="/" mode="process.root"/>
25 <xsl:call-template name="make.assembly"/>
29 <xsl:template name="chunk-element-content">
30 <xsl:param name="content">
34 <xsl:copy-of select="$content"/>
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"/>
45 <xsl:variable name="filename">
46 <xsl:if test="$manifest.in.base.dir != 0">
47 <xsl:value-of select="$base.dir"/>
49 <xsl:value-of select="$assembly.filename"/>
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>
60 <xsl:template name="make.structure">
61 <xsl:param name="root" select="/*[1]"/>
63 <xsl:param name="root.resourceref">
64 <xsl:call-template name="object.id">
65 <xsl:with-param name="object" select="$root"/>
70 <xsl:when test="$root.as.resourceref = 0">
72 <xsl:attribute name="type">
73 <xsl:value-of select="local-name($root)"/>
75 <xsl:attribute name="xml:id">
76 <xsl:value-of select="$root.resourceref"/>
79 <xsl:copy-of select="($root/title | $root/info/title)[1]"/>
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"/>
88 <xsl:attribute name="resourceref">
89 <xsl:value-of select="$root.resourceref"/>
92 <output renderas="{local-name($root)}"/>
94 <xsl:apply-templates select="$root/*" mode="module.list"/>
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="."/>
107 <!-- generate an output element for renderas? -->
108 <xsl:variable name="src.element" select="concat(' ', local-name(.), ' ')"/>
110 <xsl:variable name="is.topic">
112 <xsl:when test="contains($topic.list, $src.element)">1</xsl:when>
113 <xsl:otherwise>0</xsl:otherwise>
117 <xsl:if test="$is.chunk = 1">
119 <xsl:attribute name="resourceref">
120 <xsl:call-template name="object.id"/>
123 <xsl:if test="$is.topic = 1">
124 <output renderas="{local-name()}"/>
127 <xsl:apply-templates select="*" mode="module.list"/>
132 <xsl:template name="make.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 -->
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)"/>
144 <xsl:value-of select="$base.dir"/>
149 <xsl:apply-templates select="/*[1]" mode="resource.list"/>
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="."/>
160 <xsl:if test="$is.chunk = 1">
162 <xsl:attribute name="fileref">
164 <xsl:if test="$manifest.in.base.dir = 0">
165 <xsl:value-of select="$base.dir"/>
168 <xsl:apply-templates select="." mode="chunk-filename"/>
171 <xsl:attribute name="xml:id">
172 <xsl:call-template name="object.id"/>
175 <xsl:variable name="title">
176 <xsl:apply-templates select="." mode="title.markup"/>
178 <xsl:if test="string-length($title) != 0">
180 <xsl:value-of select="$title"/>
187 <xsl:apply-templates select="*" mode="resource.list"/>
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="."/>
199 <xsl:attribute name="fileref">
200 <xsl:apply-templates select="." mode="chunk-filename"/>
202 <xsl:attribute name="xml:id">
204 <xsl:when test="$root.as.resourceref = 0">
205 <xsl:value-of select="concat($root.resourceref,$root.id.suffix)"/>
208 <xsl:value-of select="$root.resourceref"/>
213 <xsl:apply-templates select="*" mode="resource.list"/>
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="."/>