p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > XML > XML
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 20th, 2009, 11:05 AM
Authorized User
Points: 156, Level: 3
Points: 156, Level: 3 Points: 156, Level: 3 Points: 156, Level: 3
Activity: 38%
Activity: 38% Activity: 38% Activity: 38%
 
Join Date: Apr 2008
Location: , , .
Posts: 36
Thanks: 5
Thanked 0 Times in 0 Posts
Default 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old October 20th, 2009, 11:13 AM
Friend of Wrox
Points: 3,131, Level: 23
Points: 3,131, Level: 23 Points: 3,131, Level: 23 Points: 3,131, Level: 23
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Nov 2007
Location: Germany
Posts: 655
Thanks: 0
Thanked 98 Times in 97 Posts
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
The Following User Says Thank You to Martin Honnen For This Useful Post:
nelly78 (October 20th, 2009)
  #3 (permalink)  
Old October 20th, 2009, 11:55 AM
Authorized User
Points: 156, Level: 3
Points: 156, Level: 3 Points: 156, Level: 3 Points: 156, Level: 3
Activity: 38%
Activity: 38% Activity: 38% Activity: 38%
 
Join Date: Apr 2008
Location: , , .
Posts: 36
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Thanks Martin, Its working ...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old October 20th, 2009, 11:56 AM
Authorized User
Points: 156, Level: 3
Points: 156, Level: 3 Points: 156, Level: 3 Points: 156, Level: 3
Activity: 38%
Activity: 38% Activity: 38% Activity: 38%
 
Join Date: Apr 2008
Location: , , .
Posts: 36
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Thanks Martin, Its working.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
create xml from xml schema in java zhebincong XML 1 October 6th, 2009 05:10 AM
how to refer any schema attribute in one file while it is declared in other maryj XML 2 June 21st, 2009 02:18 PM
What's the use of XML Schema?! janise XML 2 August 29th, 2004 06:31 AM
xml schema help allang XML 0 August 19th, 2004 10:58 PM
XML, XML Schema, JavaScript, ASP cyberjames2003 XML 0 June 4th, 2003 05:49 AM



All times are GMT -4. The time now is 07:23 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc