On Thu, 2009-05-21 at 12:00 +0000, xml-request gnome org wrote:
I have a recursive xml document structure which I am trying to validate with relaxng...
No response to my earlier request, so here is a simpler, runnable, demonstration of the issue. This rng definition allows any valid xml as long as each element contains an x attribute: <grammar xmlns="http://relaxng.org/ns/structure/1.0" ns=""> <start> <ref name="anyElement"/> </start> <define name="anyElement"> <element> <anyName/> <zeroOrMore> <choice> <attribute name="x"> </attribute> <text/> <ref name="anyElement"/> </choice> </zeroOrMore> </element> </define> </grammar> Here is the xml I wish to validate. Note that element q is missing the x attribute. <?xml version="1.0" encoding="UTF-8"?> <a x="y"> <b x="y"> <b x="y"> <c x="y"> <q y="y"> </q> </c> </b> </b> </a> Here is the output from xmllint: <?xml version="1.0" encoding="UTF-8"?> <a x="y"> <b x="y"> <b x="y"> <c x="y"> <q y="y"> </q> </c> </b> </b> </a> test.xml:4: element b: Relax-NG validity error : Element a has extra content: b test.xml fails to validate Given that the realxng grammar is defined recursively it is quite correct, but not very useful, to say that a, or even b, is invalid. What would be useful is an indication that the definition of q is malformed, or at least that c contains a malformed element. Is there any way I can define the rng file to give me such information while still defining it recursively? Better still, is there any way the relaxng validator can recognise that it is validating recursively and provide the error for each level of recursion? Something like: test.xml:4: element b: Relax-NG validity error : Element a has extra content: b Element b has extra content: b Element b has extra content: c Element c has extra content: q Invalid attribute y for element q test.xml fails to validate __ Marc
Attachment:
signature.asc
Description: This is a digitally signed message part