xml validation error

View: New views
4 Messages — Rating Filter:   Alert me  

xml validation error

by nandana :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi,

while creating the below part of the xsd, I'm getting errors:

<xs:element name="HealthState">
<xs:complexType>
<xs:simpleContent>
<xs:restriction base="cim:cimUnsignedShort">
<xs:simpleType>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:unsignedShort">
<xs:enumeration value="0"/>
<xs:enumeration value="5"/>
<xs:enumeration value="10"/>
<xs:enumeration value="15"/>
<xs:enumeration value="20"/>
<xs:enumeration value="25"/>
<xs:enumeration value="30"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:unsignedShort">
<xs:minInclusive value="31"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
</xs:element>

where, the definition for cim:cimUnsignedShort is as follows in another xsd.:

<xs:complexType name="cimUnsignedShort">
<xs:simpleContent>
<xs:extension base="xs:unsignedShort">
<xs:anyAttribute namespace="##any" processContents="lax"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

Im getting the following error while validating:

Type '{anonymous}' is not a valid restriction of type 'cim:cimUnsignedShort'.
Error location: xs:schema / xs:element / xs:complexType / xs:simpleContent / xs:restriction / @base
derivation-ok-restriction.5.2: The simple type definition '{anonymous}' is not a valid restriction of the base type definition's content type 'xs:unsignedShort'.

Please help me understand the problem.

thanks in advance.

Nandan.

Re: xml validation error

by George Cristian Bina-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Nandan,

Point 5.2 from
http://www.w3.org/TR/xmlschema-1/#derivation-ok-restriction to which the
error message refers tells you that basically the derived simple type is
not a valid simple type derivation from the simple type of the base
content type, that is your simple type

<xs:simpleType>
   <xs:union>
     <xs:simpleType>
       <xs:restriction base="xs:unsignedShort">
         <xs:enumeration value="0"/>
         <xs:enumeration value="5"/>
         <xs:enumeration value="10"/>
         <xs:enumeration value="15"/>
         <xs:enumeration value="20"/>
         <xs:enumeration value="25"/>
         <xs:enumeration value="30"/>
       </xs:restriction>
     </xs:simpleType>
     <xs:simpleType>
       <xs:restriction base="xs:unsignedShort">
         <xs:minInclusive value="31"/>
       </xs:restriction>
     </xs:simpleType>
   </xs:union>
</xs:simpleType>

is not a restriction of xs:unsignedShort.

If you look at
http://www.w3.org/TR/xmlschema-1/#cos-st-derived-ok

you see in 2.2.3 that if your derived type is a union as in your case
then you can derive that only from anySimpleType.

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


nandanprasad wrote:

>
> hi,
>
> while creating the below part of the xsd, I'm getting errors:
>
> <xs:element name="HealthState">
> <xs:complexType>
> <xs:simpleContent>
> <xs:restriction base="cim:cimUnsignedShort">
> <xs:simpleType>
> <xs:union>
> <xs:simpleType>
> <xs:restriction base="xs:unsignedShort">
> <xs:enumeration value="0"/>
> <xs:enumeration value="5"/>
> <xs:enumeration value="10"/>
> <xs:enumeration value="15"/>
> <xs:enumeration value="20"/>
> <xs:enumeration value="25"/>
> <xs:enumeration value="30"/>
> </xs:restriction>
> </xs:simpleType>
> <xs:simpleType>
> <xs:restriction base="xs:unsignedShort">
> <xs:minInclusive value="31"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:union>
> </xs:simpleType>
> </xs:restriction>
> </xs:simpleContent>
> </xs:complexType>
> </xs:element>
>
> where, the definition for cim:cimUnsignedShort is as follows in another
> xsd.:
>
> <xs:complexType name="cimUnsignedShort">
> <xs:simpleContent>
> <xs:extension base="xs:unsignedShort">
> <xs:anyAttribute namespace="##any" processContents="lax"/>
> </xs:extension>
> </xs:simpleContent>
> </xs:complexType>
>
> Im getting the following error while validating:
>
> Type '{anonymous}' is not a valid restriction of type
> 'cim:cimUnsignedShort'.
> Error location: xs:schema / xs:element / xs:complexType / xs:simpleContent /
> xs:restriction / @base
> derivation-ok-restriction.5.2: The simple type definition '{anonymous}' is
> not a valid restriction of the base type definition's content type
> 'xs:unsignedShort'.
>
> Please help me understand the problem.
>
> thanks in advance.
>
> Nandan.


Re: xml validation error

by nandana :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
I tried doing the following to remove the error

<xs:anySimpleType>
   <xs:union>
     <xs:simpleType>
       <xs:restriction base="xs:unsignedShort">
         <xs:enumeration value="0"/>
         <xs:enumeration value="5"/>
         <xs:enumeration value="10"/>
         <xs:enumeration value="15"/>
         <xs:enumeration value="20"/>
         <xs:enumeration value="25"/>
         <xs:enumeration value="30"/>
       </xs:restriction>
     </xs:simpleType>
     <xs:simpleType>
       <xs:restriction base="xs:unsignedShort">
         <xs:minInclusive value="31"/>
       </xs:restriction>
     </xs:simpleType>
   </xs:union>
</xs:anySimpleType>

but, it doesn't recognise the <xs:anySimpleType> tag. Please help.

Thanks,
Nandan.


RE: xml validation error

by Michael Kay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> I tried doing the following to remove the error

You've misunderstood (and what you've written is meaningless). You're trying
to use this type in a position where the system requires your type to be a
restriction of xs:unsignedShort, and no type that you define as a union will
ever be a restriction of xs:unsignedShort. Your only remedy is to define
your type without using a union. You could do this for example by defining
it with a pattern:

xs:pattern value="0|5|10|15|20|25|[3-9]\d|\d{3,5}"

Michael Kay
http://www.saxonica.com/

>
> <xs:anySimpleType>
>    <xs:union>
>      <xs:simpleType>
>        <xs:restriction base="xs:unsignedShort">
>          <xs:enumeration value="0"/>
>          <xs:enumeration value="5"/>
>          <xs:enumeration value="10"/>
>          <xs:enumeration value="15"/>
>          <xs:enumeration value="20"/>
>          <xs:enumeration value="25"/>
>          <xs:enumeration value="30"/>
>        </xs:restriction>
>      </xs:simpleType>
>      <xs:simpleType>
>        <xs:restriction base="xs:unsignedShort">
>          <xs:minInclusive value="31"/>
>        </xs:restriction>
>      </xs:simpleType>
>    </xs:union>
> </xs:anySimpleType>
>
> but, it doesn't recognise the <xs:anySimpleType> tag. Please help.
>
> Thanks,
> Nandan.
>
>
> --
> View this message in context:
> http://www.nabble.com/xml-validation-error-tf3564425.html#a9957068
> Sent from the w3.org - xmlschema-dev mailing list archive at
> Nabble.com.
>
>