1

Basically, I'm trying to limit the values that can be provided by a WFS transaction. So the original schema I've got for this simple test feature here

<xsd:complexType name="secondfeatureType">
    <xsd:complexContent>
        <xsd:extension base="gml:AbstractFeatureType">
            <xsd:sequence>
                <xsd:element maxOccurs="1" minOccurs="1" name="objectid" nillable="false" type="xsd:int"/>
                <xsd:element maxOccurs="1" minOccurs="0" name="color" nillable="true" type="xsd:string"/>
                <xsd:element maxOccurs="1" minOccurs="0" name="shape" nillable="true" type="gml:GeometryPropertyType"/>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexContent>
</xsd:complexType>
<xsd:element name="secondfeature" substitutionGroup="gml:_Feature" type="geofeatures:secondfeatureType"/>

But I want to limit the value of color to several options: 'Red', 'Green', 'Blue'

I tried creating the following schema for Geoserver to use for this feature:

<xsd:simpleType name="colorType" final="restriction">
    <xsd:restriction base="xsd:string">
        <xsd:enumeration value="Red"/>
        <xsd:enumeration value="Green"/>
        <xsd:enumeration value="Blue"/>
    </xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="secondfeatureType">
    <xsd:complexContent>
        <xsd:extension base="gml:AbstractFeatureType">
            <xsd:sequence>
                <xsd:element maxOccurs="1" minOccurs="1" name="objectid" nillable="false" type="xsd:int"/>
                <xsd:element maxOccurs="1" minOccurs="0" name="color" nillable="true" type="colorType"/>
                <xsd:element maxOccurs="1" minOccurs="0" name="shape" nillable="true" type="gml:GeometryPropertyType"/>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexContent>
</xsd:complexType>
<xsd:element name="secondfeature" substitutionGroup="gml:_Feature" type="geofeatures:secondfeatureType"/>

But the result is that any Insert Transaction I attempt to perform for this feature, the color value ends up being an empty string. It's the same result whether I try and create a feature with a color of "red" or deliberately bad value like "badvalue".

Is something like this even possible with GeoServer and WFS? If so, what do I need to change to make this work?

  • can you turn logging up to GeoTools Dev and then include the relevant part of the log file when you try the insert. – Ian Turton Jun 5 '18 at 7:50
  • Could you use schematron to do some additional validation in the client? – nmtoken Feb 1 at 3:36
  • Unfortunately, validation kind of needs to be done at the service level, as there are multiple clients utilizing the wfs service. Was able to solve this problem by ditching the xsds (since they dont allow for this) and just writing a validation extension with the geoserver scripting extension – DerekR Feb 1 at 17:38
3

As far as I know, what you're attempting to do is not possible, it would require new code to be written to either:

  • Make the schema configurable via UI (the xml schema snippets are a semi-working hidden hack)
  • Make the schema parsing code realize that thing is really just a string (my guess is that currently something that some object describing the string restriction comes up, and the parsing code does not know what to do with it... later at runtime, there is no converter to go from the user provided input to this type describing the restriction)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.