xsl-list
[Top] [All Lists]

Re: [xsl] Sorting by child element count

2010-12-29 09:43:53
Not hand counting, use stylesheet to do it for you. with xsl:copy p.e.

On Wed, Dec 29, 2010 at 4:39 PM, Mark <mark(_at_)knihtisk(_dot_)org> wrote:
Hi Michel,
Good idea if there is no better way. But since there are 400 <Item> elements
in the list and hand counting is subject to error, I was hoping to automate
the task. However, I can use this solution if no automated method is
forthcoming.
Regards,
Mark

-----Original Message----- From: Michel Hendriksen
Sent: Wednesday, December 29, 2010 7:36 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Sorting by child element count

Maybe not the best way but you could copy/preprocess the Item elements
and add an atribute with the number of Data elements. Then sort on the
attribute.

Michel

On Wed, Dec 29, 2010 at 4:21 PM, Mark <mark(_at_)knihtisk(_dot_)org> wrote:

Happy new year! Thanks for all the help this list has given me over the
past
two years. My question:

I have an XML document that looks like the listing below. I want to sort
the
<List> by <Item> so that all the <Items> with one <Data> element are
followed by all the <Items> with two <Data> elements, and so on, until the
last <Items> in the output list have the most <Data> elements. The <Data>
elements have to remain inside their original parent <Item>.

No clue how to begin. Can you point me in the right direction?

Thanks,
Mark

<List>
 <Item>
     <Data>...</Data>
         ... <!—possibly 1 to 10 or so <Data> elements in each parent
<Item> element.
     <Data>...</Data>
 </Item>
  ... <!—400 <Item> elements in the <List> –>
</List>



--~------------------------------------------------------------------
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>
--~--



--~------------------------------------------------------------------
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>
--~--




--~------------------------------------------------------------------
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>
--~--



--~------------------------------------------------------------------
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>
--~--