Hi Radu,

thanks for your help. I forgot to work out my need for the typed values:
Given an array of XmlObjects, I am supposed to deliver a sorted list of the distinct values.
With your hint my code actually looks like this:

Set extractDistinctValues(XmlObject[] xoArr) throws .CompareFailedException... {

 SortedSet result = new TreeSet();
for (XmlObject xo: xoArr){

   if (xo instanceof org.apache.xmlbeans.impl.values.XmlObjectBase){
       result.add(((XmlObjectBase)xo).getObjectValue()));
   } else if (xo instanceof XmlAnySimpleType)
        result.add(((XmlAnySimpleType) xo).getStringValue());
   } else{
       // trying to extract textValue from Cursor       
       result.add(getTextValue(xo.newCursor())); // dispose Cursor inside!
   }

 }
return result;

}

If I skipped the first if-closure with its use of (XmlObjectBase)xo).getObjectValue(), sorting would be done on Strings, even if xoArr contains Integer-Values only. So what I'm actually looking for, would be (XmlAnySimpleType)xo).getObjectValue().
Is there something like that?

Thanks in advance,

Siggi B.



Radu Preotiuc-Pietro wrote:
The correct way to do it would be:

if (xo instanceof XmlAnySimpleType)
    return ((XmlAnySimpleType) xo).getStringValue();

Radu
_______________________________________________________
Sulzer GmbH
Geschaeftsfuehrer: Dr. Johann Sulzer, Hildegard Sulzer,
Albert Euba, Hans-Dieter Panzer, Angelika Rudolph
Sitz und Registergericht: Stuttgart HRB 7608

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to