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 add constraints on two elements in schema - need help.. 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 "add constraints on two elements in schema - need help.." Watch "add constraints on two elements in schema - need help.." New topic
Author

add constraints on two elements in schema - need help..

Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
I have two elements in the schema:
< Item > and < Price >. Is there a way to add constraints on both these elements in the foll. manner:
Item can have the values "One" and "Two".
If Item="One" then Price="100"
else if Item="Two" then Price="200".
I understand the basics of schema like the complexType, the Sequence, the simpleType etc and
am tying to learn some complex stuff.
This is not a requirement but I want to design
it this way.
Any help is appreciated.
Thanks.
- madhav


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
I didn't tried the if then part,, but if you want to restrict the datas for item and price to one,two and 100,200 respectively then you try this schema

[ January 17, 2003: Message edited by: Balaji Loganathan ]

Spritle Software Blogs
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Thanks, Balaji. I got the restriction and enumaration part done.
I didn't tried the if then part,,
With all the fuss that schema's can do this do that....I am trying to know how to do complex expressions...hope someone can point me in the right direction.
Sometimes, its frustrating to accept that I am lagging so far behind the rest of the world.... :roll:
regds.
- madhav
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
knock..............knock...please...
Thanks.
- madhav
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
I hope you have the Schema tutorial of Henry thomson or Roger which is available at http://www.cogsci.ed.ac.uk/~ht/tutorials.html
thats the only good one i have for schema.
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Originally posted by Madhav Lakkapragada:
knock..............knock...please...
Thanks.
- madhav

the other option could be to use a validator to check this (if then) constraints, for example a small XSLT can do this checking job. But its depends on ur business case.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: add constraints on two elements in schema - need help..