users@jaxb.java.net

xsi:nil problem on repeated marshalling-unmarshalling operations

From: boldra <boldra_at_gmail.com>
Date: Wed, 17 Mar 2010 01:32:06 -0700 (PDT)

Dear all,

I have a problem if upgrading to JAXB versions > 2.1.9. I think it is
consequence of this related fix:
https://jaxb.dev.java.net/issues/show_bug.cgi?id=565

The problem is observed on repeated marshalling/unmarshalling operations:
MARSHALLING->UNMARSHALLING->MARSHALLING->UNMARSHALLING
Details follow:

This is the marshalling of an instance of my class MDMetadata (generated
from schemas at:
http://schemas.opengis.net/csw/2.0.2/profiles/apiso/1.0.0/apiso.xsd)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<gmd:MD_Metadata xmlns:gml="http://www.opengis.net/gml"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:gmd="http://www.isotc211.org/2005/gmd"
xmlns:gco="http://www.isotc211.org/2005/gco"
xmlns:gmx="http://www.isotc211.org/2005/gmx"
xmlns:srv="http://www.isotc211.org/2005/srv"
xmlns:gts="http://www.isotc211.org/2005/gts"
xmlns:wrs="http://www.opengis.net/cat/wrs/1.0"
xmlns:dct="http://purl.org/dc/terms/"
xmlns:csw="http://www.opengis.net/cat/csw/2.0.2"
xmlns:apiso="http://www.opengis.net/cat/csw/apiso/1.0"
xmlns:gsr="http://www.isotc211.org/2005/gsr"
xmlns:rim="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0"
xmlns:ows="http://www.opengis.net/ows"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.isotc211.org/2005/gmd
http://schemas.opengis.net/csw/2.0.2/profiles/apiso/1.0.0/apiso.xsd">
<gmd:hierarchyLevel>
<gmd:MD_ScopeCode
codeList="http://www.isotc211.org/2005/resources/codeList.xml#MD_ScopeCode"
codeListValue="service"></gmd:MD_ScopeCode>
</gmd:hierarchyLevel>
<gmd:contact xlink:type="simple"/>
<gmd:dateStamp>
<gco:Date xsi:nil="true"/>
</gmd:dateStamp>
<gmd:identificationInfo xlink:type="simple">
<srv:SV_ServiceIdentification>
<gmd:citation xlink:type="simple">
<gmd:CI_Citation>
<gmd:title>
<gco:CharacterString>My CSW/ISO</gco:CharacterString>
</gmd:title>
<gmd:alternateTitle>
<gco:CharacterString></gco:CharacterString>
</gmd:alternateTitle>
<gmd:date xlink:type="simple"/>
</gmd:CI_Citation>
</gmd:citation>
<gmd:abstract>
<gco:CharacterString></gco:CharacterString>
</gmd:abstract>
<srv:serviceType>
<gco:LocalName>CSW</gco:LocalName>
</srv:serviceType>
<srv:serviceTypeVersion>
<gco:CharacterString>2.0.2</gco:CharacterString>
</srv:serviceTypeVersion>
<srv:couplingType/>
<srv:containsOperations xlink:type="simple"/>
</srv:SV_ServiceIdentification>
</gmd:identificationInfo>
</gmd:MD_Metadata>

If I take the above output as input to the unmarshaller, I get back a
MDMetadata object which has JAXBElement
identificationInfos->abstractMDIdentification->nil (wrongly IMHO) set to
true (while the original object had: false). Marshalling again I get in fact
an unexpected attribute xsi:nil="true" on srv:SV_ServiceIdentification, as
it is possible to see:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<gmd:MD_Metadata xmlns:gml="http://www.opengis.net/gml"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:gmd="http://www.isotc211.org/2005/gmd"
xmlns:gco="http://www.isotc211.org/2005/gco"
xmlns:gmx="http://www.isotc211.org/2005/gmx"
xmlns:srv="http://www.isotc211.org/2005/srv"
xmlns:gts="http://www.isotc211.org/2005/gts"
xmlns:wrs="http://www.opengis.net/cat/wrs/1.0"
xmlns:dct="http://purl.org/dc/terms/"
xmlns:csw="http://www.opengis.net/cat/csw/2.0.2"
xmlns:apiso="http://www.opengis.net/cat/csw/apiso/1.0"
xmlns:gsr="http://www.isotc211.org/2005/gsr"
xmlns:rim="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0"
xmlns:ows="http://www.opengis.net/ows"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.isotc211.org/2005/gmd
http://schemas.opengis.net/csw/2.0.2/profiles/apiso/1.0.0/apiso.xsd">
<gmd:hierarchyLevel>
<gmd:MD_ScopeCode
codeList="http://www.isotc211.org/2005/resources/codeList.xml#MD_ScopeCode"
codeListValue="service"></gmd:MD_ScopeCode>
</gmd:hierarchyLevel>
<gmd:contact xlink:type="simple"/>
<gmd:dateStamp>
<gco:Date xsi:nil="true"/>
</gmd:dateStamp>
<gmd:identificationInfo xlink:type="simple">
<srv:SV_ServiceIdentification xsi:nil="true">
<gmd:citation xlink:type="simple">
<gmd:CI_Citation>
<gmd:title>
<gco:CharacterString>My CSW/ISO</gco:CharacterString>
</gmd:title>
<gmd:alternateTitle>
<gco:CharacterString></gco:CharacterString>
</gmd:alternateTitle>
<gmd:date xlink:type="simple"/>
</gmd:CI_Citation>
</gmd:citation>
<gmd:abstract>
<gco:CharacterString></gco:CharacterString>
</gmd:abstract>
<srv:serviceType>
<gco:LocalName>CSW</gco:LocalName>
</srv:serviceType>
<srv:serviceTypeVersion>
<gco:CharacterString>2.0.2</gco:CharacterString>
</srv:serviceTypeVersion>
<srv:couplingType/>
<srv:containsOperations xlink:type="simple"/>
</srv:SV_ServiceIdentification>
</gmd:identificationInfo>
</gmd:MD_Metadata>

This behaviour implies that unmarshalling this last output,
ServiceIdentification is completely lost in the new Java object, as it
possible to observe by marshalling again:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<gmd:MD_Metadata xmlns:gml="http://www.opengis.net/gml"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:gmd="http://www.isotc211.org/2005/gmd"
xmlns:gco="http://www.isotc211.org/2005/gco"
xmlns:gmx="http://www.isotc211.org/2005/gmx"
xmlns:srv="http://www.isotc211.org/2005/srv"
xmlns:gts="http://www.isotc211.org/2005/gts"
xmlns:wrs="http://www.opengis.net/cat/wrs/1.0"
xmlns:dct="http://purl.org/dc/terms/"
xmlns:csw="http://www.opengis.net/cat/csw/2.0.2"
xmlns:apiso="http://www.opengis.net/cat/csw/apiso/1.0"
xmlns:gsr="http://www.isotc211.org/2005/gsr"
xmlns:rim="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0"
xmlns:ows="http://www.opengis.net/ows"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.isotc211.org/2005/gmd
http://schemas.opengis.net/csw/2.0.2/profiles/apiso/1.0.0/apiso.xsd">
<gmd:hierarchyLevel>
<gmd:MD_ScopeCode
codeList="http://www.isotc211.org/2005/resources/codeList.xml#MD_ScopeCode"
codeListValue="service"></gmd:MD_ScopeCode>
</gmd:hierarchyLevel>
<gmd:contact xlink:type="simple"/>
<gmd:dateStamp>
<gco:Date xsi:nil="true"/>
</gmd:dateStamp>
<gmd:identificationInfo xlink:type="simple">
<srv:SV_ServiceIdentification xsi:nil="true"/>
</gmd:identificationInfo>
</gmd:MD_Metadata>

Let me know if more details are needed, thanks

Enrico

-- 
View this message in context: http://old.nabble.com/xsi%3Anil-problem-on-repeated-marshalling-unmarshalling-operations-tp27928223p27928223.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.