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

for-each-group, group-starting-with - group based on

Subject: for-each-group, group-starting-with - group based on attribute value of first child... possible?
From: Matt Poff <matt.poff@xxxxxxxxxxxxxxx>
Date: Mon, 12 Feb 2007 16:24:49 +1300
 for-each-group
Hi,

I'm a relative newbie with XSLT but have got about 90% of a conversion task taking XHTML describing table information to relational XML ready for a database. My problem is this, each row of the HTML table has varying number of columns, and I want to wrap certain rows of data in a new output element. Basically I'd like to cycle through table <tr> tags, check if the first child <td> tag of each row has a rowspan value of 2 or 5, and if so wrap the translated output from that row, and every row following it, with my new tags *until* I encounter a row with that row-span value again.

I've tried something like this (which XSLT doesn't seem to like):

   <xsl:template  match="table">
           <xsl:for-each-group  select="tr"
               group-starting-with="td/@colspan=5">
                   <xsl:value-of select="current-group()" />
           </xsl:for-each-group>
   </xsl:template>


Is it possible to create groups using a path to a nested node and an explicit evaluation? Also once I have these groups, what basic structure should I use to parse the contents of each group. I've already written code which successfully translates the values of <td> tags in the <table> but to date I haven't need to use grouping.


Any help greatly appreciated. I'm using XSLT 2.0 with the Saxon 8.1B processor.

Cheers,
Matt

-------------------------------------------------------------------
Matt Poff - Director

HEADFIRST LTD
Web Developers
Engaging | Useful | Works

Email:  matt.poff@xxxxxxxxxxxxxxx
Ph:     64 4 477 6075
Mob:    027 229 9584

http://www.headfirst.co.nz

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-2011 All Rights Reserved.