According to the XML Schema specifications (Schema Component Constraint:
Complex Type Definition Properties Correct), if the base type is simple
type (xs:string in your case), the derivation method must be extension.
You need to create a new simple type which is a restriction of string.
Then, in your complexType definition, you will use extension as your
derivation method and your base will be the new simple type you just
defined.
For example:
<xs:simpleType name="BuySellType">
<xs:restriction base="xs:string">
<xs:enumeration value="BUY"/>
<xs:enumeration value="SELL"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="BuySellInd">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="BuySellType">
<xs:attribute name="elementID" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
Regards,
Khaled
Abhay Chaudhary wrote:
> Hi,
>
> I am facing a problem in validating a xml with schema. I need to write
> schema which supports attributes for leaf elements. Attached is the
> sample I tried and the parser Xerces-c 1.5.1 gives the following
> error.
>
> Error at file "D:\Buysell.xml", line 4, column 135
> Message: The type 'xs:string' is a simple type. It cannot be used
> in a derivation by RESTRICTION for a complexType
>
> Can somebody tell me what is wrong with the schema and how can I fix
> it with the requirement described above. Please help out.
>
> Regards,
>
> Abhay.
>
> ----------------------------------------------------------------
> ---------------------------------------------------------------------
> 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]