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

Add a level of structure?

Subject: Add a level of structure?
From: "Edmund Mitchell" <emitchell@xxxxxxxx>
Date: Sun, 19 Jun 2005 16:33:36 -0700
add a level
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.

Thanks for any help

E

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.