Exercice
Compléter le schéma RelaxNG schema.rng
afin que les fichiers XML file1.xml
, file2.xml
et file3.xml
soient valides. On cherchera le schéma le plus restrictif possible. On cherchera un schéma sans description redondante, en utilisant la syntaxe ref/define
lorsque c'est nécessaire.
1
<?xml version="1.0"?>
2
<!--file1.xml-->
3
<?oxygen RNGSchema="04.rng" type="xml"?>
4
<a>
5
<b><b1/></b>
6
</a>
<?xml version="1.0"?> <!--file1.xml--> <?oxygen RNGSchema="04.rng" type="xml"?> <a> <b><b1/></b> </a>
1
<?xml version="1.0"?>
2
<!--file2.xml-->
3
<?oxygen RNGSchema="04.rng" type="xml"?>
4
<a>
5
<b><b1/></b>
6
<b><b1/><b2/></b>
7
<b><b1/></b>
8
</a>
<?xml version="1.0"?> <!--file2.xml--> <?oxygen RNGSchema="04.rng" type="xml"?> <a> <b><b1/></b> <b><b1/><b2/></b> <b><b1/></b> </a>
1
<?xml version="1.0"?>
2
<!--file3.xml-->
3
<?oxygen RNGSchema="04.rng" type="xml"?>
4
<a>
5
<b><b1/></b>
6
<b><b1/><b2/></b>
7
<b><b1/></b>
8
<c/>
9
<c/>
10
<b><b1/></b>
11
<b><b1/></b>
12
</a>
<?xml version="1.0"?> <!--file3.xml--> <?oxygen RNGSchema="04.rng" type="xml"?> <a> <b><b1/></b> <b><b1/><b2/></b> <b><b1/></b> <c/> <c/> <b><b1/></b> <b><b1/></b> </a>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
3
<start>
4
<element name="a">
5
<oneOrMore>
6
<ref name="B"/>
7
</oneOrMore>
8
<zeroOrMore>
9
<element name="c">
10
<empty/>
11
</element>
12
</zeroOrMore>
13
<zeroOrMore>
14
<ref name="B"/>
15
</zeroOrMore>
16
</element>
17
</start>
18
<define name="B">
19
<element name="b">
20
<element name="b1">
21
<empty/>
22
</element>
23
<optional>
24
<element name="b2">
25
<empty/>
26
</element>
27
</optional>
28
</element>
29
</define>
30
</grammar>
<?xml version="1.0" encoding="UTF-8"?> <grammar xmlns="http://relaxng.org/ns/structure/1.0"> <start> <element name="a"> <oneOrMore> <ref name="B"/> </oneOrMore> <zeroOrMore> <element name="c"> <empty/> </element> </zeroOrMore> <zeroOrMore> <ref name="B"/> </zeroOrMore> </element> </start> <define name="B"> <element name="b"> <element name="b1"> <empty/> </element> <optional> <element name="b2"> <empty/> </element> </optional> </element> </define> </grammar>