リスト2 goods.rng

 1 <?xml version="1.0" encoding="UTF-8" ?>
 2 <grammar xmlns="http://relaxng.org/ns/structure/1.0"
 3          xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
 4          xmlns:relaxer="http://www.relaxer.org/xmlns/relaxer"
 5          xmlns:java="http://www.relaxer.org/xmlns/relaxer/java"
 6          xmlns:sql="http://www.relaxer.org/xmlns/relaxer/sql"
 7          datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
 8          ns="">
 9   <start>
10     <ref name="goodsList"/>
11   </start>
12   
13   <define name="goodsList">
14     <element name="goodsList">
15       <oneOrMore>
16         <ref name="goods"/>
17       </oneOrMore>
18     </element>
19   </define>
20
21   <define name="goods">
22     <element name="goods">
23       <attribute name="id">
24         <data type="integer"
25               datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"/>
26       </attribute>
27       <optional>
28         <attribute name="sample"/>
29       </optional>
30       <ref name="detail"/>
31     </element>
32   </define>
33
34   <define name="detail">
35     <element name="category">
36       <ref name="category"/>
37     </element>
38     <element name="price">
39       <ref name="price"/>
40     </element>
41     <element name="name"><text/></element>
42     <optional>
43       <element name="xmlDate">
44         <data type="date"
45               datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"/>
46       </element>
47     </optional>
48     <optional>
49       <element name="description"><text/></element>
50     </optional>
51   </define>
52
53   <define name="category">
54       <attribute name="id">
55       <data type="integer"
56             datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"/>
57       </attribute>
58       <element name="name"><text/></element>
59   </define>
60   
61   <define name="price">
62     <attribute name="id">
63       <data type="integer"
64             datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"/>
65     </attribute>
66     <element name="cost">
67       <data type="integer"
68             datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"/>
69     </element>
70     <element name="retail">
71       <data type="integer"
72             datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"/>
73     </element>
74   </define>
75 </grammar>