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 Tough XSD Validation Question 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 "Tough XSD Validation Question" Watch "Tough XSD Validation Question" New topic
Author

Tough XSD Validation Question

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1083
Ran into a tough validation issue I'm having trouble figuring out.

Say you want an XML Output like this:

Note that either of the two requests are OK, but you can't legally have an XML request with both a view 'id" and a "name" in the same request:



OR


------

So, in each request, you can have multiple of either "id" or "name", but not both in the same request.

--------------

The XSD below allows (incorrectly) both an "id" and a "name" in the multiple "views" elements.

How do I need to change the below so I only get multiple "ids" or multiple "name"s, but not both in the same XML request?

Thanks in advance.

-mike

g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 547
    
    3
With schema v1.0, it is a no. With schema v1.1, you can do this.

But you may not have all the agents involved supporting schema v1.1.

ps: I have no intention to comment on the renderment of RequestItems as it appeared in the original post.
pps: I use the assumption of empty targetNamespace which is not very clear from the excerpt as shown in the original post except at one point which suggests it may not be empty. If it is not, just qualified the elements view_id and view_name with prefix (if the targetNamespace is not being declared as a default namespace as well in xsd.)
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1083
g tsuji wrote:With schema v1.0, it is a no. With schema v1.1, you can do this.

But you may not have all the agents involved supporting schema v1.1.

ps: I have no intention to comment on the renderment of RequestItems as it appeared in the original post.
pps: I use the assumption of empty targetNamespace which is not very clear from the excerpt as shown in the original post except at one point which suggests it may not be empty. If it is not, just qualified the elements view_id and view_name with prefix (if the targetNamespace is not being declared as a default namespace as well in xsd.)


Wow. Thanks very much for your reply.

I guess I need to upgrade my XML Schema book and do some further study to understand what this 1.1 stuff means. :)

-- mike
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tough XSD Validation Question