This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes XML Schema: JAXB validation for 2 attributes Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "XML Schema: JAXB validation for 2 attributes" Watch "XML Schema: JAXB validation for 2 attributes" New topic
Author

XML Schema: JAXB validation for 2 attributes

Sverre Moe
Ranch Hand

Joined: Jul 10, 2007
Posts: 109
I'm building a XML Schema to be used with JAXB and are faced with a problem with the schema.

Take the myElementType for example. It has two attributes that are requeired, but not both of them. Either of them is required if the other is omitted.




In order for JAXB to validate this properly how can I arrange the XML Schema for this element for these 2 attributes?
I guess one of the two must have precedence over the other. If class is defined, the presence of url is invalid or vice versa.
If neither is defined it must validate that it must have either class or url.


For what I have read it seems like it is not possible to have attributes like a choice.
http://stackoverflow.com/questions/763072/xsd-one-of-2-attributes-is-required
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: XML Schema: JAXB validation for 2 attributes
 
Similar Threads
converting xsd to html
XML valiadation using schema
Need to create nested element with name
JAXB - Weird Problem in unmarshling
namespace