xsl-list
[Top] [All Lists]

Grouping and sorting using an unknown node name

2002-10-07 15:41:09
Hi,

I have been looking on various sites for ideas on the best way to do some
grouping/sorting, and I'm unsure of the best way to tackle it.
I've looked at the xsl:key but am not sure that this is appropriate for what
I'm doing.  The problem is that I have an unknown number of
element readings with unknown names (see example below), which means I don't
see how I can define an xsl:key.  For example, the readings
below contain Cond,TP and Turb.  The xml to be styled will vary (ie. there
may be less than these or more with names that cannot be known beforehand),
although all elements will have a child node called <ordinate>.

What I need to be able to do is group by the reading type (in alphabetical
order), and for each reading type values, they need to be in date order.

So for example the result would be:

Cond
1993-01-11         165
1993-02-10         154

TP
1993-01-11         0
1993-02-10         465

Turb
1993-01-11         0
1993-02-10         23

I'm thinking along the lines of finding out how many reading types there are
per reading (ie. in this case 3), and then for each reading
call a template which selects the first node of each reading which has an
ordinate value and repeat till n. I don't know whether this is the way to go
about this and still not sure of how to group by date in this instance.

Any advice would be much appreciated.

I'm using a Saxon windows binary processor

I have the following sample xml:

<Collection>
 <Group>
  <Reading>
   <Date>1993-02-10</Date>
   <SiteNumber>991001</SiteNumber>
   <Cond>
    <ordinate>154</ordinate>
   </Cond>
   <TP>
    <ordinate>465</ordinate>
   </TP>
   <Turb>
    <ordinate>23</ordinate>
   </Turb>
  </Reading>
 </Group>
 <Group>
  <Reading>
   <Date>1993-01-11</Date>
   <SiteNumber>991001</SiteNumber>
   <Cond>
    <ordinate>165</ordinate>
   </Cond>
   <TP>
    <ordinate>0</ordinate>
   </TP>
   <Turb>
    <ordinate>0</ordinate>
   </Turb>
  </Reading>
 </Group>
 ................
</Collection>

Thanks,

Trem



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



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