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