xsl-list
[Top] [All Lists]

[xsl] for-each-group, group-starting-with - group based on attribute value of first child... possible?

2007-02-11 20:26:26
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(_dot_)poff(_at_)headfirst(_dot_)co(_dot_)nz
Ph:     64 4 477 6075
Mob:    027 229 9584

http://www.headfirst.co.nz

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>