468,103 Members | 1,189 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,103 developers. It's quick & easy.

Schema validation problem

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

Jan 18 '06 #1
12 2155
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/#de...ok-restriction

Hope that helps,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Jan 18 '06 #2
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

Jan 18 '06 #3
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)

Jan 18 '06 #4
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
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Jan 18 '06 #5
steve_marjoribanks writes:
<!--============= 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: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
Jan 18 '06 #6
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

Jan 18 '06 #7
steve_marjoribanks writes:
<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: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
Jan 19 '06 #8
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?

Jan 20 '06 #9
Here are a few web-based options:

http://apps.gotdotnet.com/xmltools/xsdvalidator/
http://www.w3.org/2001/03/webdata/xsv

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.

"steve_marjoribanks" <st****************@hotmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
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?

Jan 20 '06 #10
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

Jan 21 '06 #11
steve_marjoribanks writes:
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: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
Jan 23 '06 #12
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?

Jan 25 '06 #13

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Iain A. Mcleod | last post: by
1 post views Thread by Dan Bass | last post: by
2 posts views Thread by Ali | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.