XML Schema newbie question

K

Kevin B Ebert

I have the following xml document that I want to create a schema for:

<?xml version="1.0" encoding="utf-8" ?>
<CheckPoints xmlns="http://tempuri.org/WorkflowManager">
<CheckPoint id="uniqueID">
<case value="value1" actiontype="HOLD" action="action1" />
<case value="value1" actiontype="STATUS" action="action2" />
<case value="value1" actiontype="CLASS" action="action3" />
<case value="value1" actiontype="URL" action="action4" />
</CheckPoint>
</CheckPoints>

I want to develop a schema document that will limit the values for
"actiontype" to HOLD, STATUS, CLASS, or URL. Because I'm a newbie to
schema document creation, I used the schema generator within Visual
Studio. It generated the following schema:

<?xml version="1.0"?>
<xs:schema id="CheckPoints"
targetNamespace="http://tempuri.org/WorkflowManager"
xmlns:mstns="http://tempuri.org/WorkflowManager"
xmlns="http://tempuri.org/WorkflowManager"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="CheckPoints" msdata:IsDataSet="true"
msdata:EnforceConstraints="False">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="CheckPoint">
<xs:complexType>
<xs:sequence>
<xs:element name="case" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="value" form="unqualified"
type="xs:string" />
<xs:attribute name="actiontype" form="unqualified"
type="xs:string" />
<xs:attribute name="action" form="unqualified"
type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" form="unqualified"
type="xs:string" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

Thanks for the help in advance.
 
G

George Bina

Hi Kevin,

....
I want to develop a schema document that will limit the values for
"actiontype" to HOLD, STATUS, CLASS, or URL. ....
<xs:attribute name="actiontype" form="unqualified"
type="xs:string" />

You can use a restriction as below:

<xs:attribute name="actiontype" form="unqualified">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="HOLD"/>
<xs:enumeration value="STATUS"/>
<xs:enumeration value="CLASS"/>
<xs:enumeration value="URL"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>

Best Regards,
George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top