[Geoserver-devel] Making sure GML output always has all the attributes

Hi all,
as you probably know our current GML2 output (GetFeature and GetFeatureInfo)
omits fully the elements whose value is null.

This causes issues in some dumb clients, such as javascript ones, as they may
show up a reduced set of attributes hiding the fact there are more.
Now, one could run a DescribeFeatureType but WFS might be not enabled,
and running an extra call might be undesirable anyways.

What problems do you see if we start returning an empty element instead of no
element at all for empty attributes? That is:

Do you believe we could just do that by default, or should it have a configuration
flag to enable/disable it?

Coding wise for GML2 generation the change is trivial (and it would really be
all I need, but I’m trying to think in more general terms).
GML3 wise uh… not sure. Maybe it’s just a matter of changing
GML3EncodingUtils.encodeSimpleContent, but I may be wrong

Opinions?

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


Well this discussion came up actually before during the development of the wfs 1.1 spec and there were three options.

  1. omit the element
  2. create an empty element
  3. use the xs:nil construct

In the end (1) was decided upon. (2) I believe creates invalid xml documents and (3) I can’t remember.

So long story short this would go against the specification so not something we would want to do by default (perhaps by format_option?)

Then there is the question of other formats, like geojson which i believe apply the same method for null properties that are null (although i could be wrong).

On Wed, Aug 22, 2012 at 5:42 AM, Andrea Aime <andrea.aime@anonymised.com> wrote:

Hi all,
as you probably know our current GML2 output (GetFeature and GetFeatureInfo)
omits fully the elements whose value is null.

This causes issues in some dumb clients, such as javascript ones, as they may
show up a reduced set of attributes hiding the fact there are more.
Now, one could run a DescribeFeatureType but WFS might be not enabled,
and running an extra call might be undesirable anyways.

What problems do you see if we start returning an empty element instead of no
element at all for empty attributes? That is:

Do you believe we could just do that by default, or should it have a configuration
flag to enable/disable it?

Coding wise for GML2 generation the change is trivial (and it would really be
all I need, but I’m trying to think in more general terms).
GML3 wise uh… not sure. Maybe it’s just a matter of changing
GML3EncodingUtils.encodeSimpleContent, but I may be wrong

Opinions?

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it



Live Security Virtual Conference
Exclusive live event will cover all the ways today’s security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


Geoserver-devel mailing list
Geoserver-devel@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel


Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

On Wed, Aug 22, 2012 at 5:18 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

Well this discussion came up actually before during the development of the wfs 1.1 spec and there were three options.

  1. omit the element
  2. create an empty element
  3. use the xs:nil construct

In the end (1) was decided upon. (2) I believe creates invalid xml documents and (3) I can’t remember.

So long story short this would go against the specification so not something we would want to do by default (perhaps by format_option?)

That’s odd? I’ve just tried to replace elements in a GeoServer WFS response with empty ones, as follows:

<wfs:FeatureCollection xmlns=“http://www.opengis.net/wfs
xmlns:wfs=“http://www.opengis.net/wfs” xmlns:gml=“http://www.opengis.net/gml
xmlns:GeoSolutions=“http://www.geo-solutions.it” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation=“http://www.opengis.net/wfs http://demo1.geo-solutions.it:80/geoserver-enterprise/schemas/wfs/1.0.0/WFS-basic.xsd http://www.geo-solutions.it http://demo1.geo-solutions.it:80/geoserver-enterprise/GeoSolutions/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=GeoSolutions%3Acities”>
gml:boundedBy
gml:nullunknown</gml:null>
</gml:boundedBy>
gml:featureMember
<GeoSolutions:cities fid=“cities.1”>
GeoSolutions:the_geom
<gml:Point srsName=“http://www.opengis.net/gml/srs/epsg.xml#4326”>
<gml:coordinates xmlns:gml=“http://www.opengis.net/gml
decimal=“.” cs=“,” ts=" ">-16.2617,28.4623</gml:coordinates>
</gml:Point>
</GeoSolutions:the_geom>
<GeoSolutions:TYPE />
<GeoSolutions:NATION />
GeoSolutions:CNTRYNAMESpain</GeoSolutions:CNTRYNAME>
GeoSolutions:LEVEL1</GeoSolutions:LEVEL>
GeoSolutions:NAMESanta Cruz de Tenerife</GeoSolutions:NAME>
<GeoSolutions:NAMEPRE />
<GeoSolutions:CODE />
GeoSolutions:PROVINCE38</GeoSolutions:PROVINCE>
GeoSolutions:PROVNAMESanta Cruz de Tenerife</GeoSolutions:PROVNAME>
GeoSolutions:UNPROV0</GeoSolutions:UNPROV>
<GeoSolutions:CONURB />
</GeoSolutions:cities>
</gml:featureMember>
</wfs:FeatureCollection>

Eclipse says the above document is valid (that GeoServer is available to the internet so you
can try out validation yourself)

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


On Wed, Aug 22, 2012 at 6:07 PM, Andrea Aime <andrea.aime@anonymised.com> wrote:

That’s odd? I’ve just tried to replace elements in a GeoServer WFS response with empty ones, as follows:

<wfs:FeatureCollection xmlns=“http://www.opengis.net/wfs
xmlns:wfs=“http://www.opengis.net/wfs” xmlns:gml=“http://www.opengis.net/gml
xmlns:GeoSolutions=“http://www.geo-solutions.it” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation=“http://www.opengis.net/wfs http://demo1.geo-solutions.it:80/geoserver-enterprise/schemas/wfs/1.0.0/WFS-basic.xsd http://www.geo-solutions.it http://demo1.geo-solutions.it:80/geoserver-enterprise/GeoSolutions/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=GeoSolutions%3Acities”>
gml:boundedBy
gml:nullunknown</gml:null>
</gml:boundedBy>
gml:featureMember
<GeoSolutions:cities fid=“cities.1”>
GeoSolutions:the_geom
<gml:Point srsName=“http://www.opengis.net/gml/srs/epsg.xml#4326”>
<gml:coordinates xmlns:gml=“http://www.opengis.net/gml
decimal=“.” cs=“,” ts=" ">-16.2617,28.4623</gml:coordinates>
</gml:Point>
</GeoSolutions:the_geom>
<GeoSolutions:TYPE />
<GeoSolutions:NATION />
GeoSolutions:CNTRYNAMESpain</GeoSolutions:CNTRYNAME>
GeoSolutions:LEVEL1</GeoSolutions:LEVEL>
GeoSolutions:NAMESanta Cruz de Tenerife</GeoSolutions:NAME>
<GeoSolutions:NAMEPRE />
<GeoSolutions:CODE />
GeoSolutions:PROVINCE38</GeoSolutions:PROVINCE>
GeoSolutions:PROVNAMESanta Cruz de Tenerife</GeoSolutions:PROVNAME>
GeoSolutions:UNPROV0</GeoSolutions:UNPROV>
<GeoSolutions:CONURB />
</GeoSolutions:cities>
</gml:featureMember>
</wfs:FeatureCollection>

Eclipse says the above document is valid (that GeoServer is available to the internet so you
can try out validation yourself)

Bah, it just took forever to validate, but indeed the result is invalid, have to look into why

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


I think it depends on the type, indeed some types will allow for empty content (like strings) but others i believe do not. Or maybe i am just wrong about that…

On Wed, Aug 22, 2012 at 9:07 AM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Wed, Aug 22, 2012 at 5:18 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

Well this discussion came up actually before during the development of the wfs 1.1 spec and there were three options.

  1. omit the element
  2. create an empty element
  3. use the xs:nil construct

In the end (1) was decided upon. (2) I believe creates invalid xml documents and (3) I can’t remember.

So long story short this would go against the specification so not something we would want to do by default (perhaps by format_option?)

That’s odd? I’ve just tried to replace elements in a GeoServer WFS response with empty ones, as follows:

<wfs:FeatureCollection xmlns=“http://www.opengis.net/wfs
xmlns:wfs=“http://www.opengis.net/wfs” xmlns:gml=“http://www.opengis.net/gml
xmlns:GeoSolutions=“http://www.geo-solutions.it” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation=“http://www.opengis.net/wfs http://demo1.geo-solutions.it:80/geoserver-enterprise/schemas/wfs/1.0.0/WFS-basic.xsd http://www.geo-solutions.it http://demo1.geo-solutions.it:80/geoserver-enterprise/GeoSolutions/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=GeoSolutions%3Acities”>
gml:boundedBy
gml:nullunknown</gml:null>
</gml:boundedBy>
gml:featureMember
<GeoSolutions:cities fid=“cities.1”>
GeoSolutions:the_geom
<gml:Point srsName=“http://www.opengis.net/gml/srs/epsg.xml#4326”>
<gml:coordinates xmlns:gml=“http://www.opengis.net/gml
decimal=“.” cs=“,” ts=" ">-16.2617,28.4623</gml:coordinates>
</gml:Point>
</GeoSolutions:the_geom>
<GeoSolutions:TYPE />
<GeoSolutions:NATION />
GeoSolutions:CNTRYNAMESpain</GeoSolutions:CNTRYNAME>
GeoSolutions:LEVEL1</GeoSolutions:LEVEL>
GeoSolutions:NAMESanta Cruz de Tenerife</GeoSolutions:NAME>
<GeoSolutions:NAMEPRE />
<GeoSolutions:CODE />
GeoSolutions:PROVINCE38</GeoSolutions:PROVINCE>
GeoSolutions:PROVNAMESanta Cruz de Tenerife</GeoSolutions:PROVNAME>
GeoSolutions:UNPROV0</GeoSolutions:UNPROV>
<GeoSolutions:CONURB />
</GeoSolutions:cities>
</gml:featureMember>
</wfs:FeatureCollection>

Eclipse says the above document is valid (that GeoServer is available to the internet so you
can try out validation yourself)

Cheers

Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it



Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

On Wed, Aug 22, 2012 at 6:09 PM, Andrea Aime <andrea.aime@anonymised.com> wrote:

Bah, it just took forever to validate, but indeed the result is invalid, have to look into why

This variant seems to work fine though:

<wfs:FeatureCollection xmlns=“http://www.opengis.net/wfs
xmlns:wfs=“http://www.opengis.net/wfs” xmlns:gml=“http://www.opengis.net/gml
xmlns:GeoSolutions=“http://www.geo-solutions.it” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation=“http://www.opengis.net/wfs http://demo1.geo-solutions.it:80/geoserver-enterprise/schemas/wfs/1.0.0/WFS-basic.xsd http://www.geo-solutions.it http://demo1.geo-solutions.it:80/geoserver-enterprise/GeoSolutions/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=GeoSolutions%3Acities”>
gml:boundedBy
gml:nullunknown</gml:null>
</gml:boundedBy>
gml:featureMember
<GeoSolutions:cities fid=“cities.1”>
GeoSolutions:the_geom
<gml:Point srsName=“http://www.opengis.net/gml/srs/epsg.xml#4326”>
<gml:coordinates xmlns:gml=“http://www.opengis.net/gml
decimal=“.” cs=“,” ts=" ">-16.2617,28.4623</gml:coordinates>
</gml:Point>
</GeoSolutions:the_geom>
<GeoSolutions:TYPE xsi:nil=“true” />
<GeoSolutions:NATION xsi:nil=“true” />
GeoSolutions:CNTRYNAMESpain</GeoSolutions:CNTRYNAME>
GeoSolutions:LEVEL1</GeoSolutions:LEVEL>
GeoSolutions:NAMESanta Cruz de Tenerife</GeoSolutions:NAME>
<GeoSolutions:NAMEPRE />
<GeoSolutions:CODE />
GeoSolutions:PROVINCE38</GeoSolutions:PROVINCE>
GeoSolutions:PROVNAMESanta Cruz de Tenerife</GeoSolutions:PROVNAME>
GeoSolutions:UNPROV0</GeoSolutions:UNPROV>
<GeoSolutions:CONURB />
</GeoSolutions:cities>
</gml:featureMember>
</wfs:FeatureCollection>

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it