Hi all,

I spent some time yesterday trying to port the geoserver wfs 1.1 xlink 
tests to an app-schema configuration. Made some progress but ran into 
the following issue.

One of the types for testing looks like this:

  <xsd:complexType name="PrimitiveGeoFeatureType">
     <xsd:complexContent>
       <xsd:extension base="gml:AbstractFeatureType">
         <xsd:sequence>
           <xsd:element name="surfaceProperty" minOccurs="0" 
type="gml:SurfacePropertyType" />
           <xsd:element name="pointProperty" minOccurs="0" 
type="gml:PointPropertyType" />
           <xsd:element name="curveProperty" minOccurs="0" 
type="gml:CurvePropertyType" />

   ...

Now if I understand xml schema correctly this means the element 
"surfaceProperty" is non-nillable, but there is allowed to be zero 
occurrences in them.

So in the underlying database, there are records of PrimitiveGeoFeature 
which have a null value for "surfaceProperty". The current behavior that 
I am running into is that an Attribute instance is getting created for 
it, with a value set to null.

However, when this gets validated an error occurs, because the type is 
non-nullable. So I would think in this case the attribute instance 
should just be omitted since minOccurs == 0, and its value is 
non-existent or null. Thoughts?

If I am right does the following make sense when creating attributes 
from null values which correspond to  xml elements / particles:

* nillable = false, minOccurs > 0 -> create attribute with null value 
which will lead to a failure on validation

* nillable = true, minOccurs > 0 -> create attribute with null value 
which is ok

* nillable = false, minOccurs = 0 -> do not create an attribute

Thoughts? I also whipped up the following patch, not sure if it is 
complete though:

Index: app-schema/src/main/java/org/geotools/data/complex/filter/XPath.java
===================================================================
--- app-schema/src/main/java/org/geotools/data/complex/filter/XPath.java 
        (
revision 33570)
+++ app-schema/src/main/java/org/geotools/data/complex/filter/XPath.java 
        (
working copy)
@@ -611,6 +611,14 @@
                              + " is not a valid location path for type 
" + parent
Type.getName());
                  }
                  int index = currStep.getIndex();
+
+                //check for null, if the value is null but the 
descriptor is non
-nullable
+                // then check for minOccurs = 0, and if so
+                if ( value == null && !currStepDescriptor.isNillable() ) {
+                    if ( currStepDescriptor.getMinOccurs() == 0 ) {
+                        return null;
+                    }
+                }
                  Attribute attribute = setValue(currStepDescriptor, id, 
value, in
dex, parent,
                          targetNodeType, isXlinkRef);
                  return attribute;

-Justin

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

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to