RE: [xsl] numbering question

Subject: RE: [xsl] numbering question
From: "Trevor Nicholls" <trevor@xxxxxxxxxxxxxxxxxx>
Date: Wed, 24 Dec 2008 02:39:42 +1300
Thanks Michael

 - "For each countable node (taking them in document order), count how many
preceding siblings it has that also match the count pattern and add one for
the node itself."

I had misread this, thinking that the "sibling" relation was applied _after_
removing any nodes (at any level) that didn't match the count pattern. I'm
glad to have that corrected at last.

But I think I have the right expression for my problem here:

  count="/document | included | section[not(parent::included)]"

gives me exactly the right numbers everywhere.

This works because a "document" node will never appear anywhere except
directly under an "included" node or at the document root. But I was just
playing around with this expression to see how I would express the count if
it was, and found that

  count="/document | included | (section|document)[not(parent::included)]"

is invalid. Is there a more concise way of writing this expression than the
full version below?

  count="/document | included | section[not(parent::included)] |
document[not(parent::included)]"


Cheers
Trevor


-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx] 
Sent: Wednesday, 24 December 2008 12:49 a.m.
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] numbering question

Each 2nd-level <document> element is the first child of its parent, and
therefore gets the number 1.

Try count="/document | included | section"

(Or just generate the leading "1." by hand, as it's constant, and use
count="included | section").

Michael Kay
http://www.saxonica.com/

Current Thread