In RelaxNG, I want to describe a structure similar to this:
<parent>
<subelem1>
<subelem1>
<subelem1>
...
</parent>
or:
<parent>
<subelem2>
<subelem2>
<subelem2>
...
</parent>
I tried with the following rng:
<rng:element name="parent">
<rng:choice>
<rng:zeroOrMore>
<rng:ref name="subelem1"/>
</rng:zeroOrMore>
<rng:zeroOrMore>
<rng:ref name="subelem2"/>
</rng:zeroOrMore>
</rng:choice>
</rng:element>
But verifying with lxml
in Python, I only get error messages Did not expect element subelem1 there
.
What's wrong there?
I've used a slightly different schema to yours but it should be functionality the same:
That validates both your sample documents just fine using jing and also with xmllint (which uses libxml2 as does lxml in python if I remember correctly). I'd suggest comparing your full grammar (I assume you only posted part of it) with the above. Also, I corrected your namespaces (the
choice
element wasn't in one). If you still can't validate I would suggest hte problem is withlxml
rather than the grammar.