(dsssl) Sort child elements by attribute or data

Subject: (dsssl) Sort child elements by attribute or data
From: Tim McDaniel <tmcd@xxxxxxxxx>
Date: Sun, 23 Mar 2003 21:35:01 -0600 (CST)
(In case anyone cares about previous questions: I went ahead with

    <!DOCTYPE style-sheet
    PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
    <!ENTITY common SYSTEM "loar-common.dsl">


because I was already using that syntax in my XML input.  For another
question: I specified line spacing font-size on a "make sequence"
inside "root", and that cleaned up a lot of code.  But one attribute
that's not inherited, and therefore that I couldn't specify there, is
space-before:.  It turns out that it varied enough from paragraph to
paragraph that it really had to be specified in each case separately

Today's question: I have an existing structure that looks something

    <group groupname="West">
            ... lots of stuff ...
            <name>Zoe Noel</name>
            ... lots of stuff ...
            ... lots of stuff ...
            <name>Adam Smith</name>
            ... lots of stuff ...
            ... lots of stuff ...
            <name>Barbara Stanley</name>
            ... lots of stuff ...
    ... other groups with other items ...

Currently, I sort them by name by hand.  Is there any way that I could
sort them programmatically in Jade?  The big stumbling block I see is
getting the contents of
    <name>The Contents</name>
(The DTD says that a name can contain only #PCDATA, so at least
there's no complications there.)  Is the "data" function usable for
that?  Or "entity-text"?  If not, I suppose I could change it to be
    <name name="Zoe Noel"/>

Can someone outline how I might proceed if I can get the name?  I
think this might be doable: In the group element, process the
generalitem and generalcomment children (somehow), if any.  Call
(children) to get the child nodes, and do something (node-list-filter
using gi?) to extract only the item elements.  For each member of that
list X, generate a two-member list
where NAME is the name value for X and PROCESSED_ITEM is the sosofo
return value of processing X (is process-node-list available in
Jade?).  Then call a sort function (check the mailing list archives
first to see if someone already provided one) to sort the list by
NAME.  Then sosofo-append the PROCESSED_ITEM members in list order,
and that's the result.

Does that sound doable, or have I assumed a function that doesn't
exist in Jade, or is there an easier way?

Tim McDaniel (home); Reply-To: tmcd@xxxxxxxxx; work is tmcd@xxxxxxxxxxx

 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist

Current Thread