リスト1 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     <choice>
11       <ref name="goodsList"/>
12       <ref name="goods"/>
13     </choice>
14   </start>
15   
16   <define name="goodsList">
17     <element name="goodsList">
18       <oneOrMore>
19         <ref name="goods"/>
20       </oneOrMore>
21     </element>
22   </define>
23
24   <define name="goods">
25     <element name="goods">
26       <attribute name="id">
27         <data type="integer"
28               datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"/>
29       </attribute>
30       <optional>
31         <attribute name="sample"/>
32       </optional>
33       <ref name="detail"/>
34     </element>
35   </define>
36
37   <define name="detail">
38     <element name="category">
39       <ref name="category"/>
40     </element>
41     <element name="price">
42       <ref name="price"/>
43     </element>
44     <element name="name"><text/></element>
45     <optional>
46       <element name="xmlDate">
47         <data type="date"
48               datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"/>
49       </element>
50     </optional>
51     <optional>
52       <element name="description"><text/></element>
53     </optional>
54   </define>
55
56   <define name="category">
57       <attribute name="id">
58       <data type="integer"
59             datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"/>
60       </attribute>
61       <element name="name"><text/></element>
62   </define>
63   
64   <define name="price">
65     <attribute name="id">
66       <data type="integer"
67             datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"/>
68     </attribute>
69     <element name="cost">
70       <data type="integer"
71             datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"/>
72     </element>
73     <element name="retail">
74       <data type="integer"
75             datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"/>
76     </element>
77   </define>
78 </grammar>