2

I'm trying to set up a new gml Feature schema however I think I'm misunderstanding something with the namespace. Heres my schema:

<xs:schema targetNamespace="http://localhost/dar" xmlns:gml="http://www.opengis.net/gml" xmlns:xs="http://www.w3.org/2001/XMLSchema"
 xmlns="http://localhost/dar">
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd" />
<xs:element name="Region" substitutionGroup="gml:_Feature">
    <xs:complexType>
        <xs:complexContent>
            <xs:extension base="gml:AbstractFeatureType">
                <xs:sequence>
                    <xs:element name="regionId" type="xs:string" />
                    <xs:element name="regionName" type="xs:string" />
                    <xs:element ref="gml:Polygon" />
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
</xs:element>

And heres my test xml doc:

<wfs:FeatureCollection xmlns="http://localhost/dar" xmlns:wfs="http://www.opengis.net/wfs"
xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://localhost/dar http://localhost/dar/DariusFeatures.xsd
http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
<gml:boundedBy>
    <gml:Envelope srsName="http://www.opengis.net/gml/srs/epsg.xml#63266405">
        <gml:lowerCorner>10 10</gml:lowerCorner>
        <gml:upperCorner>20 20</gml:upperCorner>
    </gml:Envelope>
</gml:boundedBy>
<gml:featureMember>
    <Region>
        <regionId>region432762</regionId>
        <regionName>Southern Block</regionName>
        <gml:Polygon>
            <gml:exterior>
                <gml:LinearRing>
                    <gml:coordinates>38.324,21.754 38.424,21.754 38.424,21.854 38.324,21.854 38.324,21.754 </gml:coordinates>
                </gml:LinearRing>
            </gml:exterior>
        </gml:Polygon>
    </Region>
</gml:featureMember>

Now the schema validates fine in eclipse however when I try to validate the xml doc, eclipse tells me that the schema file's target Namespace is "null" ?

As can be seen I've deployed the schema on localhost. Can anyone see where I've messed up?

j0k
  • 22,600
  • 28
  • 79
  • 90
user143278
  • 43
  • 1
  • 5

3 Answers3

1

Try to add the following line to your xml schema:

<xs:import namespace="http://www.opengis.net/wfs" schemaLocation="http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" />

Given that line (and elementFormDefault="qualified" in xs:schema, as Ian said), xml should validate.

tsufiev
  • 11
  • 2
  • Sorry, didn't help, also I don't see how it could help since _Feature element is under the gml namespace, wfs just makes use of it – user143278 Nov 15 '12 at 19:56
0

Short version: you need to add elementFormDefault="qualified" to your xs:schema element.

Longer version: by default only the top-level element declarations in a schema go into the target namespace, elements nested inside complex types are not declared into a namespace. Therefore the schema as written currently expects regionName and regionId to be in no namespace, but your XML document has them in the http://localhost/dar namespace. The elementFormDefault causes the nested "local" elements to take on the target namespace as well.

Ian Roberts
  • 120,891
  • 16
  • 170
  • 183
  • That makes sense however I added elementFormDefault="qualified" to http://localhost/dar/DariusFeatures.xsd, refreshed eclipse, and I still get the same validation error that target namespace is null, any other suggestions? – user143278 Nov 15 '12 at 09:57
  • @user143278 I notice you don't have the `http://www.opengis.net/gml` namespace listed in `xsi:schemaLocation`, maybe that's what it's complaining about. – Ian Roberts Nov 15 '12 at 10:35
  • thats not needed since http://schemas.opengis.net/wfs/1.1.0/wfs.xsd imports it internally – user143278 Nov 15 '12 at 11:08
0

Well, Its been several days and the validation problem still remains a mystery. As a work around, I've discovered that theres a newer version of OGC's Web feature Service at: http://schemas.opengis.net/wfs/2.0/wfs.xsd which uses gml 3.2 instead of gml 3.1.1

After small changes to use this new format everythings fine!

user143278
  • 43
  • 1
  • 5