Schema refactoring:
authorMartin Vidner <mvidner@suse.cz>
Wed, 1 Mar 2006 15:07:16 +0000 (15:07 +0000)
committerMartin Vidner <mvidner@suse.cz>
Wed, 1 Mar 2006 15:07:16 +0000 (15:07 +0000)
- attribute-flags
- entry definitions in product.rnc are more readable now

zypp/parser/yum/schema/product.rnc
zypp/parser/yum/schema/product.rng
zypp/parser/yum/schema/rpm-ns.rnc
zypp/parser/yum/schema/rpm-ns.rng
zypp/parser/yum/schema/suse-primary.rnc
zypp/parser/yum/schema/suse-primary.rng

index 10dd694..c8b18b9 100644 (file)
@@ -1,6 +1,23 @@
 default namespace = "http://linux.duke.edu/metadata/rpm"
 namespace ns1 = "http://novell.com/package/metadata/suse/product"
 
+include "rpm-ns.rnc"
+
+attribute-kind = 
+  attribute kind { "package" | "patch" | "script" | "message" | "product"}
+
+usual-entry-content =
+  (
+    attribute-kind?,           # new compared to rpm-ns
+    attribute-name,
+    (
+      shared-entry-attributes,
+      attribute-flags
+    )?,
+    empty
+  )
+
+start =
 element ns1:product {
   attribute type { text },
   element ns1:vendor { text },
@@ -20,91 +37,55 @@ element ns1:product {
   }+,
   element provides {
     element entry {
-      attribute name { text },
-      attribute kind { "package" | "patch" | "script" | "message" | "product"}?,
-      (attribute flags { "EQ" | "LE" | "GE" },
-       attribute epoch { xsd:nonNegativeInteger },
-       attribute ver { text },
-       attribute rel { text }?)?,
+      attribute-kind?,
+      attribute-name,
+      (
+        shared-entry-attributes,
+        attribute-flags-provides
+      )?,
       empty
     }+
   }?,
   element conflicts {
     element entry {
-      attribute name { text },
-      attribute kind { "package" | "patch" | "script" | "message" | "product"}?,
-      (attribute flags { "EQ" | "LE" | "GE" | "LT" | "GT" },
-       attribute epoch { xsd:nonNegativeInteger },
-       attribute ver { text },
-       attribute rel { text }?)?,
-      empty
+      usual-entry-content
     }+
   }?,
   element obsoletes {
     element entry {
-      attribute name { text },
-      attribute kind { "package" | "patch" | "script" | "message" | "product"}?,
-      (attribute flags { "EQ" | "LE" | "GE" | "LT" },
-       attribute epoch { xsd:nonNegativeInteger },
-       attribute ver { text },
-       attribute rel { text }?)?,
+      attribute-kind?,
+      attribute-name,
+      (
+        shared-entry-attributes,
+        attribute-flags-obsoletes
+      )?,
       empty
     }+
   }?,
   element requires {
     element entry {
-      attribute name { text },
-      attribute kind { "package" | "patch" | "script" | "message" | "product"}?,
-      (attribute flags { "EQ" | "LE" | "GE" | "LT" | "GT" },
-       attribute epoch { xsd:nonNegativeInteger },
-       attribute ver { text },
-       attribute rel { text }?)?,
       attribute pre { "1" | "0" }?,
-      empty
+      usual-entry-content
     }*
   }?,
   element recommends {
     element entry {
-      attribute name { text },
-      attribute kind { "package" | "patch" | "script" | "message" | "product"}?,
-      (attribute flags { "EQ" | "LE" | "GE" | "LT" | "GT" },
-       attribute epoch { xsd:nonNegativeInteger },
-       attribute ver { text },
-       attribute rel { text }?)?,
-      empty
+      usual-entry-content
     }*
   }?,
   element enhances {
     element entry {
-      attribute name { text },
-      attribute kind { "package" | "patch" | "script" | "message" | "product"}?,
-      (attribute flags { "EQ" | "LE" | "GE" | "LT" | "GT" },
-       attribute epoch { xsd:nonNegativeInteger },
-       attribute ver { text },
-       attribute rel { text }?)?,
-      empty
+      usual-entry-content
     }*
   }?,
   element supplements {
     element entry {
-      attribute name { text },
-      attribute kind { "package" | "patch" | "script" | "message" | "product"}?,
-      (attribute flags { "EQ" | "LE" | "GE" | "LT" | "GT" },
-       attribute epoch { xsd:nonNegativeInteger },
-       attribute ver { text },
-       attribute rel { text }?)?,
-      empty
+      usual-entry-content
     }*
   }?,
   element suggests {
     element entry {
-      attribute name { text },
-      attribute kind { "package" | "patch" | "script" | "message" | "product"}?,
-      (attribute flags { "EQ" | "LE" | "GE" | "LT" | "GT" },
-       attribute epoch { xsd:nonNegativeInteger },
-       attribute ver { text },
-       attribute rel { text }?)?,
-      empty
+      usual-entry-content
     }*
   }?
 }
index 0e3d453..5c92fd3 100644 (file)
 <?xml version="1.0" encoding="UTF-8"?>
-<element name="ns1:product" xmlns:ns1="http://novell.com/package/metadata/suse/product" ns="http://linux.duke.edu/metadata/rpm" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
-  <attribute name="type"/>
-  <element name="ns1:vendor">
-    <text/>
-  </element>
-  <element name="ns1:name">
-    <text/>
-  </element>
-  <element name="ns1:version">
-    <attribute name="epoch">
-      <data type="nonNegativeInteger"/>
+<grammar xmlns:ns1="http://novell.com/package/metadata/suse/product" ns="http://linux.duke.edu/metadata/rpm" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+  <include href="rpm-ns.rng"/>
+  <define name="attribute-kind">
+    <attribute name="kind">
+      <choice>
+        <value>package</value>
+        <value>patch</value>
+        <value>script</value>
+        <value>message</value>
+        <value>product</value>
+      </choice>
     </attribute>
-    <attribute name="ver"/>
-    <attribute name="rel"/>
-  </element>
-  <oneOrMore>
-    <element name="ns1:displayname">
-      <attribute name="lang"/>
-      <text/>
-    </element>
-  </oneOrMore>
-  <oneOrMore>
-    <element name="ns1:description">
-      <attribute name="lang"/>
-      <text/>
-    </element>
-  </oneOrMore>
-  <optional>
-    <element name="provides">
+  </define>
+  <define name="usual-entry-content">
+    <optional>
+      <ref name="attribute-kind"/>
+    </optional>
+    <!-- new compared to rpm-ns -->
+    <ref name="attribute-name"/>
+    <optional>
+      <ref name="shared-entry-attributes"/>
+      <ref name="attribute-flags"/>
+    </optional>
+    <empty/>
+  </define>
+  <start>
+    <element name="ns1:product">
+      <attribute name="type"/>
+      <element name="ns1:vendor">
+        <text/>
+      </element>
+      <element name="ns1:name">
+        <text/>
+      </element>
+      <element name="ns1:version">
+        <attribute name="epoch">
+          <data type="nonNegativeInteger"/>
+        </attribute>
+        <attribute name="ver"/>
+        <attribute name="rel"/>
+      </element>
       <oneOrMore>
-        <element name="entry">
-          <attribute name="name"/>
-          <optional>
-            <attribute name="kind">
-              <choice>
-                <value>package</value>
-                <value>patch</value>
-                <value>script</value>
-                <value>message</value>
-                <value>product</value>
-              </choice>
-            </attribute>
-          </optional>
-          <optional>
-            <attribute name="flags">
-              <choice>
-                <value>EQ</value>
-                <value>LE</value>
-                <value>GE</value>
-              </choice>
-            </attribute>
-            <attribute name="epoch">
-              <data type="nonNegativeInteger"/>
-            </attribute>
-            <attribute name="ver"/>
-            <optional>
-              <attribute name="rel"/>
-            </optional>
-          </optional>
-          <empty/>
+        <element name="ns1:displayname">
+          <attribute name="lang"/>
+          <text/>
         </element>
       </oneOrMore>
-    </element>
-  </optional>
-  <optional>
-    <element name="conflicts">
       <oneOrMore>
-        <element name="entry">
-          <attribute name="name"/>
-          <optional>
-            <attribute name="kind">
-              <choice>
-                <value>package</value>
-                <value>patch</value>
-                <value>script</value>
-                <value>message</value>
-                <value>product</value>
-              </choice>
-            </attribute>
-          </optional>
-          <optional>
-            <attribute name="flags">
-              <choice>
-                <value>EQ</value>
-                <value>LE</value>
-                <value>GE</value>
-                <value>LT</value>
-                <value>GT</value>
-              </choice>
-            </attribute>
-            <attribute name="epoch">
-              <data type="nonNegativeInteger"/>
-            </attribute>
-            <attribute name="ver"/>
-            <optional>
-              <attribute name="rel"/>
-            </optional>
-          </optional>
-          <empty/>
+        <element name="ns1:description">
+          <attribute name="lang"/>
+          <text/>
         </element>
       </oneOrMore>
-    </element>
-  </optional>
-  <optional>
-    <element name="obsoletes">
-      <oneOrMore>
-        <element name="entry">
-          <attribute name="name"/>
-          <optional>
-            <attribute name="kind">
-              <choice>
-                <value>package</value>
-                <value>patch</value>
-                <value>script</value>
-                <value>message</value>
-                <value>product</value>
-              </choice>
-            </attribute>
-          </optional>
-          <optional>
-            <attribute name="flags">
-              <choice>
-                <value>EQ</value>
-                <value>LE</value>
-                <value>GE</value>
-                <value>LT</value>
-              </choice>
-            </attribute>
-            <attribute name="epoch">
-              <data type="nonNegativeInteger"/>
-            </attribute>
-            <attribute name="ver"/>
-            <optional>
-              <attribute name="rel"/>
-            </optional>
-          </optional>
-          <empty/>
+      <optional>
+        <element name="provides">
+          <oneOrMore>
+            <element name="entry">
+              <optional>
+                <ref name="attribute-kind"/>
+              </optional>
+              <ref name="attribute-name"/>
+              <optional>
+                <ref name="shared-entry-attributes"/>
+                <ref name="attribute-flags-provides"/>
+              </optional>
+              <empty/>
+            </element>
+          </oneOrMore>
         </element>
-      </oneOrMore>
-    </element>
-  </optional>
-  <optional>
-    <element name="requires">
-      <zeroOrMore>
-        <element name="entry">
-          <attribute name="name"/>
-          <optional>
-            <attribute name="kind">
-              <choice>
-                <value>package</value>
-                <value>patch</value>
-                <value>script</value>
-                <value>message</value>
-                <value>product</value>
-              </choice>
-            </attribute>
-          </optional>
-          <optional>
-            <attribute name="flags">
-              <choice>
-                <value>EQ</value>
-                <value>LE</value>
-                <value>GE</value>
-                <value>LT</value>
-                <value>GT</value>
-              </choice>
-            </attribute>
-            <attribute name="epoch">
-              <data type="nonNegativeInteger"/>
-            </attribute>
-            <attribute name="ver"/>
-            <optional>
-              <attribute name="rel"/>
-            </optional>
-          </optional>
-          <optional>
-            <attribute name="pre">
-              <choice>
-                <value>1</value>
-                <value>0</value>
-              </choice>
-            </attribute>
-          </optional>
-          <empty/>
+      </optional>
+      <optional>
+        <element name="conflicts">
+          <oneOrMore>
+            <element name="entry">
+              <ref name="usual-entry-content"/>
+            </element>
+          </oneOrMore>
         </element>
-      </zeroOrMore>
-    </element>
-  </optional>
-  <optional>
-    <element name="recommends">
-      <zeroOrMore>
-        <element name="entry">
-          <attribute name="name"/>
-          <optional>
-            <attribute name="kind">
-              <choice>
-                <value>package</value>
-                <value>patch</value>
-                <value>script</value>
-                <value>message</value>
-                <value>product</value>
-              </choice>
-            </attribute>
-          </optional>
-          <optional>
-            <attribute name="flags">
-              <choice>
-                <value>EQ</value>
-                <value>LE</value>
-                <value>GE</value>
-                <value>LT</value>
-                <value>GT</value>
-              </choice>
-            </attribute>
-            <attribute name="epoch">
-              <data type="nonNegativeInteger"/>
-            </attribute>
-            <attribute name="ver"/>
-            <optional>
-              <attribute name="rel"/>
-            </optional>
-          </optional>
-          <empty/>
+      </optional>
+      <optional>
+        <element name="obsoletes">
+          <oneOrMore>
+            <element name="entry">
+              <optional>
+                <ref name="attribute-kind"/>
+              </optional>
+              <ref name="attribute-name"/>
+              <optional>
+                <ref name="shared-entry-attributes"/>
+                <ref name="attribute-flags-obsoletes"/>
+              </optional>
+              <empty/>
+            </element>
+          </oneOrMore>
         </element>
-      </zeroOrMore>
-    </element>
-  </optional>
-  <optional>
-    <element name="enhances">
-      <zeroOrMore>
-        <element name="entry">
-          <attribute name="name"/>
-          <optional>
-            <attribute name="kind">
-              <choice>
-                <value>package</value>
-                <value>patch</value>
-                <value>script</value>
-                <value>message</value>
-                <value>product</value>
-              </choice>
-            </attribute>
-          </optional>
-          <optional>
-            <attribute name="flags">
-              <choice>
-                <value>EQ</value>
-                <value>LE</value>
-                <value>GE</value>
-                <value>LT</value>
-                <value>GT</value>
-              </choice>
-            </attribute>
-            <attribute name="epoch">
-              <data type="nonNegativeInteger"/>
-            </attribute>
-            <attribute name="ver"/>
-            <optional>
-              <attribute name="rel"/>
-            </optional>
-          </optional>
-          <empty/>
+      </optional>
+      <optional>
+        <element name="requires">
+          <zeroOrMore>
+            <element name="entry">
+              <optional>
+                <attribute name="pre">
+                  <choice>
+                    <value>1</value>
+                    <value>0</value>
+                  </choice>
+                </attribute>
+              </optional>
+              <ref name="usual-entry-content"/>
+            </element>
+          </zeroOrMore>
         </element>
-      </zeroOrMore>
-    </element>
-  </optional>
-  <optional>
-    <element name="supplements">
-      <zeroOrMore>
-        <element name="entry">
-          <attribute name="name"/>
-          <optional>
-            <attribute name="kind">
-              <choice>
-                <value>package</value>
-                <value>patch</value>
-                <value>script</value>
-                <value>message</value>
-                <value>product</value>
-              </choice>
-            </attribute>
-          </optional>
-          <optional>
-            <attribute name="flags">
-              <choice>
-                <value>EQ</value>
-                <value>LE</value>
-                <value>GE</value>
-                <value>LT</value>
-                <value>GT</value>
-              </choice>
-            </attribute>
-            <attribute name="epoch">
-              <data type="nonNegativeInteger"/>
-            </attribute>
-            <attribute name="ver"/>
-            <optional>
-              <attribute name="rel"/>
-            </optional>
-          </optional>
-          <empty/>
+      </optional>
+      <optional>
+        <element name="recommends">
+          <zeroOrMore>
+            <element name="entry">
+              <ref name="usual-entry-content"/>
+            </element>
+          </zeroOrMore>
         </element>
-      </zeroOrMore>
-    </element>
-  </optional>
-  <optional>
-    <element name="suggests">
-      <zeroOrMore>
-        <element name="entry">
-          <attribute name="name"/>
-          <optional>
-            <attribute name="kind">
-              <choice>
-                <value>package</value>
-                <value>patch</value>
-                <value>script</value>
-                <value>message</value>
-                <value>product</value>
-              </choice>
-            </attribute>
-          </optional>
-          <optional>
-            <attribute name="flags">
-              <choice>
-                <value>EQ</value>
-                <value>LE</value>
-                <value>GE</value>
-                <value>LT</value>
-                <value>GT</value>
-              </choice>
-            </attribute>
-            <attribute name="epoch">
-              <data type="nonNegativeInteger"/>
-            </attribute>
-            <attribute name="ver"/>
-            <optional>
-              <attribute name="rel"/>
-            </optional>
-          </optional>
-          <empty/>
+      </optional>
+      <optional>
+        <element name="enhances">
+          <zeroOrMore>
+            <element name="entry">
+              <ref name="usual-entry-content"/>
+            </element>
+          </zeroOrMore>
+        </element>
+      </optional>
+      <optional>
+        <element name="supplements">
+          <zeroOrMore>
+            <element name="entry">
+              <ref name="usual-entry-content"/>
+            </element>
+          </zeroOrMore>
+        </element>
+      </optional>
+      <optional>
+        <element name="suggests">
+          <zeroOrMore>
+            <element name="entry">
+              <ref name="usual-entry-content"/>
+            </element>
+          </zeroOrMore>
         </element>
-      </zeroOrMore>
+      </optional>
     </element>
-  </optional>
-</element>
+  </start>
+</grammar>
index b3c50b2..12c922c 100644 (file)
@@ -54,6 +54,13 @@ shared-entry-attributes =
      attribute ver { text },
      attribute rel { text }?
 
+attribute-flags-provides =
+  attribute flags { "EQ" | "LE" | "GE" }
+attribute-flags-obsoletes =
+  attribute flags { "EQ" | "LE" | "GE" | "LT" }
+attribute-flags =
+  attribute flags { "EQ" | "LE" | "GE" | "LT" | "GT" }
+
 attribute-name =
      attribute name { text }
 
@@ -62,7 +69,7 @@ provides =
       attribute-name,
       (
         shared-entry-attributes,
-        attribute flags { "EQ" | "LE" | "GE" }
+        attribute-flags-provides
       )?,
       empty
     }+
@@ -75,7 +82,7 @@ conflicts =
       attribute-name,
       (
         shared-entry-attributes,
-        attribute flags { "EQ" | "LE" | "GE" | "LT" | "GT" }
+        attribute-flags
       )?,
       empty
     }+
@@ -89,7 +96,7 @@ obsoletes =
       attribute-name,
       (
         shared-entry-attributes,
-        attribute flags { "EQ" | "LE" | "GE" | "LT" }
+        attribute-flags-obsoletes
       )?,
       empty
     }+
@@ -102,7 +109,7 @@ requires =
       attribute-name,
       (
         shared-entry-attributes,
-        attribute flags { "EQ" | "LE" | "GE" | "LT" | "GT" }
+        attribute-flags
       )?,
       attribute pre { "1" | "0" }?,
         empty
@@ -116,7 +123,7 @@ suggests =
       attribute-name,
       (
         shared-entry-attributes,
-        attribute flags { "EQ" | "LE" | "GE" | "LT" | "GT" }
+        attribute-flags
       )?,
       empty
       }*
@@ -129,7 +136,7 @@ recommends =
       attribute-name,
       (
         shared-entry-attributes,
-        attribute flags { "EQ" | "LE" | "GE" | "LT" | "GT" }
+        attribute-flags
       )?,
       empty
       }*
@@ -142,7 +149,7 @@ enhances =
       attribute-name,
       (
         shared-entry-attributes,
-        attribute flags { "EQ" | "LE" | "GE" | "LT" | "GT" }
+        attribute-flags
       )?,
       empty
       }*
@@ -155,7 +162,7 @@ supplements =
       attribute-name,
       (
         shared-entry-attributes,
-        attribute flags { "EQ" | "LE" | "GE" | "LT" | "GT" }
+        attribute-flags
       )?,
       empty
       }*
index ae468c7..67ebc28 100644 (file)
       <attribute name="rel"/>
     </optional>
   </define>
+  <define name="attribute-flags-provides">
+    <attribute name="flags">
+      <choice>
+        <value>EQ</value>
+        <value>LE</value>
+        <value>GE</value>
+      </choice>
+    </attribute>
+  </define>
+  <define name="attribute-flags-obsoletes">
+    <attribute name="flags">
+      <choice>
+        <value>EQ</value>
+        <value>LE</value>
+        <value>GE</value>
+        <value>LT</value>
+      </choice>
+    </attribute>
+  </define>
+  <define name="attribute-flags">
+    <attribute name="flags">
+      <choice>
+        <value>EQ</value>
+        <value>LE</value>
+        <value>GE</value>
+        <value>LT</value>
+        <value>GT</value>
+      </choice>
+    </attribute>
+  </define>
   <define name="attribute-name">
     <attribute name="name"/>
   </define>
         <ref name="attribute-name"/>
         <optional>
           <ref name="shared-entry-attributes"/>
-          <attribute name="flags">
-            <choice>
-              <value>EQ</value>
-              <value>LE</value>
-              <value>GE</value>
-            </choice>
-          </attribute>
+          <ref name="attribute-flags-provides"/>
         </optional>
         <empty/>
       </element>
         <ref name="attribute-name"/>
         <optional>
           <ref name="shared-entry-attributes"/>
-          <attribute name="flags">
-            <choice>
-              <value>EQ</value>
-              <value>LE</value>
-              <value>GE</value>
-              <value>LT</value>
-              <value>GT</value>
-            </choice>
-          </attribute>
+          <ref name="attribute-flags"/>
         </optional>
         <empty/>
       </element>
         <ref name="attribute-name"/>
         <optional>
           <ref name="shared-entry-attributes"/>
-          <attribute name="flags">
-            <choice>
-              <value>EQ</value>
-              <value>LE</value>
-              <value>GE</value>
-              <value>LT</value>
-            </choice>
-          </attribute>
+          <ref name="attribute-flags-obsoletes"/>
         </optional>
         <empty/>
       </element>
         <ref name="attribute-name"/>
         <optional>
           <ref name="shared-entry-attributes"/>
-          <attribute name="flags">
-            <choice>
-              <value>EQ</value>
-              <value>LE</value>
-              <value>GE</value>
-              <value>LT</value>
-              <value>GT</value>
-            </choice>
-          </attribute>
+          <ref name="attribute-flags"/>
         </optional>
         <optional>
           <attribute name="pre">
         <ref name="attribute-name"/>
         <optional>
           <ref name="shared-entry-attributes"/>
-          <attribute name="flags">
-            <choice>
-              <value>EQ</value>
-              <value>LE</value>
-              <value>GE</value>
-              <value>LT</value>
-              <value>GT</value>
-            </choice>
-          </attribute>
+          <ref name="attribute-flags"/>
         </optional>
         <empty/>
       </element>
         <ref name="attribute-name"/>
         <optional>
           <ref name="shared-entry-attributes"/>
-          <attribute name="flags">
-            <choice>
-              <value>EQ</value>
-              <value>LE</value>
-              <value>GE</value>
-              <value>LT</value>
-              <value>GT</value>
-            </choice>
-          </attribute>
+          <ref name="attribute-flags"/>
         </optional>
         <empty/>
       </element>
         <ref name="attribute-name"/>
         <optional>
           <ref name="shared-entry-attributes"/>
-          <attribute name="flags">
-            <choice>
-              <value>EQ</value>
-              <value>LE</value>
-              <value>GE</value>
-              <value>LT</value>
-              <value>GT</value>
-            </choice>
-          </attribute>
+          <ref name="attribute-flags"/>
         </optional>
         <empty/>
       </element>
         <ref name="attribute-name"/>
         <optional>
           <ref name="shared-entry-attributes"/>
-          <attribute name="flags">
-            <choice>
-              <value>EQ</value>
-              <value>LE</value>
-              <value>GE</value>
-              <value>LT</value>
-              <value>GT</value>
-            </choice>
-          </attribute>
+          <ref name="attribute-flags"/>
         </optional>
         <empty/>
       </element>
index b9c1a8f..f717569 100644 (file)
@@ -63,7 +63,7 @@ freshen =
       attribute-name,
       (
         shared-entry-attributes,
-        attribute flags { "EQ" | "LE" | "GE" | "LT" | "GT" }
+        attribute-flags
       )?,
       empty
     }+
index ea97990..d3663e7 100644 (file)
         <ref name="attribute-name"/>
         <optional>
           <ref name="shared-entry-attributes"/>
-          <attribute name="flags">
-            <choice>
-              <value>EQ</value>
-              <value>LE</value>
-              <value>GE</value>
-              <value>LT</value>
-              <value>GT</value>
-            </choice>
-          </attribute>
+          <ref name="attribute-flags"/>
         </optional>
         <empty/>
       </element>