[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Count previous-siblings w/same attribute value up to

Subject: Count previous-siblings w/same attribute value up to attribute value - 1 possible?
From: "Lou Argyres" <Lou.Argyres@xxxxxxxxxxxx>
Date: Mon, 12 Dec 2011 16:54:28 -0800
 Count previous-siblings w/same attribute value up to
I hope this makes sense.

I have "flat" outline list structures, the numbering of which is
controlled by a "level" attribute, that I renumber based on name-spaced
change tracking tags where I need to output Accept-All and Reject-All
versions to be redlined in other application formats after
transformations. (They're good for unsophisticated users who have
trouble editing embedded lists.)

The best I've come up with is a recursive template to count previous
same level items and stop at a lower level (skipping adds/deletes as
needed).

Is there an XPATH-2 select that can count preceding-siblings up to the
first preceding @level = $lvl-1?

 <xsl:variable name="lvl" select="@level"/>
 ...
 ... select="(count(preceding-sibling::section[@level=$lvl]) + 1) -
count(preceding-sibling::section[@level=$lvl][not(following-sibling::sec
tion[preceding-sibling::section[@level=number($lvl)-1][1]])])"

picks up all previous same-level items.

<flatOutline>
 <item numDisplay="I." level="1" />
 <item numDisplay="II." level="1" />
  <item numDisplay="A." level="2" />
  <item numDisplay="B." level="2" />
  <item numDisplay="C." level="2" />
 <item numDisplay="III." level="1"/>
  <item numDisplay="A." level="2"/>
   <item numDisplay="1." level="3" />
   <item numDisplay="2." level="3" />
   <item numDisplay="3." level="3" />
   <item numDisplay="4." level="3" />
  <item numDisplay="B." level="2"/>
   <item numDisplay="1." level="3" />
   <item numDisplay="2." level="3" />
   <item numDisplay="3." level="3" />
  <item numDisplay="C." level="2"/>
</flatOutline>

Lou Argyres
Continuing Education of the Bar - California
Oakland, CA
Lou.Argyres@xxxxxxxxxxxx

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.