Connecting Tech Pros Worldwide Help | Site Map

How to Restrict Attribute value in XML using XML Schema

Newbie
 
Join Date: Jul 2008
Posts: 28
#1: 4 Weeks Ago
Hi All,

I have an XMl structure and i am creating XML Schema document for validating xml document.
What i want that for a particular element it should not allow same attribute name.

for example below is the XML structure :

Expand|Select|Wrap|Line Numbers
  1. <News>
  2.    <Regional> 
  3.       <Report Region="Asia">
  4.         <Title></Title>
  5.         <Story></Story>
  6.       </Report>
  7.    </Regional>
  8. </News>
What i want in Xml Schema how can i restrict that in the "Region" Attribute of elemet <Report> value "Asia" occure only once. It should not allow two <Report> element with the value "Asia" in Region Attribute.

Thanks for the help

-John
Newbie
 
Join Date: Jul 2008
Posts: 28
#2: 4 Weeks Ago

re: How to Restrict Attribute value in XML using XML Schema


Hi All,
I have got the answer ...

Expand|Select|Wrap|Line Numbers
  1. <xs:unique name=”Unique_Region”>
  2. <xs:selector xpath=”Report />
  3. <xs:field xpath=”@Region” />
  4. </xs:unique>
Reply