• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML Validation

 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you really *need* them to be attributes?
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic