|
12 | 12 | encoding="UTF-8"/>
|
13 | 13 | <xsl:preserve-space elements="*"/>
|
14 | 14 |
|
15 |
| -<!-- Do add border div for figure images in cookbook series --> |
16 |
| -<xsl:param name="figure.border.div" select="1"/> |
17 | 15 |
|
18 | 16 |
|
19 | 17 | <!-- Generate separate footnote-call markers, so that we don't
|
20 | 18 | need to rely on AH counters to do footnote numbering -->
|
21 | 19 | <xsl:param name="process.footnote.callouts.only" select="1"/>
|
22 | 20 |
|
| 21 | +<!-- ***************** COOKBOOK PARAMS ***************** --> |
| 22 | +<!-- *************** Overrides param.xsl *************** --> |
| 23 | + |
| 24 | +<!-- Recipe format should be "X.1 Title, no second period" --> |
| 25 | +<xsl:param name="recipe.number.and.title.separator" select="' '"/> |
| 26 | + |
| 27 | +<!-- This book should show sect2s in TOC --> |
| 28 | +<xsl:param name="toc.section.depth" select="2"/> |
| 29 | + |
| 30 | +<!-- ***************** LABEL HANDLING ***************** --> |
| 31 | +<!-- ************* Overrides common.xsl *************** --> |
| 32 | + |
| 33 | + <!-- Logic for processing sect1 headings with labels (including section numbers) --> |
| 34 | + <xsl:template match="h:section[@data-type='chapter' and not(contains(@class, 'orm:non-recipe'))]/h:section[@data-type='sect1' and not(contains(@class, 'orm:non-recipe'))]/h:h1" mode="process-heading"> |
| 35 | + <xsl:param name="autogenerate.labels" select="$autogenerate.labels"/> |
| 36 | + <!-- Labeled element is typically the parent element of the heading (e.g., <section> or <figure>) --> |
| 37 | + <xsl:param name="labeled-element" select="(parent::h:header/parent::*|parent::*[not(self::h:header)])[1]"/> |
| 38 | + <!-- Labeled element semantic name is typically the parent element of the heading's @data-type --> |
| 39 | + <xsl:param name="labeled-element-semantic-name" select="(parent::h:header/parent::*|parent::*[not(self::h:header)])[1]/@data-type"/> |
| 40 | + <!-- Name for output heading element; same as current node name by default --> |
| 41 | + <xsl:param name="output-element-name" select="local-name(.)"/> |
| 42 | + <xsl:element name="{$output-element-name}" namespace="http://www.w3.org/1999/xhtml"> |
| 43 | + <xsl:apply-templates select="@*"/> |
| 44 | + <!-- BEGIN COOKBOOK OVERRIDE --> |
| 45 | + <!-- Recipes should have labels in format #.# --> |
| 46 | + <xsl:apply-templates select="$labeled-element" mode="label.markup"/> |
| 47 | + <xsl:value-of select="$recipe.number.and.title.separator"/> |
| 48 | + <xsl:apply-templates/> |
| 49 | + <!-- END COOKBOOK OVERRIDE --> |
| 50 | + </xsl:element> |
| 51 | + </xsl:template> |
23 | 52 |
|
24 | 53 | <!-- Logic for processing sect2 headings with labels (including section numbers) -->
|
25 | 54 | <xsl:template match="h:section[@data-type='sect2']/h:h2" mode="process-heading">
|
|
32 | 61 | <xsl:param name="output-element-name" select="local-name(.)"/>
|
33 | 62 | <xsl:element name="{$output-element-name}" namespace="http://www.w3.org/1999/xhtml">
|
34 | 63 | <xsl:apply-templates select="@*"/>
|
35 |
| - |
| 64 | + <!-- BEGIN COOKBOOK OVERRIDE --> |
| 65 | + <!-- Recipes should have labels in format #.# --> |
| 66 | + <xsl:apply-templates select="$labeled-element" mode="label.markup"/> |
| 67 | + <xsl:value-of select="$recipe.number.and.title.separator"/> |
| 68 | + <xsl:apply-templates/> |
| 69 | + <!-- END COOKBOOK OVERRIDE --> |
36 | 70 | </xsl:element>
|
37 | 71 | </xsl:template>
|
38 | 72 |
|
39 | 73 | <!-- Creating the sect1 labels (read: creating the X.X section numbering) -->
|
40 | 74 | <xsl:template match="h:section[@data-type='sect1']" mode="label.markup">
|
41 | 75 | <xsl:variable name="current-node" select="."/>
|
| 76 | + <!-- BEGIN COOKBOOK OVERRIDE --> |
| 77 | + <!-- Recipes should always be labeled with ancestor chapter --> |
| 78 | + <xsl:for-each select="ancestor::h:section[@data-type='chapter']"> |
| 79 | + <xsl:call-template name="get-label-from-data-type"> |
| 80 | + <xsl:with-param name="data-type" select="@data-type"/> |
| 81 | + </xsl:call-template> |
| 82 | + <xsl:apply-templates select="$current-node" mode="intralabel.punctuation"/> |
| 83 | + </xsl:for-each> |
| 84 | + |
| 85 | + <!-- Custom Recipe numbering logic: |
| 86 | + * Don't number Recipes with class=orm:non-recipe |
| 87 | + * Introduction sections at the beginning of chapters have labeling start at #.0 |
| 88 | + --> |
| 89 | + <xsl:variable name="is.numbered"> |
| 90 | + <xsl:choose> |
| 91 | + <xsl:when test="@class='orm:non-recipe'">1</xsl:when> |
| 92 | + <xsl:otherwise>0</xsl:otherwise> |
| 93 | + </xsl:choose> |
| 94 | + </xsl:variable> |
| 95 | + |
| 96 | + <xsl:variable name="chap.has.intro"> |
| 97 | + <xsl:choose> |
| 98 | + <xsl:when test="$is.numbered = 0"> |
| 99 | + <xsl:call-template name="check.chap.for.intro"> |
| 100 | + <xsl:with-param name="chapter" select="parent::*"/> |
| 101 | + </xsl:call-template> |
| 102 | + </xsl:when> |
| 103 | + <xsl:otherwise>1</xsl:otherwise> |
| 104 | + </xsl:choose> |
| 105 | + </xsl:variable> |
42 | 106 |
|
| 107 | + <xsl:variable name="recipe.level"> |
| 108 | + <xsl:value-of select="count(preceding-sibling::h:section[@data-type='sect1']) + (1 - $chap.has.intro - $is.numbered)"/> |
| 109 | + </xsl:variable> |
| 110 | + <xsl:number format="1" value="$recipe.level"/> |
| 111 | + |
| 112 | + <!-- END COOKBOOK OVERRIDE --> |
43 | 113 | </xsl:template>
|
44 | 114 |
|
45 | 115 | <!-- Creating the sect2 labels (read: creating the X.X.X section numbering) -->
|
46 | 116 | <xsl:template match="h:section[@data-type='sect2']" mode="label.markup">
|
47 | 117 | <!-- END OVERRIDE -->
|
48 | 118 | <xsl:variable name="current-node" select="."/>
|
| 119 | + <!-- BEGIN COOKBOOK OVERRIDE --> |
| 120 | + <!-- Recipes should always be labeled with ancestor chapter --> |
| 121 | + <xsl:for-each select="ancestor::h:section[@data-type='chapter']"> |
| 122 | + <xsl:call-template name="get-label-from-data-type"> |
| 123 | + <xsl:with-param name="data-type" select="@data-type"/> |
| 124 | + </xsl:call-template> |
| 125 | + <xsl:apply-templates select="$current-node" mode="intralabel.punctuation"/> |
| 126 | + </xsl:for-each> |
| 127 | + |
| 128 | + <!-- Custom Recipe numbering logic: |
| 129 | + * Don't number Recipes with class=orm:non-recipe |
| 130 | + * Introduction sections at the beginning of chapters have labeling start at #.0 |
| 131 | + --> |
| 132 | + <xsl:variable name="is.numbered"> |
| 133 | + <xsl:choose> |
| 134 | + <xsl:when test="parent::h:section/@class='orm:non-recipe'">1</xsl:when> |
| 135 | + <xsl:otherwise>0</xsl:otherwise> |
| 136 | + </xsl:choose> |
| 137 | + </xsl:variable> |
| 138 | + |
| 139 | + <xsl:variable name="chap.has.intro"> |
| 140 | + <xsl:choose> |
| 141 | + <xsl:when test="$is.numbered = 0"> |
| 142 | + <xsl:call-template name="check.chap.for.intro"> |
| 143 | + <xsl:with-param name="chapter" select="ancestor::h:section[data-type='chapter']"/> |
| 144 | + </xsl:call-template> |
| 145 | + </xsl:when> |
| 146 | + <xsl:otherwise>1</xsl:otherwise> |
| 147 | + </xsl:choose> |
| 148 | + </xsl:variable> |
| 149 | + |
| 150 | + <xsl:variable name="sect1.recipe.level"> |
| 151 | + <xsl:value-of select="count(../preceding-sibling::h:section[@data-type='sect1']) + (1 - $chap.has.intro - $is.numbered)"/> |
| 152 | + </xsl:variable> |
| 153 | + <xsl:number format="1" value="$sect1.recipe.level"/> |
| 154 | + <xsl:text>.</xsl:text> |
| 155 | + |
| 156 | + <xsl:variable name="is.sect1.numbered"> |
| 157 | + <xsl:choose> |
| 158 | + <xsl:when test="@class='orm:non-recipe'">1</xsl:when> |
| 159 | + <xsl:otherwise>0</xsl:otherwise> |
| 160 | + </xsl:choose> |
| 161 | + </xsl:variable> |
| 162 | + |
| 163 | + <xsl:variable name="sect1.has.intro"> |
| 164 | + <xsl:choose> |
| 165 | + <xsl:when test="$is.sect1.numbered = 0"> |
| 166 | + <xsl:call-template name="check.sect1.for.intro"> |
| 167 | + <xsl:with-param name="sect1" select="parent::*"/> |
| 168 | + </xsl:call-template> |
| 169 | + </xsl:when> |
| 170 | + <xsl:otherwise>1</xsl:otherwise> |
| 171 | + </xsl:choose> |
| 172 | + </xsl:variable> |
49 | 173 |
|
| 174 | + <xsl:variable name="recipe.level"> |
| 175 | + <xsl:value-of select="count(preceding-sibling::h:section[@data-type='sect2'][not(@class='orm:non-recipe')]) + (1 - $sect1.has.intro - $is.sect1.numbered)"/> |
| 176 | + </xsl:variable> |
| 177 | + <xsl:number format="1" value="$recipe.level"/> |
| 178 | + |
| 179 | + <!-- END COOKBOOK OVERRIDE --> |
50 | 180 | </xsl:template>
|
51 | 181 | <!-- Utility template -->
|
52 | 182 | <xsl:template name="check.chap.for.intro">
|
|
149 | 279 | <xsl:with-param name="object" select="."/>
|
150 | 280 | </xsl:call-template>
|
151 | 281 | </xsl:attribute>
|
152 |
| - |
| 282 | + <!-- BEGIN COOKBOOK OVERRIDE --> |
| 283 | + <xsl:if test="(self::h:section[@data-type='sect1'] and ancestor::h:section[@data-type='chapter'] or self::h:section[@data-type='sect2'] and ancestor::h:section[@data-type='sect1']) and not(ancestor-or-self::h:section[contains(@class, 'orm:non-recipe')])"> |
| 284 | + <xsl:variable name="toc-entry-label"> |
| 285 | + <xsl:apply-templates select="." mode="label.markup"/> |
| 286 | + </xsl:variable> |
| 287 | + <xsl:value-of select="normalize-space($toc-entry-label)"/> |
| 288 | + <xsl:value-of select="$recipe.number.and.title.separator"/> |
| 289 | + </xsl:if> |
| 290 | + <!-- END COOKBOOK OVERRIDE --> |
153 | 291 | <xsl:apply-templates select="." mode="title.markup"/>
|
154 | 292 | </a>
|
155 | 293 | <!-- Make sure there are descendants that conform to $toc.section.depth restrictions before generating nested TOC <ol> -->
|
|
0 commit comments