Schema validation problem

S

steve_marjoribanks

I'm fairly new to XML and schemas and I'm trying to work out why a
schema I've been given keeps throwing up validation errors in XMLSpy.
The section of code with the problem is:

<!--============= Element =============-->
<element name="conResults" type="agsml:CongArrayType"
substitutionGroup="agsml:_congProperty"/>
<!--============= ComplexType =============-->
<complexType name="CongArrayType">
<complexContent>
<restriction base="gml:FeatureArrayPropertyType">
<sequence>
<element ref="agsml:_CongFeature" maxOccurs="unbounded"/>
</sequence>
</restriction>
</complexContent>
</complexType>


Whenever I try to validate it, XMLSpy highlights the <complexType
name="CongArrayType"> tag and says:
"The content model of complexType "agsml:CongArrayType" is not a valid
restriction of the content model of complexType
"gml:FeatureArrayPropertyType"

Presumably this means that there is an error elsewhere in the schema in
the part which defines gml:FeatureArrayPropertyType? Is this correct or
is there an obvious error in the above code which I have missed?
I can't really post the whole schema because it's a collection of 7
schemas which are hundreds of lines long!

Thanks
Stephen
 
G

GeorgeBina

Hi Stephen,

The error message refers to the fact that you cannot restrict the
gml:FeatureArrayPropertyType with something like you wrote in your
schema, that is with a content model like:
<sequence>
<element ref="agsml:_CongFeature" maxOccurs="unbounded"/>
</sequence>
This does not mean that the gml:FeatureArrayPropertyType has errors,
the error is in the defined CongArrayType.
You may look also in the spec where what a valid derivation by
restriction is specified:
http://www.w3.org/TR/xmlschema-1/#derivation-ok-restriction

Hope that helps,
George
 
S

steve_marjoribanks

Thanks for the info!
The problem is that I didn't write the schema and so I'm trying to work
out what they intended.
I think I understand what you said above but the one problem with it is
that there are numerous other elements and complex types declared of
exactly the same format as the one above, such as:

<!--============= Element =============-->
<element name="laboratoryTesting" type="agsml:SampArrayType"
substitutionGroup="agsml:_sampProperty"/>
<!--============= ComplexType =============-->
<complexType name="SampArrayType">
<complexContent>
<restriction base="gml:FeatureArrayPropertyType">
<sequence>
<element ref="agsml:_SampFeature" maxOccurs="unbounded"/>
</sequence>
</restriction>
</complexContent>
</complexType>


and none of these seem to throw up errors even though there are a
fCongArrayType isn't even though they both are of exactly the same
format and content (just with different names, types and refs)?

Thanks
Stephen
 
S

steve_marjoribanks

Sorry the last paragraph got messed up for some reason. It was supposed
to say;

and none of these seem to throw up errors even though they are of a
very similar layout/format to the CongArrayType complexType (ie.
different name and type, same restriction, one element in a sequence,
different reference element)
 
G

GeorgeBina

Hi Stephen

Maybe the answer is in the difference between agsml:_CongFeature and
agsml:_SampFeature?
It is hard to tell what is wrong from these fragments, you may want to
check also with different schema processors like XercesJ, XSV, Saxon8,
MSXML, etc. to see if you get an error message that can help you more.

Best Regards,
George
 
H

Henry S. Thompson

steve_marjoribanks said:
<!--============= ComplexType =============-->
<complexType name="CongArrayType">
<complexContent>
<restriction base="gml:FeatureArrayPropertyType">
<sequence>
<element ref="agsml:_CongFeature" maxOccurs="unbounded"/>
</sequence>
</restriction>
</complexContent>
</complexType>


Whenever I try to validate it, XMLSpy highlights the <complexType
name="CongArrayType"> tag and says:
"The content model of complexType "agsml:CongArrayType" is not a valid
restriction of the content model of complexType
"gml:FeatureArrayPropertyType"

So we need to see the complex type definition of
FeatureArrayPropertyType in the imported schema document for whatever
namespace 'gml' is bound to, before we can identify the problem.

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: (e-mail address removed)
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 
S

steve_marjoribanks

Ok, the gml:FeatureArrayPropertyType is defined as:

<element name="featureMembers" type="gml:FeatureArrayPropertyType"/>
<!-- ========================================================== -->
<complexType name="FeatureArrayPropertyType">
<annotation>
<documentation>Container for features - follow
gml:ArrayAssociationType pattern.</documentation>
</annotation>
<sequence>
<element ref="gml:_Feature" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>


the referenced element above is:

<element name="_Feature" type="gml:AbstractFeatureType" abstract="true"
substitutionGroup="gml:_GML"/>

and the gml:AbstractFeatureType as mentioned there is defined as:

<complexType name="AbstractFeatureType" abstract="true">
<annotation>
<documentation> An abstract feature provides a set of common
properties, including id, metaDataProperty, name and description
inherited from AbstractGMLType, plus boundedBy. A concrete feature
type must derive from this type and specify additional properties in
an application schema. A feature must possess an identifying attribute
('id' - 'fid' has been deprecated). </documentation>
</annotation>
<complexContent>
<extension base="gml:AbstractGMLType">
<sequence>
<element ref="gml:boundedBy" minOccurs="0"/>
<element ref="gml:location" minOccurs="0">
<annotation>
<appinfo>deprecated</appinfo>
<documentation>deprecated in GML version 3.1</documentation>
</annotation>
</element>
<!-- additional properties must be specified in an application
schema -->
</sequence>
</extension>
</complexContent>
</complexType>


However, I can see this problem going round in circles because the
original schema I was looking at was one of an 11 part schema
definition. These schemas in turn include certain GML schemas which
reference other schemas in the 33 part schema definition of the GML
dialect!!!
XMLSpy has now started saying in the error message "The schema doesn't
appear to be valid by itself (as part of another schema it might still
be ok), *error details here* ".
Seeing as it is saying there are validation errors with the GML schemas
(GML is now in version 3.1.0), I think it is more likely that the
schemas are in fact valid and it is simply a problem of XMLSpy not
being able to validate the schemas that are included in other schemas
or something like that? Surely it must be able to do this somehow
though, or can anyone recommend any other solutions?

Thanks for the help,
Stephen
 
H

Henry S. Thompson

steve_marjoribanks said:
<restriction base="gml:FeatureArrayPropertyType">
<sequence>
<element ref="agsml:_CongFeature" maxOccurs="unbounded"/>
</sequence>
</restriction>
Ok, the gml:FeatureArrayPropertyType is defined as:

<element name="featureMembers" type="gml:FeatureArrayPropertyType"/>
<!-- ========================================================== -->
<complexType name="FeatureArrayPropertyType">
<sequence>
<element ref="gml:_Feature" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>

<element name="_Feature" type="gml:AbstractFeatureType" abstract="true"
substitutionGroup="gml:_GML"/>

(gee, I love this remote debugging. . .:)

Given the above, what we know need to know is whether or not
agsml:_congFeature is substitutable for gml:_Feature, i.e. does the
agsml schema have something like

<element name="_congFeature" type="xyzzy"
substitutionGroup="gml:_Feature"/>

where 'xyzzy' is or is derived by restriction from gml:AbstractFeatureType?

If not, your schema is indeed broken. If so, the version of Spy
you're using is the likely culprit. Should have asked before now --
have you tried validating with another validator?

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: (e-mail address removed)
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 
S

steve_marjoribanks

The schema does have the above line in it, so I'm guessing I should try
with another validator. This is gonna sound really dumb but how do I go
about doing this?
 
S

steve_marjoribanks

Thanks for the links. However, I have found that all of the online
validators I've tried don't work in my case. This could be because they
don't like working with schemas which import other schemas I'm not
sure. However, I think the most likely explanation is that the AGSML
schemas I am looking at are not actually in use yet, they are only at
the consultation stage and as such are only stored on my local drive
not on the webspace which the agsml namespace refers to. I imagine this
might be causing some of the problems when validating because the
validator is having to import the schemas from a local directory. This
shouldn't be a problem when validating locally on my computer because
the include schema statement gives the local directory paths. So
basically, what other ways are there of validating a schema locally
please?
Thanks
 
H

Henry S. Thompson

steve_marjoribanks said:
So basically, what other ways are there of validating a schema
locally please? Thanks

XSV, Xerces and SQC are all available for download and local use --
see the W3C XML Schema home page [1] for a long list. . .

ht

[1] http://www.w3.org/XML/Schema.html
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: (e-mail address removed)
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 
S

steve_marjoribanks

I've just discovered that the schema validates fine when XMLSpy is in
Schema/WSDL view but comes up with an error if it is in text view?!!!!
Presumably this is a bug in XMLSpy then?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top