WFS Inline Schema

Simpson asimpson at I-55.COM
Wed Nov 9 05:21:05 PST 2005


Yes, I'd like to define the XML Schema inside the GetFeature Response.
When GeoTools is parsing the GetFeature response, it sucks in the schemas it
needs to validate the document.  Unfortunately when it tries to suck in the
schema from my server, it doesn't know how to negotiate basic
authentication, so gets a 401 and the document fails validation.
The code for the initial GetFeature request is easy to get basic auth
working, but the suck in of schemas is deep in the stack and it would be
difficult to change every method in the stack to accept authentication
arguments.
Creating and setting the default Authenticator in a Java application,
broadly solves this issue, however in an applet, setting the default
Authenticator throws a security exception.  I don't want customers to have
to bother with signed applets or monkeying around with java policy files.
In-lining the schema would alleviate me of any code changes on the client
end, that is if the parser knows how to deal with in-line schemas.
Below is an example GetFeature Response and associated schema.

Thanks for any info,
Drew.

=========================  GetFeature Response ===========================

<?xml version='1.0' encoding="ISO-8859-1" ?>
<wfs:FeatureCollection
   xmlns:myns="http://www.ttt.org/myns"
   xmlns:wfs="http://www.opengis.net/wfs"
   xmlns:gml="http://www.opengis.net/gml"
   xmlns:ogc="http://www.opengis.net/ogc"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.opengis.net/wfs
http://ogc.dmsolutions.ca/wfs/1.0.0/WFS-basic.xsd
                       http://www.ttt.org/myns
https://www.xxx.com/cgi-bin/mapserv?SERVICE=WFS&VERSION=1.0.0&REQUES
T=DescribeFeatureType&TYPENAME=eden_isles&OUTPUTFORMAT=XMLSCHEMA">
      <gml:boundedBy>
      	<gml:Box srsName="EPSG:32615">
      		<gml:coordinates>808464.020638,3346885.074396
809738.167216,3347815.170807</gml:coordinates>
      	</gml:Box>
      </gml:boundedBy>
    <gml:featureMember>
      <myns:eden_isles>
        <gml:boundedBy>
        	<gml:Box srsName="EPSG:32615">
        		<gml:coordinates>808464.020638,3346885.074396
809022.080755,3347464.191029</gml:coordinates>
        	</gml:Box>
        </gml:boundedBy>
        <myns:msGeometry>
        <gml:Polygon srsName="EPSG:32615">
          <gml:outerBoundaryIs>
            <gml:LinearRing>
              <gml:coordinates>808713.217294,3347464.191029
809022.080755,3347334.328511 808621.962181,3346885.074396
808506.138383,3346927.191969 808502.628571,3346993.878127
808464.020638,3347169.368016 808657.060301,3347443.132243
808713.217294,3347464.191029 </gml:coordinates>
            </gml:LinearRing>
          </gml:outerBoundaryIs>
        </gml:Polygon>
        </myns:msGeometry>
        <myns:gid>1</myns:gid>
        <myns:namex>xxx</myns:namex>
        <myns:descr>ddddddddd</myns:descr>
      </myns:eden_isles>
    </gml:featureMember>
    <gml:featureMember>
      <myns:eden_isles>
        <gml:boundedBy>
        	<gml:Box srsName="EPSG:32615">
        		<gml:coordinates>809130.884929,3347173.046875
809738.167216,3347815.170807</gml:coordinates>
        	</gml:Box>
        </gml:boundedBy>
        <myns:msGeometry>
        <gml:Polygon srsName="EPSG:32615">
          <gml:outerBoundaryIs>
            <gml:LinearRing>
              <gml:coordinates>809130.884929,3347815.170807
809569.611437,3347815.170807 809696.331720,3347639.969565
809729.800117,3347459.824281 809738.167216,3347346.709801
809390.920516,3347173.046875 809130.884929,3347309.759927
809130.884929,3347815.170807 </gml:coordinates>
            </gml:LinearRing>
          </gml:outerBoundaryIs>
        </gml:Polygon>
        </myns:msGeometry>
        <myns:gid>2</myns:gid>
        <myns:namex>yyyy</myns:namex>
        <myns:descr>sdfasdfasdfd</myns:descr>
      </myns:eden_isles>
    </gml:featureMember>
</wfs:FeatureCollection>


================================ SCHEMA
===========================================

<?xml version='1.0' encoding="ISO-8859-1" ?>
<schema
   targetNamespace="http://www.ttt.org/myns"
   xmlns:myns="http://www.ttt.org/myns"
   xmlns:ogc="http://www.opengis.net/ogc"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns="http://www.w3.org/2001/XMLSchema"
   xmlns:gml="http://www.opengis.net/gml"
   elementFormDefault="qualified" version="0.1" >

  <import namespace="http://www.opengis.net/gml"
          schemaLocation="http://ogc.dmsolutions.ca/gml/2.1.2/feature.xsd"
/>

  <element name="eden_isles"
           type="myns:eden_islesType"
           substitutionGroup="gml:_Feature" />

  <complexType name="eden_islesType">
    <complexContent>
      <extension base="gml:AbstractFeatureType">
        <sequence>
          <element name="msGeometry" type="gml:GeometryPropertyType"
minOccurs="0" maxOccurs="1"/>
          <element name="gid" type="string"/>
          <element name="namex" type="string"/>
          <element name="descr" type="string"/>
        </sequence>
      </extension>
    </complexContent>
  </complexType>

</schema>


 =======================================================================


-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU]On
Behalf Of Kralidis,Tom [Burlington]
Sent: Tuesday, November 08, 2005 5:54 PM
To: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: Re: [UMN_MAPSERVER-USERS] WFS Inline Schema


What do you mean by inline schema?  Do you mean defining the XML Schema
in the XML instance document (i.e. the GetFeature response) itself?  If
yes, that's not going to happen.  xsi:schemaLocation provides a
namespace and URL value for an XML parser to seek the XML Schema
document and validate against it.

Perhaps I don't understand your problem clearly enough.  Do you have
full examples of both the XML instance document, as well as the schema
it uses?

..Tom


> -----Original Message-----
> From: UMN MapServer Users List
> [mailto:MAPSERVER-USERS at lists.umn.edu] On Behalf Of Simpson
> Sent: Tuesday, 08 November, 2005 16:35
> To: MAPSERVER-USERS at lists.umn.edu
> Subject: Re: [UMN_MAPSERVER-USERS] WFS Inline Schema
>
>
> Something along the lines of below xml.
>
> When the namespace http://www.ttt.org/myns points to a URL
> back on the server it came from, the XML parser in GeoTools
> tries to GET the document but can't since I have basic auth
> running on the server and the XML parser doesn't know how to
> authenticate.  Getting the main WFS calls (getcapabilities,
> getfeature, etc) to authenticate is fairly straight forward
> (somebody gave me the code :) ), but the XML parser is deep
> in the call stack and running in a thread, so am a little
> apprehensive about digging into it.
>
> Unfortunately, my bodged up XML below doesn't validate saying:
>
> java.io.IOException: org.xml.sax.SAXException: Could not find
> element handler for http://www.w3.org/2001/XMLSchema : schema
> as a child of FeatureCollectionType
>
> I am XML challenged and am currently fumbling around trying
> to get an example schema inlined and validated.
>
> Not sure if it is even possible?  If it was, I figured the
> Mapserver crew had probably already done that and been there.
>
> Thanks for any suggestions,
> Drew.
>
>
>
> <?xml version='1.0' encoding="ISO-8859-1" ?> <wfs:FeatureCollection
>    xmlns:myns="http://www.ttt.org/myns"
>    xmlns:wfs="http://www.opengis.net/wfs"
>    xmlns:gml="http://www.opengis.net/gml"
>    xmlns:ogc="http://www.opengis.net/ogc"
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>    xsi:schemaLocation="http://www.opengis.net/wfs
> http://ogc.dmsolutions.ca/wfs/1.0.0/WFS-basic.xsd
> ">
>
>
> <schema
>    targetNamespace="http://www.ttt.org/myns"
>    xmlns:myns="http://www.ttt.org/myns"
>    xmlns:ogc="http://www.opengis.net/ogc"
>    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>    xmlns="http://www.w3.org/2001/XMLSchema"
>    xmlns:gml="http://www.opengis.net/gml"
>    elementFormDefault="qualified" version="0.1" >
>
>   <import namespace="http://www.opengis.net/gml"
>
> schemaLocation="http://ogc.dmsolutions.ca/gml/2.1.2/feature.xsd"
> />
>
>   <element name="eden_isles"
>            type="myns:eden_islesType"
>            substitutionGroup="gml:_Feature" />
>
>   <complexType name="eden_islesType">
>     <complexContent>
>       <extension base="gml:AbstractFeatureType">
>         <sequence>
>           <element name="msGeometry"
> type="gml:GeometryPropertyType" minOccurs="0" maxOccurs="1"/>
>           <element name="gid" type="string"/>
>           <element name="namex" type="string"/>
>           <element name="descr" type="string"/>
>         </sequence>
>       </extension>
>     </complexContent>
>   </complexType>
>
> </schema>
>
>
>
>
>       <gml:boundedBy>
>       	<gml:Box srsName="EPSG:32615">
>       		<gml:coordinates>808464.020638,3346885.074396
> 809738.167216,3347815.170807</gml:coordinates>
>       	</gml:Box>
>       </gml:boundedBy>
>     <gml:featureMember>
>       <myns:eden_isles>
>         <gml:boundedBy>
>         	<gml:Box srsName="EPSG:32615">
>         		<gml:coordinates>808464.020638,3346885.074396
> 809022.080755,3347464.191029</gml:coordinates>
>         	</gml:Box>
>         </gml:boundedBy>
>         <myns:msGeometry>
>         <gml:Polygon srsName="EPSG:32615">
>           <gml:outerBoundaryIs>
>             <gml:LinearRing>
>               <gml:coordinates>808713.217294,3347464.191029
> 809022.080755,3347334.328511 808621.962181,3346885.074396
> 808506.138383,3346927.191969 808502.628571,3346993.878127
> 808464.020638,3347169.368016 808657.060301,3347443.132243
> 808713.217294,3347464.191029 </gml:coordinates>
>             </gml:LinearRing>
>           </gml:outerBoundaryIs>
>         </gml:Polygon>
>         </myns:msGeometry>
>         <myns:gid>1</myns:gid>
>         <myns:namex>xxx</myns:namex>
>         <myns:descr>ddddddddd</myns:descr>
>       </myns:eden_isles>
>     </gml:featureMember>
>     <gml:featureMember>
>       <myns:eden_isles>
>         <gml:boundedBy>
>         	<gml:Box srsName="EPSG:32615">
>         		<gml:coordinates>809130.884929,3347173.046875
> 809738.167216,3347815.170807</gml:coordinates>
>         	</gml:Box>
>         </gml:boundedBy>
>         <myns:msGeometry>
>         <gml:Polygon srsName="EPSG:32615">
>           <gml:outerBoundaryIs>
>             <gml:LinearRing>
>               <gml:coordinates>809130.884929,3347815.170807
> 809569.611437,3347815.170807 809696.331720,3347639.969565
> 809729.800117,3347459.824281 809738.167216,3347346.709801
> 809390.920516,3347173.046875 809130.884929,3347309.759927
> 809130.884929,3347815.170807 </gml:coordinates>
>             </gml:LinearRing>
>           </gml:outerBoundaryIs>
>         </gml:Polygon>
>         </myns:msGeometry>
>         <myns:gid>2</myns:gid>
>         <myns:namex>yyyy</myns:namex>
>         <myns:descr>sdfasdfasdfd</myns:descr>
>       </myns:eden_isles>
>     </gml:featureMember>
> </wfs:FeatureCollection>
>
>
> -----Original Message-----
> From: UMN MapServer Users List
> [mailto:MAPSERVER-USERS at LISTS.UMN.EDU]On
> Behalf Of Steve Lime
> Sent: Tuesday, November 08, 2005 2:57 PM
> To: MAPSERVER-USERS at LISTS.UMN.EDU
> Subject: Re: [UMN_MAPSERVER-USERS] WFS Inline Schema
>
>
> Drew: I guess I'm not sure exactly what you're asking. Do you
> mean changing the schemaLocation to point to a fixed document
> rather than the schema generated by the WFS server?
>
> Steve
>
> >>> Simpson <asimpson at I-55.COM> 11/08/05 12:24 PM >>>
> Hello,
>
> Is it possible to inline the schema in the response from a
> getFeature rather than the normal xsi:schemaLocation?
>
> I am trying to avoid re-writing a bunch of GeoTools to
> include basic authentication when parsing the getFeature.
>
> Thanks,
> Drew.
>



More information about the MapServer-users mailing list