| 1 | <?xml version="1.0"?> |
|---|
| 2 | |
|---|
| 3 | <!-- |
|---|
| 4 | - Pre-process the spec before handing it over to standard DocBook. This allows |
|---|
| 5 | - using convenient shorthands that DocBook does not provide. Currently these |
|---|
| 6 | - shorthands are: |
|---|
| 7 | - |
|---|
| 8 | - <defterm>term</defterm> is converted to an <indexterm>, using "term" as |
|---|
| 9 | - the primary, with "preferred" significance. This is used to create a short |
|---|
| 10 | - index of "important terms" as an - appendix. |
|---|
| 11 | - |
|---|
| 12 | - <refterm>term</refterm> is converted to an <indexterm>, using "term" as |
|---|
| 13 | - the primary, with "normal" significance. This is used to add list of |
|---|
| 14 | - usage points to each "important terms" in the appendix. |
|---|
| 15 | --> |
|---|
| 16 | |
|---|
| 17 | <xsl:stylesheet |
|---|
| 18 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|---|
| 19 | version="1.0"> |
|---|
| 20 | |
|---|
| 21 | <!-- Generate the DOCBOOk DTD decleration. Can't copy it! --> |
|---|
| 22 | <xsl:output |
|---|
| 23 | method="xml" doctype-public="-//OASIS//DTD DocBook V4.2//EN" |
|---|
| 24 | doctype-system="http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" /> |
|---|
| 25 | |
|---|
| 26 | <!-- Convert uquote to userinput quote. --> |
|---|
| 27 | <xsl:template match="uquote" |
|---|
| 28 | ><quote |
|---|
| 29 | ><userinput |
|---|
| 30 | ><xsl:apply-templates select='*|text()' |
|---|
| 31 | /></userinput |
|---|
| 32 | ></quote |
|---|
| 33 | ></xsl:template> |
|---|
| 34 | |
|---|
| 35 | <!-- Convert defterm to index entry definition. --> |
|---|
| 36 | <xsl:template match="defterm" |
|---|
| 37 | ><indexterm significance="preferred" |
|---|
| 38 | ><primary><xsl:value-of select='@primary'/></primary |
|---|
| 39 | ><xsl:if test="@secondary" |
|---|
| 40 | ><secondary><xsl:value-of select='@secondary'/></secondary |
|---|
| 41 | ></xsl:if |
|---|
| 42 | ><xsl:if test="@tertiary" |
|---|
| 43 | ><tertiary><xsl:value-of select='@tertiary'/></tertiary |
|---|
| 44 | ></xsl:if |
|---|
| 45 | ></indexterm |
|---|
| 46 | ><firstterm |
|---|
| 47 | ><xsl:apply-templates select='*|text()' |
|---|
| 48 | /></firstterm |
|---|
| 49 | ></xsl:template> |
|---|
| 50 | |
|---|
| 51 | <!-- Convert refterm to index entry definition. --> |
|---|
| 52 | <xsl:template match="refterm" |
|---|
| 53 | ><indexterm significance="normal" |
|---|
| 54 | ><primary><xsl:value-of select='@primary'/></primary |
|---|
| 55 | ><xsl:if test="@secondary" |
|---|
| 56 | ><secondary><xsl:value-of select='@secondary'/></secondary |
|---|
| 57 | ></xsl:if |
|---|
| 58 | ><xsl:if test="@tertiary" |
|---|
| 59 | ><tertiary><xsl:value-of select='@tertiary'/></tertiary |
|---|
| 60 | ></xsl:if |
|---|
| 61 | ></indexterm |
|---|
| 62 | ><xsl:apply-templates select='*|text()' |
|---|
| 63 | /></xsl:template> |
|---|
| 64 | |
|---|
| 65 | <!-- Convert seeterm to index entry definition. --> |
|---|
| 66 | <xsl:template match="seeterm" |
|---|
| 67 | ><indexterm |
|---|
| 68 | ><primary><xsl:value-of select='@primary'/></primary |
|---|
| 69 | ><secondary><xsl:value-of select='@secondary'/></secondary |
|---|
| 70 | ><tertiary><xsl:value-of select='@tertiary'/></tertiary |
|---|
| 71 | ><see><xsl:value-of select='@see' /></see |
|---|
| 72 | ></indexterm |
|---|
| 73 | ></xsl:template> |
|---|
| 74 | |
|---|
| 75 | <!-- Convert seealso to index entry definition. --> |
|---|
| 76 | <xsl:template match="seealso" |
|---|
| 77 | ><indexterm |
|---|
| 78 | ><primary><xsl:value-of select='@primary'/></primary |
|---|
| 79 | ><secondary><xsl:value-of select='@secondary'/></secondary |
|---|
| 80 | ><tertiary><xsl:value-of select='@tertiary'/></tertiary |
|---|
| 81 | ><seealso><xsl:value-of select='@see' /></seealso |
|---|
| 82 | ></indexterm |
|---|
| 83 | ></xsl:template> |
|---|
| 84 | |
|---|
| 85 | <!-- Convert screen --> |
|---|
| 86 | <xsl:template match="screen" |
|---|
| 87 | ><screen |
|---|
| 88 | ><database |
|---|
| 89 | ><xsl:apply-templates select='*|text()' |
|---|
| 90 | /></database |
|---|
| 91 | ></screen |
|---|
| 92 | ></xsl:template> |
|---|
| 93 | |
|---|
| 94 | <!-- Convert programlisting --> |
|---|
| 95 | <xsl:template match="programlisting" |
|---|
| 96 | ><programlisting |
|---|
| 97 | ><database |
|---|
| 98 | ><xsl:apply-templates select='*|text()' |
|---|
| 99 | /></database |
|---|
| 100 | ></programlisting |
|---|
| 101 | ></xsl:template> |
|---|
| 102 | |
|---|
| 103 | <!-- Ignore html only --> |
|---|
| 104 | <xsl:template match="html" |
|---|
| 105 | ></xsl:template> |
|---|
| 106 | |
|---|
| 107 | <!-- Enforce keep-together --> |
|---|
| 108 | <xsl:template match="keep-together" |
|---|
| 109 | ><informaltable frame="none" |
|---|
| 110 | ><tgroup cols="1" |
|---|
| 111 | ><colspec |
|---|
| 112 | /><tbody |
|---|
| 113 | ><row |
|---|
| 114 | ><entry |
|---|
| 115 | ><xsl:apply-templates select='*|text()' |
|---|
| 116 | /></entry |
|---|
| 117 | ></row |
|---|
| 118 | ></tbody |
|---|
| 119 | ></tgroup |
|---|
| 120 | ></informaltable |
|---|
| 121 | ></xsl:template> |
|---|
| 122 | |
|---|
| 123 | <!-- Handle line break in productions --> |
|---|
| 124 | <xsl:template match="sbr" |
|---|
| 125 | ><xsl:if test="not(ancestor-or-self::hl1) |
|---|
| 126 | and not(ancestor-or-self::hl2) |
|---|
| 127 | and not(ancestor-or-self::hl3) |
|---|
| 128 | and not(ancestor-or-self::hl4)" |
|---|
| 129 | ><sbr |
|---|
| 130 | /><xsl:if test="ancestor-or-self::rhs" |
|---|
| 131 | ><xsl:call-template name="nbsps" |
|---|
| 132 | ><xsl:with-param name="number" select="string-length(../../lhs) + 4" |
|---|
| 133 | /></xsl:call-template |
|---|
| 134 | ></xsl:if |
|---|
| 135 | ></xsl:if |
|---|
| 136 | ></xsl:template> |
|---|
| 137 | |
|---|
| 138 | <!-- Emit a number of non-breaking spaces. --> |
|---|
| 139 | <xsl:template name="nbsps" |
|---|
| 140 | ><xsl:param name="number" |
|---|
| 141 | /><xsl:if test="$number > 0" |
|---|
| 142 | ><xsl:text> </xsl:text |
|---|
| 143 | ><xsl:call-template name="nbsps" |
|---|
| 144 | ><xsl:with-param name="number" select="$number - 1" |
|---|
| 145 | /></xsl:call-template |
|---|
| 146 | ></xsl:if |
|---|
| 147 | ></xsl:template> |
|---|
| 148 | |
|---|
| 149 | <!-- Slanted single quotes --> |
|---|
| 150 | <xsl:template match="q">’</xsl:template> |
|---|
| 151 | |
|---|
| 152 | <!-- Copy everything else unchanged. --> |
|---|
| 153 | <xsl:template match='*|@*' |
|---|
| 154 | ><xsl:copy |
|---|
| 155 | ><xsl:apply-templates select='node()|@*' |
|---|
| 156 | /></xsl:copy |
|---|
| 157 | ></xsl:template> |
|---|
| 158 | |
|---|
| 159 | </xsl:stylesheet> |
|---|