[geotk] Unmarshalling XML into ISO Objects
Martin Desruisseaux
martin.desruisseaux at geomatys.fr
Wed Feb 2 18:56:09 EST 2011
Hello Russ
Le 02/02/11 23:21, Russ Baker a écrit :
> We have metadata xml that I unmarshall into JAXB objects. For example, take
> the XML String below:
>
> <gmd:CI_ResponsibleParty (...snip...)>
>
> To unmarshall that into a
> org.geotoolkit.metadata.iso.citation.DefaultResponsibleParty, I would use the
> following method:
>
> (...snip...)
> retVal = (T) org.geotoolkit.xml.XML.unmarshal(xml);
> However, when I interrogate the DefaultResponsibleParty, I cannot access the
> attributes and use those in the equals method.
I just tried to your code with the XML provided in your file, and it worked for
me. A System.out.println(retVal) gave me the metadata content. I also tried an
arbitrary attribute:
System.out.println(retVal.getOrganisationName());
which worked as expected for me. I'm not sure which object you wanted to compare
with the "equals" method? Most metadata method returns InternationalString
object, not String, even if they look the same when printed with System.out.
Consequently the following will never work:
if (retVal.getOrganisationName().equals("NOAA"))
You need to use instead:
if (retVal.getOrganisationName().toString().equals("NOAA"))
(Of course a real application needs to check for null values first).
Is it the kind of equality tests you wanted to perform?
Regards,
Martin
More information about the Geotoolkit
mailing list