Need help with Relax NG Compact schema
Posted: Thu Jan 10, 2008 7:55 pm
I'm trying to write a Relax NG Compact schema. RNC syntax is an absolute dream compared to XSD, and I like it better than regular RNG, too. But I'm trying to do something that's a little tricky.
I'm trying to write a schema that defines the elements <courses> and <course>. Basically, I want to be able to specify optional attributes on <courses>, but if specified disallows the attributes on nested <course> elements.
For example, the following would be legal:
And the following would also be legal:
But the following should be illegal:
…Because if <courses> has specified a @dept, no contained elements should be allowed to specify @dept of their own. (The idea is that they "inherit" their parent's @dept value.)
Does anyone know how to write this in Relax NG Compact syntax? (If not, does anyone have any advice?)[/code]
I'm trying to write a schema that defines the elements <courses> and <course>. Basically, I want to be able to specify optional attributes on <courses>, but if specified disallows the attributes on nested <course> elements.
For example, the following would be legal:
Code: Select all
<courses dept="ENGL">
<course number="101" />
<course number="201" />
</courses>
Code: Select all
<courses>
<course dept="ENGL" number="101" />
<course dept="ENGL" number="201" />
</courses>
Code: Select all
<courses dept="ENGL">
<course dept="ENGL" number="101" />
<course dept="ARTT" number="201" />
</courses>
Does anyone know how to write this in Relax NG Compact syntax? (If not, does anyone have any advice?)[/code]