[xml] unexpected behavior with RELAX-NG
- From: Seth Daniel <libxml sethdaniel org>
- To: xml gnome org
- Subject: [xml] unexpected behavior with RELAX-NG
- Date: Wed, 9 Jul 2003 14:13:09 -0700
Hello,
I have two RELAX-NG files. As far as I know they should be equivalent.
However, the first one will properly validate a conforming XML file and
the second will not.
First RELAX-NG file (good.rng):
<?xml version="1.0"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<element name="ABC">
<element name="required">
<attribute name="value"/>
</element>
<zeroOrMore>
<element>
<anyName/>
<attribute name="value"/>
</element>
</zeroOrMore>
</element>
</start>
</grammar>
Second RELAX-NG file (bad.rng):
<?xml version="1.0"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<element name="ABC">
<ref name="requiredElem"/>
<zeroOrMore>
<ref name="anyElem"/>
</zeroOrMore>
</element>
</start>
<define name="requiredElem">
<element name="required">
<attribute name="value"/>
</element>
</define>
<define name="anyElem">
<element>
<anyName/>
<attribute name="value"/>
</element>
</define>
</grammar>
Simple conforming XML file (t.xml):
<?xml version="1.0"?>
<ABC>
<required value="A"/>
<anything1 value="B"/>
<anything2 value="C"/>
</ABC>
Output of xmllint using good.rng:
$ xmllint --noout --relaxng good.rng t.xml
t.xml validates
Output of xmllint using bad.rng:
$ xmllint --noout --relaxng bad.rng t.xml
RNG validity error: file t.xml line 4 element anything1
Did not expect element anything1 there
t.xml fails to validate
--
seth / @sethdaniel.org
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]