Re: [xsl] hierarchic counting in flat structures

Subject: Re: [xsl] hierarchic counting in flat structures
From: Norbert Heidbrink <nh@xxxxxxxx>
Date: Fri, 2 Nov 2012 14:52:30 +0100
Hi Michael,

[Michael Kay]:
> <xsl:number from="H3" level="any"/>
>
> It's not the usual use case given for level="any", but I think it
> should work, provided that an H3 actually exists.

That works - almost. :-)
One detail remains to be dealt with.

The input XML I am working on is not the most professional one. ;-)

<DOK>
<H3>b&</H3>
  <H4>b&</H4>          <- "outer H4"
  <some>
    <tag>
      <H4>b&</H4>          <- "inner H4"
    </tag>
  </some>
  <H4>b&</H4>         <- "outer H4"
  b&
</DOK>

Of course, your solution counts all the "inner H4", too.
However, I don't want these to be be considered.

So, I extend your proposal a bit:
<xsl:number count="DOK/H4" from="H3" level="any"/>

And there we go - this yields the result I have been looking for.

Thanks for your help,
best wishes,
Norbert

Current Thread