Justin, what happens if you are trying to use an xlink:href 
ClientProperty on a nillable minOccurs=0 property to encode it by reference?

For example, you might want to encode a GeoSciML gsml:GeologicUnit with 
a gsml:occurrence by reference (nillable and minOccurs=0). XPath.java is 
used to create this empty placeholder node. Later, a ClientProperty is 
used to set xlink:href to some URI in the UserData for the node, to be 
unpacked at encode time. I expect your patch would break this.

We have a unit test (GS XlinkWfsTest) that covers a gsml:MappedFeature 
with a gsml:specification by reference, but that gsml:specification has 
minOccurs=1 (and maxOccurs=1), so although it is nillable, it will not 
be affected by your patch.

I think we need another unit test.  :-)

Justin Deoliveira wrote:
> 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
> 


-- 
Ben Caradoc-Davies <[email protected]>
Software Engineer, CSIRO Exploration and Mining
Australian Resources Research Centre
26 Dick Perry Ave, Kensington WA 6151, Australia

------------------------------------------------------------------------------
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