Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
The
count
attribute defines which ancestor elements should be included. Usually, this is expressed as a union pattern, as in the example below:
format=“1.1.1. ”
level=“multiple”
count=“chapter | section | clause”/>
The effect of the rules is that a composite sequence number will be formed containing one component number for each ancestor (or the element itself) that is a
If the structure isn't regular, for example if there are sections that don't belong to a chapter, if there are clauses that have sections as siblings at the same level, or if there are sections nested within other sections, then the effects can be surprising, but a careful reading of the rules should explain what's going on.
A problem that sometimes occurs is that the numbering is context-sensitive. For example, within Chapter 1, clauses are numbered 1.2.3, but in Appendix A, they are numbered A.2.3. It's possible to achieve this effect by exploiting the fact that the format pattern is an attribute value template; for example, you could write:
select=“if (ancestor::chapter)
then ‘1.1.1 ’
else ‘A.1.1 ’”/>
format=“{$format}” level=“multiple”
count=“appendix | chapter | section | clause”/>
This assumes that
See Also
count()
function in Chapter 13 on page 733
position()
function in Chapter 13 on page 854
format-number()
function, in Chapter 7 on page 788
xsl:otherwise
The
Changes in 2.0
None.
Format