aspose file tools*
The moose likes XML and Related Technologies and the fly likes How do I enforce a particular constraint in a schema Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How do I enforce a particular constraint in a schema" Watch "How do I enforce a particular constraint in a schema" New topic
Author

How do I enforce a particular constraint in a schema

Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

I inherited a Schema Definition that I must validate against. However, the schema cannot be parsed as it is violating "Unique Particle Attribution". (I'll put the details below.) Unfortunately, I have little experience writing schemas and despite several hours with Google and a few XML/XSD books at my side, I have not been able to find a way to accomplish what the schema is attempting to accomplish. So I am asking my fellow ranchers for a hand.

Basically, the intent is the schema wants to enforce that a <foo> element always has either a <prefoo>, a <postfoo>, or both; so a <foo> element cannot exist alone. The <foo> element is (ultimately) a child of a <dataInformation> element.

Here is an excerpt from the schema:



When I attempt to parse the schema to use in validation, the following exception occurs:

org.xml.sax.SAXParseException: cos-nonambig: "":prefoo and "":prefoo (or elements from their
substitution group) violate "Unique Particle Attribution". During validation against this schema,
ambiguity would be created for those two particles.


Any suggestions on how I can rework the schema to get the desired affect of ensuring a <foo> element is always accompanied by a <prefoo>, OR a <postfoo> OR both?

Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I enforce a particular constraint in a schema
 
Similar Threads
problem with schema program
XML Schema validation
Schema Confusion?
Unique particle attribution rule bit me - why?
XML schema fails to load