<xsl:when test="@label">
<xsl:value-of select="@label"/>
</xsl:when>
- <xsl:when test="$part.autolabel != 0">
- <xsl:number from="book" count="part" format="I"/>
+ <xsl:when test="string($part.autolabel) != 0">
+ <xsl:variable name="format">
+ <xsl:call-template name="autolabel.format">
+ <xsl:with-param name="format" select="$part.autolabel"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:number from="book" count="part" format="{$format}"/>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:when test="@label">
<xsl:value-of select="@label"/>
</xsl:when>
- <xsl:when test="$preface.autolabel != 0">
+ <xsl:when test="string($preface.autolabel) != 0">
<xsl:if test="$component.label.includes.part.label != 0 and
ancestor::part">
<xsl:variable name="part.label">
mode="intralabel.punctuation"/>
</xsl:if>
</xsl:if>
+ <xsl:variable name="format">
+ <xsl:call-template name="autolabel.format">
+ <xsl:with-param name="format" select="$preface.autolabel"/>
+ </xsl:call-template>
+ </xsl:variable>
<xsl:choose>
<xsl:when test="$label.from.part != 0 and ancestor::part">
- <xsl:number from="part" count="preface" format="1" level="any"/>
+ <xsl:number from="part" count="preface" format="{$format}" level="any"/>
</xsl:when>
<xsl:otherwise>
- <xsl:number from="book" count="preface" format="1" level="any"/>
+ <xsl:number from="book" count="preface" format="{$format}" level="any"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="@label">
<xsl:value-of select="@label"/>
</xsl:when>
- <xsl:when test="$chapter.autolabel != 0">
+ <xsl:when test="string($chapter.autolabel) != 0">
<xsl:if test="$component.label.includes.part.label != 0 and
ancestor::part">
<xsl:variable name="part.label">
mode="intralabel.punctuation"/>
</xsl:if>
</xsl:if>
+ <xsl:variable name="format">
+ <xsl:call-template name="autolabel.format">
+ <xsl:with-param name="format" select="$chapter.autolabel"/>
+ </xsl:call-template>
+ </xsl:variable>
<xsl:choose>
<xsl:when test="$label.from.part != 0 and ancestor::part">
- <xsl:number from="part" count="chapter" format="1" level="any"/>
+ <xsl:number from="part" count="chapter" format="{$format}" level="any"/>
</xsl:when>
<xsl:otherwise>
- <xsl:number from="book" count="chapter" format="1" level="any"/>
+ <xsl:number from="book" count="chapter" format="{$format}" level="any"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="@label">
<xsl:value-of select="@label"/>
</xsl:when>
- <xsl:when test="$appendix.autolabel != 0">
+ <xsl:when test="string($appendix.autolabel) != 0">
<xsl:if test="$component.label.includes.part.label != 0 and
ancestor::part">
<xsl:variable name="part.label">
mode="intralabel.punctuation"/>
</xsl:if>
</xsl:if>
+ <xsl:variable name="format">
+ <xsl:call-template name="autolabel.format">
+ <xsl:with-param name="format" select="$appendix.autolabel"/>
+ </xsl:call-template>
+ </xsl:variable>
<xsl:choose>
<xsl:when test="$label.from.part != 0 and ancestor::part">
- <xsl:number from="part" count="appendix" format="A" level="any"/>
+ <xsl:number from="part" count="appendix" format="{$format}" level="any"/>
</xsl:when>
<xsl:otherwise>
<xsl:number from="book|article"
- count="appendix" format="A" level="any"/>
+ count="appendix" format="{$format}" level="any"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="@label">
<xsl:value-of select="@label"/>
</xsl:when>
- <xsl:when test="$part.autolabel != 0">
- <xsl:number from="book" count="reference" format="I" level="any"/>
+ <xsl:when test="string($part.autolabel) != 0">
+ <xsl:variable name="format">
+ <xsl:call-template name="autolabel.format">
+ <xsl:with-param name="format" select="$part.autolabel"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:number from="book" count="reference" format="{$format}" level="any"/>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:when test="@label">
<xsl:value-of select="@label"/>
</xsl:when>
- <xsl:when test="$label != 0">
- <xsl:number count="section"/>
+ <xsl:when test="$label != 0">
+ <xsl:variable name="format">
+ <xsl:call-template name="autolabel.format">
+ <xsl:with-param name="format" select="$section.autolabel"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:number format="{$format}" count="section"/>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:value-of select="@label"/>
</xsl:when>
<xsl:when test="$is.numbered != 0">
+ <xsl:variable name="format">
+ <xsl:call-template name="autolabel.format">
+ <xsl:with-param name="format" select="$section.autolabel"/>
+ </xsl:call-template>
+ </xsl:variable>
<xsl:copy-of select="$component.label"/>
- <xsl:number count="sect1"/>
+ <xsl:number format="{$format}" count="sect1"/>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:value-of select="@label"/>
</xsl:when>
<xsl:when test="$is.numbered != 0">
+ <xsl:variable name="format">
+ <xsl:call-template name="autolabel.format">
+ <xsl:with-param name="format" select="$section.autolabel"/>
+ </xsl:call-template>
+ </xsl:variable>
<xsl:choose>
<xsl:when test="local-name(.) = 'sect2'">
- <xsl:number count="sect2"/>
+ <xsl:number format="{$format}" count="sect2"/>
</xsl:when>
<xsl:when test="local-name(.) = 'sect3'">
- <xsl:number count="sect3"/>
+ <xsl:number format="{$format}" count="sect3"/>
</xsl:when>
<xsl:when test="local-name(.) = 'sect4'">
- <xsl:number count="sect4"/>
+ <xsl:number format="{$format}" count="sect4"/>
</xsl:when>
<xsl:when test="local-name(.) = 'sect5'">
- <xsl:number count="sect5"/>
+ <xsl:number format="{$format}" count="sect5"/>
</xsl:when>
<xsl:otherwise>
<xsl:message>label.markup: this can't happen!</xsl:message>
<xsl:value-of select="@label"/>
</xsl:when>
<xsl:when test="$section.autolabel != 0">
- <xsl:number count="refsect1"/>
+ <xsl:variable name="format">
+ <xsl:call-template name="autolabel.format">
+ <xsl:with-param name="format" select="$section.autolabel"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:number count="refsect1" format="{$format}"/>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:value-of select="@label"/>
</xsl:when>
<xsl:when test="$section.autolabel != 0">
+ <xsl:variable name="format">
+ <xsl:call-template name="autolabel.format">
+ <xsl:with-param name="format" select="$section.autolabel"/>
+ </xsl:call-template>
+ </xsl:variable>
<xsl:choose>
<xsl:when test="local-name(.) = 'refsect2'">
- <xsl:number count="refsect2"/>
+ <xsl:number count="refsect2" format="{$format}"/>
</xsl:when>
<xsl:otherwise>
- <xsl:number count="refsect3"/>
+ <xsl:number count="refsect3" format="{$format}"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:value-of select="@label"/>
</xsl:when>
<xsl:when test="$label != 0">
- <xsl:number count="simplesect"/>
+ <xsl:variable name="format">
+ <xsl:call-template name="autolabel.format">
+ <xsl:with-param name="format" select="$section.autolabel"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:number format="{$format}" count="simplesect"/>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:choose>
<xsl:when test="$qandadiv.autolabel != 0">
+ <xsl:variable name="format">
+ <xsl:call-template name="autolabel.format">
+ <xsl:with-param name="format" select="$qandadiv.autolabel"/>
+ </xsl:call-template>
+ </xsl:variable>
<xsl:value-of select="$prefix"/>
- <xsl:number level="multiple" count="qandadiv" format="1"/>
+ <xsl:number level="multiple" count="qandadiv" format="{$format}"/>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:variable name="prefix">
<xsl:if test="$qanda.inherit.numeration != 0">
<xsl:choose>
- <xsl:when test="ancestor::qandadiv">
- <xsl:apply-templates select="ancestor::qandadiv[1]" mode="label.markup"/>
- <xsl:apply-templates select="ancestor::qandadiv[1]"
- mode="intralabel.punctuation"/>
- </xsl:when>
- <xsl:when test="$lparent.prefix != ''">
- <xsl:apply-templates select="$lparent" mode="label.markup"/>
- <xsl:apply-templates select="$lparent" mode="intralabel.punctuation"/>
- </xsl:when>
+ <xsl:when test="ancestor::qandadiv">
+ <xsl:apply-templates select="ancestor::qandadiv[1]" mode="label.markup"/>
+ <xsl:apply-templates select="ancestor::qandadiv[1]"
+ mode="intralabel.punctuation"/>
+ </xsl:when>
+ <xsl:when test="$lparent.prefix != ''">
+ <xsl:apply-templates select="$lparent" mode="label.markup"/>
+ <xsl:apply-templates select="$lparent" mode="intralabel.punctuation"/>
+ </xsl:when>
</xsl:choose>
</xsl:if>
</xsl:variable>
<xsl:apply-templates select="$pchap" mode="intralabel.punctuation"/>
</xsl:if>
<xsl:number count="procedure[title]" format="1"
- from="chapter|appendix" level="any"/>
+ from="chapter|appendix" level="any"/>
</xsl:when>
<xsl:otherwise>
<xsl:number count="procedure[title]" format="1"
- from="book|article" level="any"/>
+ from="book|article" level="any"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:variable>
<xsl:choose>
- <xsl:when test="$level <= $section.autolabel.max.depth">
+ <xsl:when test="$level <= $section.autolabel.max.depth">
<xsl:value-of select="$section.autolabel"/>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
<!-- ============================================================ -->
+<xsl:template name="default.autolabel.format">
+ <xsl:param name="context" select="."/>
+ <xsl:choose>
+ <xsl:when test="local-name($context) = 'appendix'">
+ <xsl:value-of select="'A'"/>
+ </xsl:when>
+ <xsl:when test="local-name($context) = 'part'">
+ <xsl:value-of select="'I'"/>
+ </xsl:when>
+ <xsl:otherwise>1</xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="autolabel.format">
+ <xsl:param name="context" select="."/>
+ <xsl:param name="format"/>
+
+ <xsl:choose>
+ <xsl:when test="string($format) != 0">
+ <xsl:choose>
+ <xsl:when test="$format='arabic' or $format='1'">1</xsl:when>
+ <xsl:when test="$format='loweralpha' or $format='a'">
+ <xsl:value-of select="'a'"/>
+ </xsl:when>
+ <xsl:when test="$format='lowerroman' or $format='i'">
+ <xsl:value-of select="'i'"/>
+ </xsl:when>
+ <xsl:when test="$format='upperalpha' or $format='A'">
+ <xsl:value-of select="'A'"/>
+ </xsl:when>
+ <xsl:when test="$format='upperroman' or $format='I'">
+ <xsl:value-of select="'I'"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message>
+ <xsl:text>Unexpected </xsl:text><xsl:value-of select="local-name(.)"/><xsl:text>.autolabel value: </xsl:text>
+ <xsl:value-of select="$format"/><xsl:text>; using default.</xsl:text>
+ </xsl:message>
+ <xsl:call-template name="default.autolabel.format"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ </xsl:choose>
+</xsl:template>
+
+<doc:template name="autolabel.format" xmlns="">
+<refpurpose>Returns format for autolabel parameters</refpurpose>
+<refdescription>
+<para>Returns format passed as parameter if non zero. Supported
+ format are 'arabic' or '1', 'loweralpha' or 'a', 'lowerroman' or 'i',
+ 'uppoerlapha' or 'A', 'upperroman' or 'I'. If its not one of these then
+ returns the default format.</para>
+</refdescription>
+</doc:template>
+
+<!-- ============================================================ -->
+
</xsl:stylesheet>