1 | <?xml version="1.0" encoding="utf-8"?>
|
---|
2 | <xsl:stylesheet
|
---|
3 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
4 | xmlns:exsl="http://exslt.org/common"
|
---|
5 | xmlns="http://docbook.org/ns/docbook"
|
---|
6 | exclude-result-prefixes="exsl"
|
---|
7 | version="1.0">
|
---|
8 |
|
---|
9 | <!-- $Id: topic-maker.xsl,v 1.3 2012-04-16 00:29:35 bobs Exp $ -->
|
---|
10 |
|
---|
11 | <!-- This stylesheet convert DocBook elements into topic element.
|
---|
12 | The chunking takes place elsewhere. -->
|
---|
13 |
|
---|
14 | <xsl:import href="../xhtml/docbook.xsl"/>
|
---|
15 |
|
---|
16 |
|
---|
17 | <xsl:param name="assembly.filename">myassembly.xml</xsl:param>
|
---|
18 | <xsl:param name="chunk.section.depth" select="3"/>
|
---|
19 | <xsl:param name="chunk.first.sections" select="1"/>
|
---|
20 | <xsl:param name="use.id.as.filename" select="1"/>
|
---|
21 | <xsl:param name="html.ext">.xml</xsl:param>
|
---|
22 | <xsl:param name="base.dir">topics/</xsl:param>
|
---|
23 | <xsl:param name="root.filename" select="local-name(/*)"/>
|
---|
24 | <xsl:param name="html.extra.head.links" select="0"/>
|
---|
25 | <xsl:param name="stylesheet.result.type">xhtml</xsl:param>
|
---|
26 | <xsl:param name="navig.showtitles" select="0"/>
|
---|
27 | <xsl:param name="suppress.navigation" select="1"/>
|
---|
28 | <xsl:param name="chunk.append"/>
|
---|
29 | <xsl:param name="chunk.quietly" select="0"/>
|
---|
30 | <xsl:param name="chunker.output.method" select="'xml'"/>
|
---|
31 | <xsl:param name="chunker.output.encoding" select="'UTF-8'"/>
|
---|
32 | <xsl:param name="chunker.output.indent" select="'no'"/>
|
---|
33 | <xsl:param name="chunker.output.omit-xml-declaration" select="'no'"/>
|
---|
34 | <xsl:param name="chunker.output.standalone" select="'no'"/>
|
---|
35 | <xsl:param name="chunker.output.doctype-public" select="''"/>
|
---|
36 | <xsl:param name="chunker.output.doctype-system" select="''"/>
|
---|
37 | <xsl:param name="namespace">http://docbook.org/ns/docbook</xsl:param>
|
---|
38 |
|
---|
39 | <!-- These elements are converted to topic elements -->
|
---|
40 | <xsl:param name="topic.elements">preface chapter article section</xsl:param>
|
---|
41 | <xsl:variable name="topic.list"
|
---|
42 | select="concat(' ', normalize-space($topic.elements), ' ')"/>
|
---|
43 |
|
---|
44 | <!-- Default behavior is identity copy -->
|
---|
45 | <xsl:template match="node()|@*">
|
---|
46 | <xsl:copy>
|
---|
47 | <xsl:apply-templates select="@*"/>
|
---|
48 | <xsl:apply-templates/>
|
---|
49 | </xsl:copy>
|
---|
50 | </xsl:template>
|
---|
51 |
|
---|
52 | <xsl:template match="preface|chapter|appendix|section|article">
|
---|
53 | <xsl:variable name="element.name">
|
---|
54 | <xsl:call-template name="element.name"/>
|
---|
55 | </xsl:variable>
|
---|
56 |
|
---|
57 | <xsl:element name="{$element.name}" namespace="{$namespace}">
|
---|
58 | <xsl:apply-templates select="@*"/>
|
---|
59 | <xsl:apply-templates/>
|
---|
60 | </xsl:element>
|
---|
61 | </xsl:template>
|
---|
62 |
|
---|
63 | <xsl:template name="element.name">
|
---|
64 | <xsl:param name="node" select="."/>
|
---|
65 |
|
---|
66 | <xsl:variable name="src.element" select="concat(' ', local-name($node), ' ')"/>
|
---|
67 | <xsl:choose>
|
---|
68 | <xsl:when test="contains($topic.list, $src.element)">
|
---|
69 | <xsl:text>topic</xsl:text>
|
---|
70 | </xsl:when>
|
---|
71 | <xsl:otherwise>
|
---|
72 | <xsl:value-of select="local-name($node)"/>
|
---|
73 | </xsl:otherwise>
|
---|
74 | </xsl:choose>
|
---|
75 | </xsl:template>
|
---|
76 |
|
---|
77 | </xsl:stylesheet>
|
---|
78 |
|
---|