I have a smple xml

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Cox

    I have a smple xml

    <root >
    <employee id="111">Dougla s</employee>
    <wife n="1">Kitty</wife>
    <kid no="1">Polo</kid>
    <kid no="2">Paolo</kid>
    <wife num="2">Peck</wife>
    <kid no="1">Poke</kid>

    <employee id="000">Jitto </employee>
    <wife n="1">Kitten</wife>
    <kid no="1">Po</kid>
    </root>

    I'd like to sort them outputing into 2 ways, sort by id, sort by name
    of the emploee and in each sort, the subchilds also get sorted by
    number and by name.
    How can i do this ?

  • Joe Kesselman

    #2
    Re: I have a smple xml

    David Cox wrote:
    I'd like to sort them outputing into 2 ways, sort by id, sort by name
    of the emploee and in each sort, the subchilds also get sorted by
    number and by name.
    How can i do this ?
    First thing you want to do is fix your markup so you're consistant about
    whether the numbering attribute is called "num", "no", "n", or something
    else. The machine can't read your mind, and you really don't want to
    waste effort trying to explain that these all have the same intent.

    You also probably want to fix the hierarchy so each <employeeelemen t
    contains the related <wifeelements , and each <wifecontains its
    related <kid>s, rather than merely being followed by them. Indentation
    is not semantically useful; containment is.


    After fixing your document design problems, I'd suggest an XSLT
    stylesheet; this is a very standard application thereof.


    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry

    Comment

    Working...