Jump to content
ChloeJacobs

How Do I Set Restrictions On Attributes?

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~

Share this post


Link to post
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~

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...