Note that I posed a very similar question earlier but the requirements have since changed
http://stackoverflow.com/questions/3842719/alphanumeric-sort-on-mixed-string-value
The primary difference in the requirements now is that the source XML can include forms with all alpha chars in the form_name or all integers.
The form_name can be open season as letters and numbers can be in any order:
XX ## ##
XX XX ##
XX XX ###
XX XX ## ##
XX ###
XX XXXX
## XXX
XXX###
XXX
###
Given XML of:
<forms>
<FORM lob="BO" form_name="AI OM 10"/>
<FORM lob="BO" form_name="CL BP 03 01"/>
<FORM lob="BO" form_name="AI OM 107"/>
<FORM lob="BO" form_name="CL BP 00 02"/>
<FORM lob="BO" form_name="123 DDE"/>
<FORM lob="BO" form_name="CL BP 00 02"/>
<FORM lob="BO" form_name="AI OM 98"/>
<FORM lob="BO" form_name="543 ZZE"/>
<FORM lob="BO" form_name="543 ABC"/>
<FORM lob="BO" form_name="256"/>
<FORM lob="BO" form_name="ABC"/>
</forms>
The output should be:
<forms>
<FORM lob="BO" form_name="256"/>
<FORM lob="BO" form_name="123 DDE"/>
<FORM lob="BO" form_name="543 ABC"/>
<FORM lob="BO" form_name="543 ZZE"/>
<FORM lob="BO" form_name="ABC"/>
<FORM lob="BO" form_name="AI OM 10"/>
<FORM lob="BO" form_name="AI OM 98"/>
<FORM lob="BO" form_name="AI OM 107"/>
<FORM lob="BO" form_name="CL BP 00 02"/>
<FORM lob="BO" form_name="CL BP 00 02"/>
<FORM lob="BO" form_name="CL BP 03 01"/>
</forms>
The results should be in this order:
- Forms with integers only
- Forms that start of with integers but also include alpha characters (can include spaces)
- Forms that only include alpha characters
- Forms that start off with an alpha character but also include integers (can include spaces)
So like forms are grouped/sorted. I have tried various enhancements to the answers provided in my previous referenced question but have not hit upon the right filtering pattern for the sorts. XSLT 2.0 solutions are fine.