Any chance I could convince you to put this patch in the geoserver task
tracker? http://jira.codehaus.org/browse/GEOS I'm happy to submit it
myself, but if you do it then you'll be automatically notified when it's
updated.
I'm slightly wary of this, as there's a chance it may break the CITE
conformance tests. Mostly because the tests aren't good, not because
it's the wrong thing to do, but I remember that I thought nulls should
work this way, but that in their set up nulls were just returned as
blank. So to get this in to GeoServer correctly we may need to make it
a config option, or make a part of the 'citehacks' options.
Chris
Gertjan van Oosten wrote:
Hi Chris,
We have a problem with the way FeatureTransformer leaves out fields that
are NULL in e.g. a PostGIS datastore. The GML returns only the non-null
fields of a feature. This makes it rather hard to edit a feature (from
within MapBuilder) for filling in fields that are null in the database.
Please find attached my proposed change in patch format (against 2.2-RC2).
[Note that I didn't do much about the indentation so my changes are clear.]
Kind regards,
------------------------------------------------------------------------
---
geotools-2.2-RC2/module/main/src/org/geotools/gml/producer/FeatureTransformer.java.distrib
2006-04-06 17:29:58.000000000 +0200
+++
geotools-2.2-RC2/module/main/src/org/geotools/gml/producer/FeatureTransformer.java
2006-05-02 13:17:19.000000000 +0200
@@ -28,6 +28,7 @@
import org.geotools.xml.transform.TransformerBase;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
+import org.xml.sax.Attributes;
import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.NamespaceSupport;
import java.io.IOException;
@@ -528,14 +529,20 @@
*/
public void handleAttribute(AttributeType type, Object value) {
try {
- if (value != null) {
+ Attributes attrs = NULL_ATTS;
+ if (value == null) {
+ attrs = new AttributesImpl();
+ ((AttributesImpl) attrs).addAttribute("http://www.w3.org/2001/XMLSchema-instance",
"nil", "xsi:nil", "CDATA", "true");
+ }
+
String name = type.getName();
//HACK: this should be user configurable, along with the
//other gml substitutions I shall add.
- if (prefixGml //adding this in since the extra boundedBy
+ if (value != null
+ && prefixGml //adding this in since the extra
boundedBy
//hacking should only need to be done for the weird
//cite tests, and having this check before the string
//equals should get us better performance. Albeit
@@ -557,6 +564,7 @@
contentHandler.startElement("", "", name, NULL_ATTS);
+ if (value != null) {
if (Geometry.class.isAssignableFrom(value.getClass()))
{
geometryTranslator.encode((Geometry) value,
srsName);
} else {
@@ -564,13 +572,10 @@
contentHandler.characters(text.toCharArray(), 0,
text.length());
}
+ }
contentHandler.endElement("", "", name);
}
- }
-
- //REVISIT: xsi:nillable is the proper xml way to handle nulls,
- //but OGC people are fine with just leaving it out.
} catch (Exception e) {
throw new RuntimeException(e);
}
--
Chris Holmes
The Open Planning Project
http://topp.openplans.org
begin:vcard
fn:Chris Holmes
n:Holmes;Chris
org:The Open Planning Project
adr:;;377 Broadway, 11th Floor;New York;NY;10013;USA
email;internet:[EMAIL PROTECTED]
title:VP, Strategic Development
x-mozilla-html:FALSE
url:http://topp.openplans.org
version:2.1
end:vcard