Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Derivation by restriction
Derivation by restriction [message #52968] Thu, 16 September 2004 19:21 Go to next message
Eclipse UserFriend
Originally posted by: NOpcooperSPAM.uk.ibm.com

I have a test case below that seems to be well formed but is failing XSD
validation and I was wondering if anyone can confirm whether is this is
user error or not?

The messages I'm seeing are:
The type of element '#item' must derive from
http://test.org/#item_._type' at line '58' and column '11' in
'file:/C:/test/WSDLLib/Def10783.wsdl'.

The restricted content type must accept a subset of the content accepted
by the base type at line '54' and column '3' in
'file:/C:/test/WSDLLib/Def10783.wsdl'.

(Note, the line numbers may not match the input data as I've edited it
slightly for display purposes)


Here is a copy of the schema:

<s:schema targetNamespace="http://test.org/"
xmlns:s0="http://test.org/"
xmlns:s="http://www.w3.org/2001/XMLSchema">
<s:complexType name="Address" final="restriction">
<s:sequence>
<s:element name="name" type="s:string"/>
<s:element name="street" type="s:string"/>
<s:element name="city" type="s:string"/>
</s:sequence>
</s:complexType>

<!-- type derived by extension -->
<s:complexType name="USAddress">
<s:complexContent>
<s:extension base="s0:Address">
<s:sequence>
<s:element name="state" type="s0:USState"/>
<s:element name="zip" type="s:positiveInteger"/>
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>

<s:simpleType name="USState" final="restriction">
<s:restriction base="s:string">
<s:enumeration value="AK"/>
<s:enumeration value="AL"/>
<s:enumeration value="AR"/>
</s:restriction>
</s:simpleType>

<s:complexType name="Items" final="extension">
<s:sequence>
<s:element name="item" minOccurs="0" maxOccurs="unbounded">
<s:complexType>
<s:sequence>
<s:element name="productName" type="s:string"/>
<s:element name="quantity">
<s:simpleType>
<s:restriction base="s:positiveInteger">
<s:maxExclusive value="100"/>
</s:restriction>
</s:simpleType>
</s:element>
<s:element name="USPrice" type="s:decimal"/>
<s:element name="shipDate" type="s:date" minOccurs="0"/>
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>

<!-- type derived by restriction -->
<s:complexType name="ConfirmedItems">
<s:complexContent>
<s:restriction base="s0:Items">
<s:sequence>
<s:element name="item" minOccurs="1" maxOccurs="unbounded">
<s:complexType>
<s:sequence>
<s:element name="productName" type="s:string"/>
<s:element name="quantity">
<s:simpleType>
<s:restriction base="s:positiveInteger">
<s:maxExclusive value="100"/>
</s:restriction>
</s:simpleType>
</s:element>
<s:element name="USPrice" type="s:decimal"/>
<s:element name="shipDate" type="s:date" minOccurs="0"/>
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:restriction>
</s:complexContent>
</s:complexType>
</s:schema>

I think the sample input may have been taken from the XSD primer (or
somewhere similar) so it ought to be valid.

Any thoughts will be appreciated,

Thanks,
Paul Cooper.
Re: Derivation by restriction [message #52996 is a reply to message #52968] Thu, 16 September 2004 19:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------000208010209040804010007
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Paul,

Have a look at

http://www.w3.org/TR/xmlschema-1/#rcase-NameAndTypeOK

If you think about this comment there:

*NOTE: *The above constraint on {type definition} <#type_definition>
means that in deriving a type by restriction, any contained type
definitions must themselves be explicitly derived by restriction
from the corresponding type definitions in the base definition.

Since you can't restrict (or extend for that matter) an anonymous type,
you can't restrict a complex type that has local elements with anonymous
types, because you would need to repeat the element declaration and that
element declaration either must reuse the same type as in the base or
must specify a more restricted type than in the base, and yet neither
can be expressed because the type in the base is anonymous.


Paul Cooper wrote:

> I have a test case below that seems to be well formed but is failing
> XSD validation and I was wondering if anyone can confirm whether is
> this is user error or not?
>
> The messages I'm seeing are:
> The type of element '#item' must derive from
> http://test.org/#item_._type' at line '58' and column '11' in
> 'file:/C:/test/WSDLLib/Def10783.wsdl'.
>
> The restricted content type must accept a subset of the content
> accepted by the base type at line '54' and column '3' in
> 'file:/C:/test/WSDLLib/Def10783.wsdl'.
>
> (Note, the line numbers may not match the input data as I've edited it
> slightly for display purposes)
>
>
> Here is a copy of the schema:
>
> <s:schema targetNamespace="http://test.org/"
> xmlns:s0="http://test.org/"
> xmlns:s="http://www.w3.org/2001/XMLSchema">
> <s:complexType name="Address" final="restriction">
> <s:sequence>
> <s:element name="name" type="s:string"/>
> <s:element name="street" type="s:string"/>
> <s:element name="city" type="s:string"/>
> </s:sequence>
> </s:complexType>
>
> <!-- type derived by extension -->
> <s:complexType name="USAddress">
> <s:complexContent>
> <s:extension base="s0:Address">
> <s:sequence>
> <s:element name="state" type="s0:USState"/>
> <s:element name="zip" type="s:positiveInteger"/>
> </s:sequence>
> </s:extension>
> </s:complexContent>
> </s:complexType>
>
> <s:simpleType name="USState" final="restriction">
> <s:restriction base="s:string">
> <s:enumeration value="AK"/>
> <s:enumeration value="AL"/>
> <s:enumeration value="AR"/>
> </s:restriction>
> </s:simpleType>
>
> <s:complexType name="Items" final="extension">
> <s:sequence>
> <s:element name="item" minOccurs="0" maxOccurs="unbounded">
> <s:complexType>
> <s:sequence>
> <s:element name="productName" type="s:string"/>
> <s:element name="quantity">
> <s:simpleType>
> <s:restriction base="s:positiveInteger">
> <s:maxExclusive value="100"/>
> </s:restriction>
> </s:simpleType>
> </s:element>
> <s:element name="USPrice" type="s:decimal"/>
> <s:element name="shipDate" type="s:date" minOccurs="0"/>
> </s:sequence>
> </s:complexType>
> </s:element>
> </s:sequence>
> </s:complexType>
>
> <!-- type derived by restriction -->
> <s:complexType name="ConfirmedItems">
> <s:complexContent>
> <s:restriction base="s0:Items">
> <s:sequence>
> <s:element name="item" minOccurs="1" maxOccurs="unbounded">
> <s:complexType>
> <s:sequence>
> <s:element name="productName" type="s:string"/>
> <s:element name="quantity">
> <s:simpleType>
> <s:restriction base="s:positiveInteger">
> <s:maxExclusive value="100"/>
> </s:restriction>
> </s:simpleType>
> </s:element>
> <s:element name="USPrice" type="s:decimal"/>
> <s:element name="shipDate" type="s:date" minOccurs="0"/>
> </s:sequence>
> </s:complexType>
> </s:element>
> </s:sequence>
> </s:restriction>
> </s:complexContent>
> </s:complexType>
> </s:schema>
>
> I think the sample input may have been taken from the XSD primer (or
> somewhere similar) so it ought to be valid.
>
> Any thoughts will be appreciated,
>
> Thanks,
> Paul Cooper.



--------------000208010209040804010007
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Paul,<br>
<br>
Have a look at <br>
<blockquote><a
href="http://www.w3.org/TR/xmlschema-1/#rcase-NameAndTypeOK">http://www.w3.org/TR/xmlschema-1/#rcase-NameAndTypeOK</a><br>
</blockquote>
If you think about this comment there:<br>
<blockquote><b>NOTE: </b>The above constraint on <a class="propref"
href="#type_definition">{type definition}</a> means that in deriving a
type by restriction, any contained type definitions must themselves be
explicitly derived by restriction from the corresponding type
definitions in the base definition. </blockquote>
Since you can't restrict (or extend for that matter) an anonymous type,
you can't restrict a complex type that has local elements with
anonymous types, because you would need to repeat the element
declaration and that element declaration either must reuse the same
type as in the base or must specify a more restricted type than in the
base, and yet neither can be expressed because the type in the base is
anonymous.<br>
<br>
<br>
Paul Cooper wrote:<br>
<blockquote cite="midcicosl$94r$1@eclipse.org" type="cite">I have a
test case below that seems to be well formed but is failing XSD
validation and I was wondering if anyone can confirm whether is this is
user error or not?
<br>
<br>
The messages I'm seeing are:
<br>
The type of element '#item' must derive from
<a class="moz-txt-link-freetext" href="http://test.org/#item_._type">http://test.org/#item_._type</a>' at line '58' and column '11' in
'<a class="moz-txt-link-freetext" href="file:/C:/test/WSDLLib/Def10783.wsdl">file:/C:/test/WSDLLib/Def10783.wsdl </a>'.
<br>
<br>
The restricted content type must accept a subset of the content
accepted by the base type at line '54' and column '3' in
'<a class="moz-txt-link-freetext" href="file:/C:/test/WSDLLib/Def10783.wsdl">file:/C:/test/WSDLLib/Def10783.wsdl </a>'.
<br>
<br>
(Note, the line numbers may not match the input data as I've edited it
slightly for display purposes)
<br>
<br>
<br>
Here is a copy of the schema:
<br>
<br>
&lt;s:schema targetNamespace=<a class="moz-txt-link-rfc2396E" href="http://test.org/">"http://test.org/"</a>
<br>
&nbsp;&nbsp; xmlns:s0=<a class="moz-txt-link-rfc2396E" href="http://test.org/">"http://test.org/"</a>
<br>
&nbsp;&nbsp; xmlns:s=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>&gt;
<br>
&nbsp; &lt;s:complexType name="Address" final="restriction"&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:element name="name"&nbsp;&nbsp; type="s:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:element name="street" type="s:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:element name="city"&nbsp;&nbsp; type="s:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;/s:sequence&gt;
<br>
&nbsp; &lt;/s:complexType&gt;&nbsp;&nbsp;&nbsp; &nbsp; <br>
<br>
&nbsp; &lt;!-- type derived by extension --&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp; &lt;s:complexType name="USAddress"&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;s:complexContent&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:extension base="s0:Address"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:element name="state" type="s0:USState"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:element name="zip"&nbsp;&nbsp; type="s:positiveInteger"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/s:extension&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;/s:complexContent&gt;
<br>
&nbsp; &lt;/s:complexType&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <br>
<br>
&nbsp; &lt;s:simpleType name="USState" final="restriction"&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;s:restriction base="s:string"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:enumeration value="AK"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:enumeration value="AL"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:enumeration value="AR"/&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;/s:restriction&gt;
<br>
&nbsp; &lt;/s:simpleType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <br>
&nbsp; &lt;s:complexType name="Items" final="extension"&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:element name="item" minOccurs="0" maxOccurs="unbounded"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;s:complexType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:element name="productName" type="s:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:element name="quantity"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;s:simpleType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:restriction base="s:positiveInteger"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:maxExclusive value="100"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/s:restriction&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/s:simpleType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/s:element&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:element name="USPrice" type="s:decimal"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:element name="shipDate" type="s:date"
minOccurs="0"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/s:complexType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/s:element&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;/s:sequence&gt;
<br>
&nbsp; &lt;/s:complexType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <br>
&nbsp; &lt;!-- type derived by restriction --&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp; &lt;s:complexType name="ConfirmedItems"&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;s:complexContent&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:restriction base="s0:Items"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:element name="item" minOccurs="1"
maxOccurs="unbounded"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:complexType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:element name="productName" type="s:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:element name="quantity"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:simpleType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;s:restriction base="s:positiveInteger"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:maxExclusive value="100"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/s:restriction&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/s:simpleType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/s:element&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:element name="USPrice" type="s:decimal"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:element name="shipDate" type="s:date"
minOccurs="0"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/s:complexType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/s:element&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/s:restriction&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;/s:complexContent&gt;
<br>
&nbsp; &lt;/s:complexType&gt;
<br>
&lt;/s:schema&gt;
<br>
<br>
I think the sample input may have been taken from the XSD primer (or
somewhere similar) so it ought to be valid.
<br>
<br>
Any thoughts will be appreciated,
<br>
<br>
Thanks,
<br>
Paul Cooper.
<br>
</blockquote>
<br>
</body>
</html>

--------------000208010209040804010007--
Re: Derivation by restriction [message #53022 is a reply to message #52996] Fri, 17 September 2004 08:05 Go to previous message
Eclipse UserFriend
Originally posted by: NOpcooperSPAM.uk.ibm.com

Ed Merks wrote:

> Paul,
>
> Have a look at
>
> http://www.w3.org/TR/xmlschema-1/#rcase-NameAndTypeOK
>
> If you think about this comment there:
>
> *NOTE: *The above constraint on {type definition} <#type_definition>
> means that in deriving a type by restriction, any contained type
> definitions must themselves be explicitly derived by restriction
> from the corresponding type definitions in the base definition.
>
> Since you can't restrict (or extend for that matter) an anonymous type,
> you can't restrict a complex type that has local elements with anonymous
> types, because you would need to repeat the element declaration and that
> element declaration either must reuse the same type as in the base or
> must specify a more restricted type than in the base, and yet neither
> can be expressed because the type in the base is anonymous.
>
>
Thanks, I thought there had to be an error in the test case, I just
couldn't find it.

Paul.
Re: Derivation by restriction [message #591606 is a reply to message #52968] Thu, 16 September 2004 19:43 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000208010209040804010007
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Paul,

Have a look at

http://www.w3.org/TR/xmlschema-1/#rcase-NameAndTypeOK

If you think about this comment there:

*NOTE: *The above constraint on {type definition} <#type_definition>
means that in deriving a type by restriction, any contained type
definitions must themselves be explicitly derived by restriction
from the corresponding type definitions in the base definition.

Since you can't restrict (or extend for that matter) an anonymous type,
you can't restrict a complex type that has local elements with anonymous
types, because you would need to repeat the element declaration and that
element declaration either must reuse the same type as in the base or
must specify a more restricted type than in the base, and yet neither
can be expressed because the type in the base is anonymous.


Paul Cooper wrote:

> I have a test case below that seems to be well formed but is failing
> XSD validation and I was wondering if anyone can confirm whether is
> this is user error or not?
>
> The messages I'm seeing are:
> The type of element '#item' must derive from
> http://test.org/#item_._type' at line '58' and column '11' in
> 'file:/C:/test/WSDLLib/Def10783.wsdl'.
>
> The restricted content type must accept a subset of the content
> accepted by the base type at line '54' and column '3' in
> 'file:/C:/test/WSDLLib/Def10783.wsdl'.
>
> (Note, the line numbers may not match the input data as I've edited it
> slightly for display purposes)
>
>
> Here is a copy of the schema:
>
> <s:schema targetNamespace="http://test.org/"
> xmlns:s0="http://test.org/"
> xmlns:s="http://www.w3.org/2001/XMLSchema">
> <s:complexType name="Address" final="restriction">
> <s:sequence>
> <s:element name="name" type="s:string"/>
> <s:element name="street" type="s:string"/>
> <s:element name="city" type="s:string"/>
> </s:sequence>
> </s:complexType>
>
> <!-- type derived by extension -->
> <s:complexType name="USAddress">
> <s:complexContent>
> <s:extension base="s0:Address">
> <s:sequence>
> <s:element name="state" type="s0:USState"/>
> <s:element name="zip" type="s:positiveInteger"/>
> </s:sequence>
> </s:extension>
> </s:complexContent>
> </s:complexType>
>
> <s:simpleType name="USState" final="restriction">
> <s:restriction base="s:string">
> <s:enumeration value="AK"/>
> <s:enumeration value="AL"/>
> <s:enumeration value="AR"/>
> </s:restriction>
> </s:simpleType>
>
> <s:complexType name="Items" final="extension">
> <s:sequence>
> <s:element name="item" minOccurs="0" maxOccurs="unbounded">
> <s:complexType>
> <s:sequence>
> <s:element name="productName" type="s:string"/>
> <s:element name="quantity">
> <s:simpleType>
> <s:restriction base="s:positiveInteger">
> <s:maxExclusive value="100"/>
> </s:restriction>
> </s:simpleType>
> </s:element>
> <s:element name="USPrice" type="s:decimal"/>
> <s:element name="shipDate" type="s:date" minOccurs="0"/>
> </s:sequence>
> </s:complexType>
> </s:element>
> </s:sequence>
> </s:complexType>
>
> <!-- type derived by restriction -->
> <s:complexType name="ConfirmedItems">
> <s:complexContent>
> <s:restriction base="s0:Items">
> <s:sequence>
> <s:element name="item" minOccurs="1" maxOccurs="unbounded">
> <s:complexType>
> <s:sequence>
> <s:element name="productName" type="s:string"/>
> <s:element name="quantity">
> <s:simpleType>
> <s:restriction base="s:positiveInteger">
> <s:maxExclusive value="100"/>
> </s:restriction>
> </s:simpleType>
> </s:element>
> <s:element name="USPrice" type="s:decimal"/>
> <s:element name="shipDate" type="s:date" minOccurs="0"/>
> </s:sequence>
> </s:complexType>
> </s:element>
> </s:sequence>
> </s:restriction>
> </s:complexContent>
> </s:complexType>
> </s:schema>
>
> I think the sample input may have been taken from the XSD primer (or
> somewhere similar) so it ought to be valid.
>
> Any thoughts will be appreciated,
>
> Thanks,
> Paul Cooper.



--------------000208010209040804010007
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Paul,<br>
<br>
Have a look at <br>
<blockquote><a
href="http://www.w3.org/TR/xmlschema-1/#rcase-NameAndTypeOK">http://www.w3.org/TR/xmlschema-1/#rcase-NameAndTypeOK</a><br>
</blockquote>
If you think about this comment there:<br>
<blockquote><b>NOTE: </b>The above constraint on <a class="propref"
href="#type_definition">{type definition}</a> means that in deriving a
type by restriction, any contained type definitions must themselves be
explicitly derived by restriction from the corresponding type
definitions in the base definition. </blockquote>
Since you can't restrict (or extend for that matter) an anonymous type,
you can't restrict a complex type that has local elements with
anonymous types, because you would need to repeat the element
declaration and that element declaration either must reuse the same
type as in the base or must specify a more restricted type than in the
base, and yet neither can be expressed because the type in the base is
anonymous.<br>
<br>
<br>
Paul Cooper wrote:<br>
<blockquote cite="midcicosl$94r$1@eclipse.org" type="cite">I have a
test case below that seems to be well formed but is failing XSD
validation and I was wondering if anyone can confirm whether is this is
user error or not?
<br>
<br>
The messages I'm seeing are:
<br>
The type of element '#item' must derive from
<a class="moz-txt-link-freetext" href="http://test.org/#item_._type">http://test.org/#item_._type</a>' at line '58' and column '11' in
'<a class="moz-txt-link-freetext" href="file:/C:/test/WSDLLib/Def10783.wsdl">file:/C:/test/WSDLLib/Def10783.wsdl </a>'.
<br>
<br>
The restricted content type must accept a subset of the content
accepted by the base type at line '54' and column '3' in
'<a class="moz-txt-link-freetext" href="file:/C:/test/WSDLLib/Def10783.wsdl">file:/C:/test/WSDLLib/Def10783.wsdl </a>'.
<br>
<br>
(Note, the line numbers may not match the input data as I've edited it
slightly for display purposes)
<br>
<br>
<br>
Here is a copy of the schema:
<br>
<br>
&lt;s:schema targetNamespace=<a class="moz-txt-link-rfc2396E" href="http://test.org/">"http://test.org/"</a>
<br>
&nbsp;&nbsp; xmlns:s0=<a class="moz-txt-link-rfc2396E" href="http://test.org/">"http://test.org/"</a>
<br>
&nbsp;&nbsp; xmlns:s=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>&gt;
<br>
&nbsp; &lt;s:complexType name="Address" final="restriction"&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:element name="name"&nbsp;&nbsp; type="s:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:element name="street" type="s:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:element name="city"&nbsp;&nbsp; type="s:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;/s:sequence&gt;
<br>
&nbsp; &lt;/s:complexType&gt;&nbsp;&nbsp;&nbsp; &nbsp; <br>
<br>
&nbsp; &lt;!-- type derived by extension --&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp; &lt;s:complexType name="USAddress"&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;s:complexContent&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:extension base="s0:Address"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:element name="state" type="s0:USState"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:element name="zip"&nbsp;&nbsp; type="s:positiveInteger"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/s:extension&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;/s:complexContent&gt;
<br>
&nbsp; &lt;/s:complexType&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <br>
<br>
&nbsp; &lt;s:simpleType name="USState" final="restriction"&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;s:restriction base="s:string"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:enumeration value="AK"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:enumeration value="AL"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:enumeration value="AR"/&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;/s:restriction&gt;
<br>
&nbsp; &lt;/s:simpleType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <br>
&nbsp; &lt;s:complexType name="Items" final="extension"&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:element name="item" minOccurs="0" maxOccurs="unbounded"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;s:complexType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:element name="productName" type="s:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:element name="quantity"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;s:simpleType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:restriction base="s:positiveInteger"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:maxExclusive value="100"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/s:restriction&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/s:simpleType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/s:element&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:element name="USPrice" type="s:decimal"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:element name="shipDate" type="s:date"
minOccurs="0"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/s:complexType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/s:element&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;/s:sequence&gt;
<br>
&nbsp; &lt;/s:complexType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <br>
&nbsp; &lt;!-- type derived by restriction --&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp; &lt;s:complexType name="ConfirmedItems"&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;s:complexContent&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:restriction base="s0:Items"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:element name="item" minOccurs="1"
maxOccurs="unbounded"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:complexType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:element name="productName" type="s:string"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:element name="quantity"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;s:simpleType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;s:restriction base="s:positiveInteger"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:maxExclusive value="100"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/s:restriction&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/s:simpleType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/s:element&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:element name="USPrice" type="s:decimal"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;s:element name="shipDate" type="s:date"
minOccurs="0"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/s:complexType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/s:element&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/s:sequence&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/s:restriction&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;/s:complexContent&gt;
<br>
&nbsp; &lt;/s:complexType&gt;
<br>
&lt;/s:schema&gt;
<br>
<br>
I think the sample input may have been taken from the XSD primer (or
somewhere similar) so it ought to be valid.
<br>
<br>
Any thoughts will be appreciated,
<br>
<br>
Thanks,
<br>
Paul Cooper.
<br>
</blockquote>
<br>
</body>
</html>

--------------000208010209040804010007--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Derivation by restriction [message #591615 is a reply to message #52996] Fri, 17 September 2004 08:05 Go to previous message
Paul Cooper is currently offline Paul CooperFriend
Messages: 11
Registered: July 2009
Junior Member
Ed Merks wrote:

> Paul,
>
> Have a look at
>
> http://www.w3.org/TR/xmlschema-1/#rcase-NameAndTypeOK
>
> If you think about this comment there:
>
> *NOTE: *The above constraint on {type definition} <#type_definition>
> means that in deriving a type by restriction, any contained type
> definitions must themselves be explicitly derived by restriction
> from the corresponding type definitions in the base definition.
>
> Since you can't restrict (or extend for that matter) an anonymous type,
> you can't restrict a complex type that has local elements with anonymous
> types, because you would need to repeat the element declaration and that
> element declaration either must reuse the same type as in the base or
> must specify a more restricted type than in the base, and yet neither
> can be expressed because the type in the base is anonymous.
>
>
Thanks, I thought there had to be an error in the test case, I just
couldn't find it.

Paul.
Previous Topic:Derivation by restriction
Next Topic:Deteriming if an ElementDeclaration is a Simple or Complex Type
Goto Forum:
  


Current Time: Fri Apr 26 10:19:08 GMT 2024

Powered by FUDForum. Page generated in 0.03140 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top