[Geoserver-users] app schema encodeIfEmpty with null values [SEC=UNCLASSIFIED]

Hi all,

I’m trying to use the encodeIfEmpty element to encode an empty element when the value in the underlying database is null, e.g.

.

.

positionalAccuracy

POSITIONALACCURACY

true

.

.

I need the output element to be of the form gsmlp:positionalAccuracy/ for null values, although the element is being skipped, i.e. it doesn’t appear at all, and the resulting feature XML is invalid against the application schema.

Has anyone gotten this to work, or am I misunderstanding the documentation - “The encodeIfEmpty element will determine if an attribute will be encoded if it contains a null or empty value.”?

I’ve found work arounds using filter expressions, e.g. if_then_else(isNull(PARENTBOREHOLE_URI), ‘’,PARENTBOREHOLE_URI), although the element becomes non-queryable.

I’m using GeoServer 2.9.0 with the 2.9.0 app schema plugin, and have tested against Oracle and PostgreSQL databases.

Regards,

Aaron.

Aaron,

why is it schema-invalid to omit positionalAccuracy when the value is null? All occurrences in GeoSciML Portrayal 4.0.0 have minOccurs="0":
http://schemas.geosciml.org/geosciml/4.0/geosciml-portrayal.xsd

<element minOccurs="0" name="positionalAccuracy" type="string">

This means that it is schema-valid to omit this element.

Kind regards,
Ben.

On 27/06/16 19:16, Sedgmen Aaron wrote:

Hi all,

I'm trying to use the encodeIfEmpty element to encode an empty element when the value in the underlying database is null, e.g.
        .
        <AttributeMapping>
                <targetAttribute>positionalAccuracy</targetAttribute>
                <sourceExpression><OCQL>POSITIONALACCURACY</OCQL></sourceExpression>
                <encodeIfEmpty>true</encodeIfEmpty>
        </AttributeMapping>
        .

I need the output element to be of the form <gsmlp:positionalAccuracy/> for null values, although the element is being skipped, i.e. it doesn't appear at all, and the resulting feature XML is invalid against the application schema.

Has anyone gotten this to work, or am I misunderstanding the documentation - "The encodeIfEmpty element will determine if an attribute will be encoded if it contains a null or empty value."?

I've found work arounds using filter expressions, e.g. <sourceExpression><OCQL>if_then_else(isNull(PARENTBOREHOLE_URI), '',PARENTBOREHOLE_URI)</OCQL></sourceExpression>, although the element becomes non-queryable.

I'm using GeoServer 2.9.0 with the 2.9.0 app schema plugin, and have tested against Oracle and PostgreSQL databases.

Regards,
Aaron.

Geoscience Australia Disclaimer: This e-mail (and files transmitted with it) is intended only for the person or entity to which it is addressed. If you are not the intended recipient, then you have received this e-mail by mistake and any use, dissemination, forwarding, printing or copying of this e-mail and its file attachments is prohibited. The security of emails transmitted cannot be guaranteed; by forwarding or replying to this email, you acknowledge and accept these risks.
-------------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape

_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Ben Caradoc-Davies <ben@anonymised.com>
Director
Transient Software Limited <http://transient.nz/&gt;
New Zealand

Hi Ben,

Thanks for the reply. I've been working with an old app schema
configuration that uses GeoSciML Portrayal 2.0, for which there are a couple
of mandatory elements in the BoreholeView feature type other than
positionalAccuracy that are breaking validation when null (namely
specification_uri and metadata_uri). The positionalAccuracy element was a
poor example to use in my original post.

Going to GeoSciML Portrayal 4.0 has solved the problem. All elements in the
BoreholeView feature type have minOccurs="0" (except identifier and shape
which will never be null in our database), and as such there's now no need
to use encodeIfEmpty.

Thanks again for your help.

Regards,
Aaron.

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/app-schema-encodeIfEmpty-with-null-values-SEC-UNCLASSIFIED-tp5273475p5273667.html
Sent from the GeoServer - User mailing list archive at Nabble.com.