|
|
 |
| XML General XML discussions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XML section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

October 20th, 2009, 11:05 AM
|
|
Authorized User
|
|
Join Date: Apr 2008
Location: , , .
Posts: 36
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
Restricting attribute value in XMl Schema
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 :
<News>
<Regional>
<Report Region="Asia">
<Title></Title>
<Story></Story>
</Report>
</Regional>
</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
|

October 20th, 2009, 11:13 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Location: Germany
Posts: 655
Thanks: 0
Thanked 98 Times in 97 Posts
|
|
If you do not want to allow two Report elements with the same Region attribute value in general then you can define a unique constraint e.g.
Code:
<xs:element name="Regional">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="Report">
...
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="unique-region">
<xs:selector xpath="Report"/>
<xs:field xpath="@Region"/>
</xs:unique>
</xs:complexType>
__________________
Martin Honnen
Microsoft MVP - XML
My blog
|
|
The Following User Says Thank You to Martin Honnen For This Useful Post:
|
|

October 20th, 2009, 11:55 AM
|
|
Authorized User
|
|
Join Date: Apr 2008
Location: , , .
Posts: 36
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
Thanks Martin, Its working ...
|

October 20th, 2009, 11:56 AM
|
|
Authorized User
|
|
Join Date: Apr 2008
Location: , , .
Posts: 36
Thanks: 5
Thanked 0 Times in 0 Posts
|
|
Thanks Martin, Its working.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |