[Geoserver-devel] Validation issues in wcs 1.1.1 xml parsing

Hi,
the cite guys just hit me with a wcs request that contains
quite a bit of xml errors:

  <GetCoverage xmlns="http://www.opengis.net/wcs/1.1.1&quot;
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
                    xmlns:ctl="http://www.occamlab.com/ctl&quot;
                    xmlns:ows="http://www.opengis.org/ows/1.1&quot;
                    service="WCS"
                    version="1.1.1"
                    xsi:schemaLocation="http://www.opengis.net/wcs/1.1.1
http://schemas.opengis.net/wcs/1.1.1/wcsAll.xsd&quot;&gt;
          <Identifier>topp:rotated</Identifier>
          <ows:BoundingBox crs="urn:ogc:def:crs:EPSG::3003">
             <ows:LowerCorner>1402796.735086838
5000064.822668008</ows:LowerCorner>
             <ows:UpperCorner>1402868.2853603114
5000119.220342959</ows:UpperCorner>
          </ows:BoundingBox>
          <Format>application/arcgrid</Format>
       </GetCoverage>

Well, if we exclude the fact that the schema is not there,
there are other issues: the
Identifier element is not prefixed with ows: (it should),
the ows:boundingBox element is not a direct child of
GetCoverage (it should be enclosed with

I configured the xml parser with .setValidating(true),
yet it happily tries to parse the document anyways
and breaks with the following exception:

java.lang.RuntimeException: Parsing failed for GetCoverage:
java.lang.ClassCastException: java.lang.String cannot be cast to
net.opengis.ows.v1_1_0.CodeType
Parsing failed for GetCoverage: java.lang.ClassCastException:
java.lang.String cannot be cast to net.opengis.ows.v1_1_0.CodeType

That is, it tried to parse Identifier into a string (it's a codeType
instead) and to set it... I thought validation should have complained
loudly about the xml document itself? I guess I'm looking for a
setValidatingIReallyMeanIt(true) method :slight_smile:

Cheers
Andrea

Hi Andrea,

The way the validation stuff works with the parser is instead of throwing an exception when a validation error occurs it just keeps track of them while parsing. See the method getValidationErrors().

So you have run into a case where this falls down since you get a parsing error from one of the bindings. So i propose the following:

a) we add another method called setFailOnValidationError() so that the parser will cough up an exception when an error occurs

b) we cough up an exception by default

What do you think?

Andrea Aime wrote:

Hi,
the cite guys just hit me with a wcs request that contains
quite a bit of xml errors:

  <GetCoverage xmlns="http://www.opengis.net/wcs/1.1.1&quot;
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
                    xmlns:ctl="http://www.occamlab.com/ctl&quot;
                    xmlns:ows="http://www.opengis.org/ows/1.1&quot;
                    service="WCS"
                    version="1.1.1"
                    xsi:schemaLocation="http://www.opengis.net/wcs/1.1.1
http://schemas.opengis.net/wcs/1.1.1/wcsAll.xsd&quot;&gt;
          <Identifier>topp:rotated</Identifier>
          <ows:BoundingBox crs="urn:ogc:def:crs:EPSG::3003">
             <ows:LowerCorner>1402796.735086838
5000064.822668008</ows:LowerCorner>
             <ows:UpperCorner>1402868.2853603114
5000119.220342959</ows:UpperCorner>
          </ows:BoundingBox>
          <Format>application/arcgrid</Format>
       </GetCoverage>

Well, if we exclude the fact that the schema is not there,
there are other issues: the
Identifier element is not prefixed with ows: (it should),
the ows:boundingBox element is not a direct child of
GetCoverage (it should be enclosed with

I configured the xml parser with .setValidating(true),
yet it happily tries to parse the document anyways
and breaks with the following exception:

java.lang.RuntimeException: Parsing failed for GetCoverage:
java.lang.ClassCastException: java.lang.String cannot be cast to
net.opengis.ows.v1_1_0.CodeType
Parsing failed for GetCoverage: java.lang.ClassCastException:
java.lang.String cannot be cast to net.opengis.ows.v1_1_0.CodeType

That is, it tried to parse Identifier into a string (it's a codeType
instead) and to set it... I thought validation should have complained
loudly about the xml document itself? I guess I'm looking for a
setValidatingIReallyMeanIt(true) method :slight_smile:

Cheers
Andrea

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

!DSPAM:4007,47b1d58c265462143011171!

--
Justin Deoliveira
The Open Planning Project
jdeolive@anonymised.com

Justin Deoliveira ha scritto:

Hi Andrea,

The way the validation stuff works with the parser is instead of throwing an exception when a validation error occurs it just keeps track of them while parsing. See the method getValidationErrors().

So you have run into a case where this falls down since you get a parsing error from one of the bindings. So i propose the following:

a) we add another method called setFailOnValidationError() so that the parser will cough up an exception when an error occurs

b) we cough up an exception by default

What do you think?

Sounds good. At least for wcs 1.1, which is brand new, I'd like to
follow the hard line and pretend a valid request (and get good
error messages as a reward).

Cheers
Andrea