File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes XML Validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML Validation" Watch "XML Validation" New topic
Author

XML Validation

Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

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 ]

My Blog: Down Home Country Coding with Scott Selikoff
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
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


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Do you really *need* them to be attributes?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
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
 
subject: XML Validation