• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I enforce a particular constraint in a schema  RSS feed

Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!