This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML Validation

 
Scott Selikoff
author
Saloon Keeper
Posts: 3900
16
Eclipse IDE Flex Google Web Toolkit
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do XSD/DTD allow validation based on the conditional appearance of attribute values?

For example:



versus this:



I want a validation rule such that:
1) If the value of provider is "Me", the attribute quality is not required, maybe because I trust my own quality for example.
2) If the value of provider is "John", then the attribute quality is required because I may not trust everything John gives me as valid.

Can XSD define this type of rule? If not, are there good alternatives for validating XML based on this type of attribute value sensitive rule?
[ August 09, 2006: Message edited by: Scott Selikoff ]
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any logic based on the value of an attribue seems like "business specific" logic more than a schema rule.

Personally, I would like my application to make that decision rather than in an XSD. So, if I were to write the rule I will expect everyone to have a quality attribute and leave it to the application to make sense of it.

All providers must provide a quality and then have a seperate list of trusted-providers. If a provider is in the trusted-provider list, ignore the quality. This is how I would do it in the application.

My two cents.
Thanks.

- m
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you really *need* them to be attributes?
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ilja,

I am a bit confused about your post. If not attributes are you suggesting that it should be an element ?

Just trying to understand the pros / cons.
Thanks.

- m
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic