Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

XML Validation

 
author
Posts: 4278
34
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
 
Are we home yet? Wait, did we forget the tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic