[xsl] Simple m-n numbering within deeper m-m-...-n structure

Subject: [xsl] Simple m-n numbering within deeper m-m-...-n structure
From: "Trevor Nicholls" <trevor@xxxxxxxxxxxxxxxxxx>
Date: Thu, 21 Jul 2005 11:47:29 +1200
Hi

Doubtless this is trivial to anyone but a novice - but I'm a novice.

I have a document structure that contains sections nested to arbitrary
depth. Sections may have complex content but their ancestry will consist
only of sections (up to the document root).

I can number my sections (1, 2, 2-1, 2-1-1, 2-2, 3 etc.) but my problem is
where I want to generate labels for some of the components within the
sections (namely figures and tables). The numbers I generate for these need
to reflect their sequence within the top-level section (in other words, if
each of the sections in the above list contains a single table, then these
tables should be labelled 1-1, 2-1, 2-2, 2-3, 3-1).

I'm using the following expression:
  Table<xsl:text> </xsl:text>
  <xsl:number count="/document/section" level="single"/>
  <xsl:text>-</xsl:text>
followed by another <xsl:number>; but I can't figure out the right
expression for it:

  <xsl:number level="any"/>
      gives me 1-1, 2-2, 2-3, 2-4, 3-5
  <xsl:number count="/document/section//table"/>
      gives me 1-1, 2-1, 2-1, 2-1, 3-1

I expected both of those results but they aren't what I want.
I imagine that what I really want is
  <xsl:number count="table" from="{the /document/section node which is in
the context node's ancestral set}"/>

I'm sure there's an elegant way of putting that, but it is eluding me.

Cheers
Trevor

Current Thread