trying to create CodeType and child Code classes from this xml with Codes
in alphabetical order based upon <codeValue>

<codeType>
   <codeTypeValue>AddressType</codeTypeValue>

 -
<file:///C:/myFiles/sustain/documentation/conversion/newDawn/xmlCodeFiles/codes/AddressType.xml#>
<codes>
 -
<file:///C:/myFiles/sustain/documentation/conversion/newDawn/xmlCodeFiles/codes/AddressType.xml#>
 <code>
     <codeValue>B</codeValue>
     <description>Business</description>
 </code>

 -
<file:///C:/myFiles/sustain/documentation/conversion/newDawn/xmlCodeFiles/codes/AddressType.xml#>
 <code>
     <codeValue>CON</codeValue>
     <description>Confidential Address</description>
  </code>
</codes>
</codeType>



        CodeType codeType = new CodeType();
        XStream xstream = new XStream(new StaxDriver());
        SortableFieldKeySorter sorter = new SortableFieldKeySorter();
        sorter.registerFieldOrder(Code.class, new String[] { "codeValue" });
        xstream = new XStream(new PureJavaReflectionProvider(new
FieldDictionary(sorter)));

        try {
            xstream.alias("codeType", CodeType.class);
            xstream.alias("code", Code.class);
            codeType = (CodeType)xstream.fromXML(xml.getInputStream());
        }
        catch { ... }

jars:
xstream-1.4.7.jar
xpp3_min-1.1.4c.jar
xmlpull-1.1.3.1.jar

if i comment out:
xstream = new XStream(new PureJavaReflectionProvider(new
FieldDictionary(sorter)));

it works.

otherwise, all is null in CodeType

whats the most basic way to enable sorting in Xstream?

-thx

Reply via email to