You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sis.apache.org by Cullen Rombach <cu...@imagemattersllc.com> on 2017/01/19 02:25:41 UTC

NilReason Not Unmarshalling/Marshalling

Hello SIS developers,,

I am working on updating Apache SIS to support ISO 19115-3 in addition to ISO
19139, and  I have run into an issue with the gco:nilReason attribute not
properly unmarshalling or marshalling in certain situations.

For example, when unmarshalling the following ISO 19139 XML snippet,
JAXB passes
the setVersion method in DefaultFormat.java (which takes an
InternationalString as its argument) a null value.

<gmd:MD_Format>
    <gmd:name>
        <gco:CharacterString>XML</gco:CharacterString>
    </gmd:name>
    <gmd:version gco:nilReason="missing" />
</gmd:MD_Format>

When I marshal the generated Java object back into ISO 19139 XML, I
get the following
output:

<gmd:MD_Format>
    <gmd:name>
        <gco:CharacterString>XML</gco:CharacterString>
    </gmd:name>
</gmd:MD_Format>

Notice that the version element is no longer present, meaning the
nilReason attribute
was lost. It seems to me that this is occurring during unmarshalling, since
the setter for version is just passed a null value.

How, then, can I get SIS to take the nilReason attribute into account so that
my output perfectly matches my input? I took a look at NilReason.java and
some related classes, but I can't seem to figure out how they are used in
practice.

If there is a fix, I will likely need to apply it to other attributes in
the future. So, please let me know if the fix for this issue can be
generalized to other attributes.

Thank you,
Cullen Rombach

-- 
Cullen Rombach
Image Matters LLC
www.imagemattersllc.com

Re: NilReason Not Unmarshalling/Marshalling

Posted by Martin Desruisseaux <ma...@geomatys.com>.
Hello Cullen

Le 19/01/2017 � 11:25, Cullen Rombach a �crit :

> I am working on updating Apache SIS to support ISO 19115-3 in addition
> to ISO 19139 (...snip...)
>
I would like to know, if this work is public, is there a link that you
would like to share?

    Regards,

        Martin



Re: NilReason Not Unmarshalling/Marshalling

Posted by Martin Desruisseaux <ma...@geomatys.com>.
Hello Cullen

Thanks for reporting this issue. I just had a look at the code, and it
seems that indeed support of gco:nilReason attribute has not been
implemented for <gco:CharacterString> element. For adding this support,
we can take inspiration of the existing support for other metadata
elements. In the org.apache.sis.internal.jaxb.gco.PropertyType class we
have the following methods:

    @XmlAttribute(name = "nilReason", namespace = Namespaces.GCO)
    public String getNilReason() {
        ....
    }

    public void setNilReason(String nilReason) {
        ....
    }

Before to go further, would it be possible to verify if adding similar
methods in org.apache.sis.internal.jaxb.gco.GO_CharacterString causes
the setNilReason(\u2026) method to be invoked? I'm not sure if
GO_CharacterString is the right class where to put this method, so we
may need a few trials.

Once we got a setNilReason(\u2026) invoked by JAXB, then an approach would be
to create a org.apache.sis.internal.jaxb.gco.NilCharacterString class
that implements both InternationalString (returning an empty string) and
NilObject interfaces. That NilCharacterString would be instantiated by
setNilReason(\u2026).

About other properties that may need to be fixed: nilReason should be
already supported for all metadata in the org.opengis.metadata packages.
Support that may be missing are for some types outside the metadata
packages. InternationalString was one of them, other cases may be
Locale, Charset, Unit or URI (I didn't verified yet); basically the
classes in the org.apache.sis.internal.jaxb.gco package of the
sis-utility module.

    Regards,

        Martin


Le 19/01/2017 � 11:25, Cullen Rombach a �crit :
> I am working on updating Apache SIS to support ISO 19115-3 in addition to ISO
> 19139, and  I have run into an issue with the gco:nilReason attribute not
> properly unmarshalling or marshalling in certain situations.
>
> For example, when unmarshalling the following ISO 19139 XML snippet,
> JAXB passes
> the setVersion method in DefaultFormat.java (which takes an
> InternationalString as its argument) a null value.
>
> <gmd:MD_Format>
>     <gmd:name>
>         <gco:CharacterString>XML</gco:CharacterString>
>     </gmd:name>
>     <gmd:version gco:nilReason="missing" />
> </gmd:MD_Format>
>
> When I marshal the generated Java object back into ISO 19139 XML, I
> get the following
> output:
>
> <gmd:MD_Format>
>     <gmd:name>
>         <gco:CharacterString>XML</gco:CharacterString>
>     </gmd:name>
> </gmd:MD_Format>
>
> Notice that the version element is no longer present, meaning the
> nilReason attribute
> was lost. It seems to me that this is occurring during unmarshalling, since
> the setter for version is just passed a null value.
>
> How, then, can I get SIS to take the nilReason attribute into account so that
> my output perfectly matches my input? I took a look at NilReason.java and
> some related classes, but I can't seem to figure out how they are used in
> practice.
>
> If there is a fix, I will likely need to apply it to other attributes in
> the future. So, please let me know if the fix for this issue can be
> generalized to other attributes.
>
> Thank you,
> Cullen Rombach
>