Jump to content

How Do I Set Restrictions On Attributes?


ChloeJacobs
 Share

Recommended Posts

Hi every1,This my first post, yey! I'm hoping you guys can help me out? I'm writing my first XSD file and all was goin smoothly until I was tryin to set restrictions for an attribute value within an element? For example my XML looks like this:<FILE> <ADVERT> <ROOT LOADTYPE="A"> ...I want my XSD file to say tat the value entered for the loadtype has to be A or B?Can any1 help me with this please?Kind Regards,Chloe ~X~

Link to comment
Share on other sites

Hi,Here's some more detail.So far my schema looks like this

<?xml version="1.0" encoding="utf-8"?><xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"	elementFormDefault="qualified"	xmlns="http://tempuri.org/XMLSchema.xsd"	xmlns:mstns="http://tempuri.org/XMLSchema.xsd"	xmlns:xs="http://www.w3.org/2001/XMLSchema" > <xs:element name ="FILE">  <xs:complexType>	<xs:sequence>	  <xs:element maxOccurs="unbounded" name="ADVERT">		<xs:complexType>		  <xs:sequence>			<xs:element maxOccurs="1" name="ROOT">				<xs:element name="LOADTYPE" type="xs:string" use="required">					<xs:simpleType>					  <xs:restriction base="xs:string">					  <xs:enumeration value="A"/>					  <xs:enumeration value="B"/>					</xs:restriction>					</xs:simpleType>				</xs:element> 			</xs:element>		  </xs:sequence>		</xs:complexType>	  </xs:element>	</xs:sequence>	</xs:complexType>  </xs:element></xs:schema>

But I'm receiving an error? Can anyone see where i am going wrong?Kind Regards,Chloe ~X~

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...