Page 1 of 1
XMLSpy says "valid" -- oXygen says "invalid&q
Posted: Tue Jul 27, 2004 1:45 am
by danwhite
I was not sure if I should post this to Problems or Feature Requests, so I am trying here first.
Here is the sample
Code: Select all
<xs:simpleType name="TimeType">
<xs:restriction base="xs:string">
<xs:length value="6"/>
<xs:minLength value="6"/>
<xs:maxLength value="6"/>
<xs:pattern value="[0-2][0-3][0-5][0-9][0-5][0-9]"/>
</xs:restriction>
</xs:simpleType>
XML-Spy says this is valid.
oXygen says "It is an error for both length and either of minLength or maxLength to be specified."
I found errata here (
http://www.w3.org/2001/05/xmlschema-errata#e2-66) that says that it is OK to do it this way.
How do we proceed from here ?
Posted: Tue Jul 27, 2004 2:34 am
by george
Hi Dan,
The erata specifies two conditions linked by
and for each of the maxLength and minLength facets:
If length is a member of {facets} then
1 It is an error for minLength to be a member of {facets} unless
1.1 the {value} of minLength <= the {value} of length and
1.2 there is type definition from which this one is derived by one or more restriction steps in which minLength has the same {value} and length is not specified.
2 It is an error for maxLength to be a member of {facets} unless
2.1 the {value} of length <= the {value} of maxLength and
2.2 there is type definition from which this one is derived by one or more restriction steps in which maxLength has the same {value} and length is not specified.
Your schema does not fulfill the second condition (1.2 and 2.2, respectively) as the base type is xs:string which does not have the minLength or the maxLength facet defined, therefore it is invalid.
I think the erata allows something like:
Code: Select all
<xs:simpleType name="TimeTypeBase">
<xs:restriction base="xs:string">
<xs:minLength value="6"/>
<xs:maxLength value="6"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TimeType">
<xs:restriction base="TimeTypeBase">
<xs:length value="6"/>
<xs:pattern value="[0-2][0-3][0-5][0-9][0-5][0-9]"/>
</xs:restriction>
</xs:simpleType>
which is successfully validated by Oxygen.
Oxygen uses the latest Xerces release (2.6.2) to perform XML schema validation.
Best Regards,
George
Posted: Tue Jul 27, 2004 2:43 am
by danwhite
OK, the errata is convoluted, but I think I get it.
Bottom line is that you cannot have length/minLength/maxLength all in the same group, yes ?
I will direct a polite grouch at the XML-Spy folks
Thank you for the clarification.
Posted: Tue Jul 27, 2004 2:45 am
by danwhite
Actually, it is good to know that oXygen uses Xerces. I plan to use the C++ Xerces library to work with the schemas I am making.
This adds one more great reason not to spend US$500 on the pro version of XML Spy
Thanks again.
Posted: Tue Jul 27, 2004 3:00 am
by george
I think yes, there is no point to define a maxLength or a minLength together with length, this will be redundant. However, if a base type specifies a maxLength it makes sense to restrict that to the maximum specified length value in a derived type by restriction.
Oxygen uses the Java version of Xerces, Xerces J. Anyway some of the Xerces J developers are among the Xerces C developers so they should be quite similar.
Best Regards,
George
Posted: Tue Jul 27, 2004 3:46 pm
by danwhite
Seems like overkill, doesn't it ?
Perhap the intent was to say, for a string field of length 6, that there must be exactly 6 characters, no more, no less.
But then I would expect saying (minLength=6 maxLength=6) would do that.
Just my opinion. I could be wrong.
Thanks again for the clarification.