Numbering Things: Collected Data and Enumeration
How to use the collected enumeration data to number things in output.
The collected data includes data specifically designed to make numbering (enumeration) easy. The enumeration structure reflects the entire publication (root map) and contains the minimum amount of structure and data needed to number things, generate navigation lists, resolved cross references, and so on. This includes all topics, figures and tables with titles, sections, examples, and all div-type elements (<bodydiv>
, <sectiondiv>
, <div>
).
<mapdriven:collected-data xmlns:mapdriven="http://dita4publishers.org/mapdriven" xmlns:index-terms="http://dita4publishers.org/index-terms" xmlns:enum="http://dita4publishers.org/enumerables"> <enum:enumerables> <frontmatter xmlns="http://dita4publishers.org/enumerables" class="+ map/topicref pubmap-d/frontmatter " sourceId="-frontmatter-22-110-121" xtrc="frontmatter:1" docUri="file:/Users/ekimber/workspace/ebook-conversion/dita/temp/epub/Tax-Preparation.ditamap"> <inside-front-cover class="+ map/topicref pubmap-d/inside-front-cover " sourceId="-inside-front-cover-23-118-52" xtrc="inside-front-cover:1" docUri="file:/Users/ekimber/workspace/ebook-conversion/dita/temp/epub/Tax-Preparation.ditamap"> <title>Front Cover</title> </inside-front-cover> <preface class="+ map/topicref pubmap-d/preface " sourceId="-preface-30-112-69" xtrc="preface:1" docUri="file:/Users/ekimber/workspace/ebook-conversion/dita/temp/epub/Tax-Preparation.ditamap"> <title>Copyright Page</title> </preface> </frontmatter> ... </enum:enumerables> ... </mapdriven:collected-data>
The <enum:enumerables>
reflects the hierarchical structure of the publication. Each element reflects its DITA @
value, the URI of the source document it came from, and its "source ID", which is a unique identifier for the element constructed from its original context. The source ID is generated by the DITA utilities function df:generate-dita-id().@class
... <xsl:variable name="sourceId" select="df:generate-dita-id(.)" as="xs:string"/> <span class="figcap"> <xsl:apply-templates select="$collected-data/enum:enumerables//*[@sourceId = $sourceId]" mode="enumeration"/> <xsl:apply-templates select="*[contains(@class,' topic/title ')]" mode="figtitle"/> </span> ...
<xsl:template mode="enumeration" match="*[df:class(., 'topic/fig')][enum:title]"> <!-- Context item should be enum:* from the collected-data NOTE: Within the collected data, all titles are normalized to enum:title with no @class attribute. --> <span class="enumeration fig-enumeration"> <xsl:text>Figure </xsl:text> <xsl:number count="*[df:class(., 'topic/fig')][enum:title]" level="any" format="1." /> <xsl:text> </xsl:text> </span> </xsl:template>
Note that in this template, the usual <xsl:number>
facility is used to number the figure. Because the enumeration data reflects the entire publication you can number figures across the entire publication, as in this example. Because the enumeration data also includes all the topic and topicheads in their map-defined hierarchy, you could also number things at a part, chapter, or other level, as long as it's provided for in the enumeration structure.