Hi,
Maybe you can help. I am having validation problems, but doing restrictions. When validating one of the standard examples from Part 0 of the spec using the IBM schema checker, I get the error below:
-----------------------------------------------------------------------
In the definition of complexType ConfirmedItems, elementOnly content model (
<xsd:sequence maxOccurs="1" minOccurs="1">
**** <xsd:element maxOccurs="unbounded" minOccurs="1" name="item">
<xsd:complexType mixed="false">
<xsd:sequence maxOccurs="1" minOccurs="1">
<xsd:element maxOccurs="1" minOccurs="1"
name="productName" type="string"/>
<xsd:element maxOccurs="1" minOccurs="1" name="quantity">
<xsd:simpleType>
<xsd:restriction base="positiveInteger">
<xsd:maxExclusive value="100"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element maxOccurs="1" minOccurs="1" name="USPrice" type="decimal"/>
<xsd:element block="" maxOccurs="1" minOccurs="0" ref="comment"/>
<xsd:element maxOccurs="1" minOccurs="0" name="shipDate" type="date"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
is not a restriction of elementOnly content model
<xsd:sequence maxOccurs="1" minOccurs="1">
****<xsd:element maxOccurs="unbounded" minOccurs="0" name="item">
<xsd:complexType mixed="false">
<xsd:sequence maxOccurs="1" minOccurs="1">
<xsd:element maxOccurs="1" minOccurs="1"
name="productName" type="string"/>
<xsd:element maxOccurs="1" minOccurs="1" name="quantity">
<xsd:simpleType>
<xsd:restriction base="positiveInteger">
<xsd:maxExclusive value="100"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element maxOccurs="1" minOccurs="1" name="USPrice" type="decimal"/>
<xsd:element block="" maxOccurs="1" minOccurs="0" ref="comment"/>
<xsd:element maxOccurs="1" minOccurs="0" name="shipDate" type="date"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
the content type defined by the basetype.
--------------------------------------------------------------------
The asterisks are mine for highlighting. That line defines the restriction (from minOccurs="0" to minOccurs="1") which as far as I can tell should be a valid restriction.
My question:
Is this an error in the Primer or in the validator? Or am I missing some arcane point about restrictions?
Xerces generates a different error but because of the use of the following attribute group within both base and derived type:
<xsd:attributeGroup name="ItemDelivery">
<xsd:attribute name="partNum" type="SKU"/>
<xsd:attribute name="weightKg" type="xsd:decimal"/>
<xsd:attribute name="shipBy" >
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="air"/>
<xsd:enumeration value="sea"/>
<xsd:enumeration value="any"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:attributeGroup>
In this case the error is:
"ComplexType 'ConfirmedItems': derivation-ok-restriction.2.1.2: Type of attribute 'shipBy' in derivation must be a restriction of type of attribute in base."
Again, I find it difficult to see any problem with this restriction unless it has to do with the localness of the simple type on that attribute.
John
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 05 June 2001 18:22
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: Validation error
Hi,
The reason we emit the error is as follows -
- for derivation by extension, the set of attributes for a complexType
is obtained by doing a union of the attribute declarations in the base
and those specified as children in the extension (loosely speaking -
I'm paraphrasing somewhat). This is described in section 3.4.2 of
Structures. Note that for *restriction*, the final set of attributes
will not contain attribute uses from the base for which there are
similiarly named attribute uses as children of the restriction. The
same is not said of extension.
- it is illegal for the resulting set of attributes to contain
duplicates (as per "ComplexType Definition Properties Correct. 4":
Two distinct attribute declarations in the {attribute uses} must not
have identical {name}s and {target namespace}s.
So, this is why we detect such an error.
If this doesn't make sense, or doesn't reflect what you're doing with your
derivation, pls let me know.
Lisa.
---------------------- Forwarded by Lisa Martin/Toronto/IBM on 06/05/2001
12:08 PM ---------------------------
Ren� Jensen <[EMAIL PROTECTED]> on 06/04/2001 02:17:34 PM
Please respond to [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
cc:
Subject: Re: Validation error
Citat "Hunter, Francine" <[EMAIL PROTECTED]>:
> I am getting the following validation error using Xerces to validate an
> XML
> file against a Schema file:
>
> Schema error: Attribute that appeared in the base should nnot appear in
> a
> derivation by extension.
>
> Has any one seen this error before. What could the problem be?
Well my guess would be that you in your schema derives one complex type
from
another complex type, and that you in the derived type defines an attribute
which already is defined in the basetype.
\\|//
(@ @)
-----oOOo-(_)-oOOo-----
Ren� Jensen
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
