users@jaxb.java.net

Re: xsi:nil problem on repeated marshalling-unmarshalling operations

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Fri, 19 Mar 2010 19:02:55 +0100

Thanks for the zip file. Seems like a bug to me. I've created issue 744 and
attached your package.
-W

On Fri, Mar 19, 2010 at 5:23 PM, boldra <boldra_at_gmail.com> wrote:

>
> Dear Wolfgang,
>
> I'm attaching a sample maven project that:
> -generates the classes from the schemas
> -contains a JUnit test which fails on the error
>
> Please run it with: mvn clean compile test
> Hoping this will be helpful, kind regards.
>
> Enrico
>
> http://old.nabble.com/file/p27950995/test-xsi-nil.zip test-xsi-nil.zip
>
>
> Wolfgang Laun-2 wrote:
> >
> > Would you please identify the full set of xsd files you've used for
> > generating the Java classes, and how you did it?
> > -W
> >
> >
> > On 3/17/10, boldra <boldra_at_gmail.com> wrote:
> >>
> >> 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.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> >> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> > For additional commands, e-mail: users-help_at_jaxb.dev.java.net
> >
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/xsi%3Anil-problem-on-repeated-marshalling-unmarshalling-operations-tp27928223p27950995.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>