xsl-list
[Top] [All Lists]

Re: a nicer total sibling count than this

2002-09-18 18:55:05
Macaulay,Malcolm (US) wrote:

You don't need all the counting stuff. If I understand you correctly,
the test is simply: "is there a preceding def element?".

that's not quite the case. What I'm needing to do is number *all* the defs if 
there are more than one. F'rinstance, given:

<psp type="n">
       <def>physical or mental ...</def>
       <def>a condition in which ...</def>
</psp>

I would want:

1 physical or mental ... 2 a condition in which ...

Using the stylesheet including '<xsl:if test="preceding-sibling::def">' gives me

physical or mental ... 2 a condition in which ...

-> the first def isn't getting numbered. Blame the weirdness on dictionary 
conventions.

Thanks also to Wendell, whose "count(../def) > 1" expression is probably the easiest to 
understand of all the solutions, and to Dimitre's "preceding-sibling::def or 
following-sibling::def" solution is very efficient and logical.

Stewart


XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list