Shaw,

you are the second person whom I suspect has been bitten by GeoServer 
"id" handling today. The last one was in my office not two hours ago.

Short version: do not use any attributes or elements called "id". Can 
you change your schema?

Long version: GeoServer was originally implemented to handle only simple 
features, and in particular, simple features where namespaces did not 
matter. As a consequence, large tracts of core code ignored namespaces, 
discarded namespaces, or made unwarranted assumptions about namespaces. 
The app-schema crew has fixed these in many places, but one of the 
remaining issues is the way that GeoServer often assumes that any XML 
attribute or element named "id" is in fact gml:id, regardless of its 
namespace. gml:id is one of the attributes of gml:AbstractFeatureType, 
so you should be aware that it is rather widely used. The special magic 
handling of this attribute, used to make the old implementation of 
simple features easier, gets in the way of handling your "id". I also 
know one place where app-schema support code in the core code also 
treats any "id" as "gml:id".

As another example, if you have even a simple feature property myns:id 
you will not be able to make a filter query against it. It will still be 
encoded.

Sorry!

Kind regards,
Ben.

On 08/03/11 13:21, Shaw Innes wrote:
> I am still having some issues mapping feature types.  Now I have the parent 
> feature (with geometry) working fine, and I can get my child table to produce 
> a number of xml elements according to the correct number of attributes in the 
> child table, however the child (attribute) elements are not being populated 
> with data, nor ID's.
>
> I have two objects:  Locality and Attribute, where Locality is the parent and 
> can contain 1:many Attributes.  These are represented in PostGIS tables and 
> linked on ID fields.  This works fine - and I can retrieve WFS features from 
> the Locality table.
>
> I have declared the following Schema as complex.xsd (I have some other 
> elements also, but they are working fine...):
>
> <xs:schema
>          targetNamespace="http://sidelab<http://sidelab/>"
>          xmlns:sidelab="http://sidelab<http://sidelab/>"
>          xmlns:gml="http://www.opengis.net/gml";
>          xmlns:xs="http://www.w3.org/2001/XMLSchema";
>          elementFormDefault="qualified"
>          attributeFormDefault="unqualified"
>          version="1.0">
>
>    <xs:import namespace="http://www.opengis.net/gml";
>          
> schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/feature.xsd"; />
>
>    <attribute name="id" type="ID" />
>
>    <xs:element name="Attribute" type="sidelab:AttributeType" />
>    <xs:complexType name="AttributeType">
>      <xs:attribute ref="sidelab:id" />
>      <xs:sequence>
>        <xs:element name="type" type="xs:string" />
>        <xs:element name="value" type="xs:string" />
>        <xs:element name="description" type="xs:string" />
>      </xs:sequence>
>    </xs:complexType>
>
>    <xs:element name="Locality" type="sidelab:LocalityType" />
>    <xs:complexType name="LocalityType">
>      <xs:complexContent>
>        <xs:extension base="gml:AbstractFeatureType">
>          <xs:sequence>
>            <xs:element name="name" type="xs:string" />
>            <xs:element name="state" type="xs:string" />
>            <xs:element name="postcode" type="xs:string" />
>            <xs:element name="referenceName" type="xs:string" />
>            <xs:element name="the_geom" type="gml:PointPropertyType" />
>            <xs:element ref="sidelab:Attribute" maxOccurs="unbounded" />
>          </xs:sequence>
>        </xs:extension>
>      </xs:complexContent>
>    </xs:complexType>
> </xs:schema>
>
> In my Locality xml mapping I have the following:
>
>      <AttributeMapping>
>              <targetAttribute>Locality/sidelab:Attribute</targetAttribute>
>              <sourceExpression>
>                <OCQL>LocalityID</OCQL>
>                <linkElement>sidelab:Attribute</linkElement>
>                <linkField>FEATURE_LINK</linkField>
>              </sourceExpression>
>              <isMultiple>true</isMultiple>
>            </AttributeMapping>
>
> In my Attribute xml mapping I have the following:
>
>      <FeatureTypeMapping>
>          <sourceDataStore>datastore</sourceDataStore>
>          <sourceType>attribute</sourceType>
>          <targetElement>sidelab:Attribute</targetElement>
>          <attributeMappings>
>            <AttributeMapping>
>              <targetAttribute>sidelab:Attribute</targetAttribute>
>              <idExpression>
>                <OCQL>getID()</OCQL>
>              </idExpression>
>            </AttributeMapping>
> <!--
>            <AttributeMapping>
>              <targetAttribute>Attribute/sidelab:type</targetAttribute>
>              <sourceExpression>
>                <OCQL>'Type'</OCQL>
>              </sourceExpression>
>            </AttributeMapping>
> -->
>            ...
>
>            <AttributeMapping>
>              <targetAttribute>FEATURE_LINK</targetAttribute>
>              <sourceExpression>
>                <OCQL>LocalityID</OCQL>
>              </sourceExpression>
>            </AttributeMapping>
>
>
>
> In the log I am getting the following entry, which would lead me to believe I 
> should be getting my ID populated at least.
>
> 08 Mar 15:09:23 TRACE [complex.filter] - ENTRY 
> FeatureImpl:Locality<LocalityType id=1>=[AttributeImpl:name<string>=Axedale, 
> AttributeImpl:state<string>=VIC, 
> AttributeImpl:referenceName<string>=MELBOURNE, 
> GeometryAttributeImpl:the_geom<PointPropertyType>=POINT (144.504133 
> -36.787917)] sidelab:Attribute [FeatureImpl:Attribute<AttributeType 
> id=161>=[AttributeImpl:FEATURE_LINK<string>=1]] null null
>
> Furthermore - if I try to set the type element - I get the following:
>
> <ows:ExceptionText>java.lang.RuntimeException: Error applying mapping with 
> targetAttribute sidelab:Attribute Error applying mapping with targetAttribute 
> sidelab:Attribute Error applying mapping with targetAttribute sidelab:type 
> sidelab:type is not a valid location path for type 
> http://sidelab:AttributeType. sidelab:type ns: 
> http://sidelab<http://sidelab/>, AttributeType properties: 
> null#FEATURE_LINK</ows:ExceptionText>
>
> I feel like I'm so close now - and it's probably a factor of namespaces or 
> something very simple.
>
> thanks for the ongoing (and rapid) support.
>
>
>

-- 
Ben Caradoc-Davies <[email protected]>
Software Engineering Team Leader
CSIRO Earth Science and Resource Engineering
Australian Resources Research Centre

------------------------------------------------------------------------------
What You Don't Know About Data Connectivity CAN Hurt You
This paper provides an overview of data connectivity, details
its effect on application quality, and explores various alternative
solutions. http://p.sf.net/sfu/progress-d2d
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to