Any schema language for XML that allows for specifying constraints like no cyclic references?

StackOverflow https://stackoverflow.com/questions/488019

  •  20-08-2019
  •  | 
  •  

Question

Is there any schema language for XML that allows for specifying a constraint that there can be no cyclic references between elements.

As a toy example:

<animal name="A" eats="B">
<animal name="B" eats="C">
<animal name="C" eats="D">

would validate, but

<animal name="A" eats="B">
<animal name="B" eats="C">
<animal name="C" eats="D">
<animal name="D" eats="A">

would not validate.

Was it helpful?

Solution

There are as far as I know no schema languages that are designed to enforce this kind of constraint. If it's possible in a schema language, it'd probably be Schematron. The schema wouldn't be pretty.

To me, that says you shouldn't try to do this using a schema language. Take any programming language that you're comfortable with and code up the constraint in easy to read code. It will be shorter and more understandable than any schema based version.

OTHER TIPS

You could use schematron, and then post the same question as an xslt/xpath problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top