[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Edmund,
I don't recall whether you received a response for this ... if not perhaps this will help. My approach would be to create a result tree fragment of the c's, in sorted order, then pick off 3 at a time and create groups. Of course, in this case you'll need to use the node-set extension function ... which makes some people squirm, but usually leads to shorter code. node-set is implemented by many processor under different guises.
Regards,
--A
_________________________________________________________________
On the road to retirement? Check out MSN Life Events for advice on how to get there! http://lifeevents.msn.com/category.aspx?cid=Retirement
RE: [xsl] Add a level of structure?
Subject: RE: [xsl] Add a level of structure? From: "Aron Bock" <aronbock@xxxxxxxxxxx> Date: Tue, 21 Jun 2005 15:38:32 +0000 |
Edmund,
I don't recall whether you received a response for this ... if not perhaps this will help. My approach would be to create a result tree fragment of the c's, in sorted order, then pick off 3 at a time and create groups. Of course, in this case you'll need to use the node-set extension function ... which makes some people squirm, but usually leads to shorter code. node-set is implemented by many processor under different guises.
Regards,
--A
From: "Edmund Mitchell" <emitchell@xxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: [xsl] Add a level of structure? Date: Sun, 19 Jun 2005 16:33:36 -0700
Hello all,
Source xml looks like this, can have between 0-9 c's:
<a> <b> <c> <c1>9</c1> <c2/> </c> <c> <c1>33</c1> <c2/> </c> <c> <c1>1</c1> <c2/> </c> <c> <c1>3</c1> <c2/> </c> <c> <c1>16</c1> <c2/> </c> <c> <c1>50</c1> <c2/> </c> </b> </a>
I need to first sort all the c's based on the value of their c1 child (a number, and the child always exists with the parent), then, for each three c's, put them inside another element, which also contains some hard-coded information that is dependent on the c group. Lastly, there will always be 3 groups, even if there aren't enough c's to justify the group's existence.
So the result needs to look something like:
<foo> <bar> <baz> <!-- since this is the first baz group, add some first-group specific stuff --> <x att="val" att2="val2"/> <y att="val" att2="val2"/> <!-- now the first three c's whose c1 child had the lowest value, in this case 1, 3, and 9 --> <c> <!-- some stuff based on the c whose c1 child was 1 --></c> <c> <!-- some stuff based on the c whose c1 child was 3 --></c> <c> <!-- some stuff based on the c whose c1 child was 9 --></c> </baz> <baz> <!-- since this is the 2nd baz group, add some 2nd-group specific stuff --> <q att="val" att2="val2"/> <r att="val" att2="val2"/> <!-- now the first three c's whose c1 child had the next-lowest value, in this case 16, 33 and 50 --> <c> <!-- some stuff based on the c whose c1 child was 16 --></c> <c> <!-- some stuff based on the c whose c1 child was 33 --></c> <c> <!-- some stuff based on the c whose c1 child was 50 --></c> </baz> <baz> <!-- since this is the 3rd baz group, add some third-group specific stuff --> <g att="val" att2="val2"/> <h att="val" att2="val2"/> <!-- nothing here, but the group, and the hard-coded stuff must appear --> <!-- if there was another 1-3 c's, they'd be in this group --> </baz> </bar> </foo>
I've been for-each-ing and postion()-ing myself to death all day; it's time to ask the Masters.
_________________________________________________________________
On the road to retirement? Check out MSN Life Events for advice on how to get there! http://lifeevents.msn.com/category.aspx?cid=Retirement
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Add a level of structure?, Sam D. Chuparkoff | Thread | Re: [xsl] How to select either Elem, Aron Bock |
Re: [xsl] xsl:include href - relati, Colin Paul Adams | Date | Re: [xsl] xsl:include href - relati, David Carlisle |
Month |
Keywords