xsl-list
[Top] [All Lists]

[xsl] recursive sorting by element name

2007-11-28 15:04:43
Hi, consider the following example:

<Collection>
  <CollectionB>
     <B2></B2>
     <A2></A2>
     <A1></A1>
     <B1 typeName="2"></B1>
     <B1 typeName="1"></B1>
  </CollectionB>
  <CollectionA>
     <B2></B2>
     <A2></A2>
     <A1></A1>
     <B1></B1>
  </CollectionA>
</Collection>

I want to sort it as such

<Collection>
  <CollectionA>
      <A1></A1>
      <A2></A2>
      <B1></B1>
      <B2></B2>
  </CollectionA>
  <CollectionB>
      <A1></A1>
      <A2></A2>
      <B1 typeName="1"></B1>
      <B1 typeName="2"></B1>
      <B2></B2>
  </CollectionB>
</Collection>

I am trying to come up with a generic XSLT solution that does not use
explicit element names, but only uses the sort select="name()", and it
should be recursive such that if say, element <A1> contained further
elements, then they would also be sorted by element name.

Finally, if the element names are the same, then it should sort them
by an attribute called "typeName".

Can anyone provide some help?  Thank you in advance!

Regards,
davis

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

<Prev in Thread] Current Thread [Next in Thread>