summaryrefslogtreecommitdiff
path: root/data/schemata
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2015-04-24 17:39:32 +0600
committerDaniil Baturin <daniil@baturin.org>2015-04-24 17:39:32 +0600
commit5fe30d5400c55a78627f9b3f4c45cb304417afd9 (patch)
treece267833cc3ee3be1ef16d030f9c9554479ffb71 /data/schemata
parenteebd7f47f9de299adc79e3a57e2e394934665895 (diff)
downloadvyconf-5fe30d5400c55a78627f9b3f4c45cb304417afd9.tar.gz
vyconf-5fe30d5400c55a78627f9b3f4c45cb304417afd9.zip
Reduce the amount of references in the interface definition schema.
Diffstat (limited to 'data/schemata')
-rw-r--r--data/schemata/interface_definition.rnc111
-rw-r--r--data/schemata/interface_definition.rng196
2 files changed, 135 insertions, 172 deletions
diff --git a/data/schemata/interface_definition.rnc b/data/schemata/interface_definition.rnc
index ffad2af..3ad1dd8 100644
--- a/data/schemata/interface_definition.rnc
+++ b/data/schemata/interface_definition.rnc
@@ -34,6 +34,37 @@ extendsAttr = attribute extends
text
}
+# node tag may contain node, leafNode, or tagNode tags
+# Those are intermediate configuration nodes that may only contain
+# other nodes and must not have values
+node = element node
+{
+ (ownerAttr? & nodeNameAttr),
+ (properties? & children? )
+}
+
+# Tag nodes are containers for nodes without predefined names, like network interfaces
+# or user names (e.g. "interfaces ethernet eth0" or "user jrandomhacker")
+# Tag nodes may contain node and leafNode elements, and also nameConstraint tags
+# They must not contain other tag nodes
+tagNode = element tagNode
+{
+ (ownerAttr? & nodeNameAttr),
+ (properties? & children )
+}
+
+# Leaf nodes are terminal configuration nodes that can't have children,
+# but can have values.
+# Leaf node may contain one or more valueConstraint tags
+# If multiple valueConstraint tags are used, they work a logical OR
+# Leaf nodes can have "multi" attribute that indicated that it can have
+# more than one value
+leafNode = element leafNode
+{
+ nodeNameAttr,
+ properties
+}
+
# Normal and tag nodes may have children
children = element children
{
@@ -43,6 +74,12 @@ children = element children
# Nodes may have properties
# For simplicity, any property is allowed in any node,
# but whether they are used or not is implementation-defined
+#
+# Leaf nodes may differ in number of values that can be
+# associated with them.
+# By default, a leaf node can have only one value.
+# "multi" tag means a node can have one or more values,
+# "valueless" means it can have no values at all.
properties = element properties
{
help? &
@@ -50,17 +87,9 @@ properties = element properties
(element constraintErrorMessage { text })? &
# These are meaningful only for leaf nodes
- valueHelp? &
- (multi | valueless)?
-}
-
-# node tag may contain node, leafNode, or tagNode tags
-# Those are intermediate configuration nodes that may only contain
-# other nodes and must not have values
-node = element node
-{
- (ownerAttr? & nodeNameAttr),
- (properties? & children? )
+ (element valueless { empty })? &
+ (element multi { empty })? &
+ valueHelp*
}
# All nodes must have "name" attribute
@@ -81,65 +110,15 @@ ownerAttr = attribute owner
# When multiple constraints are listed, they work as logical OR
constraint = element constraint
{
- (regex | validator)+
+ ( (element regex { text }) |
+ validator )+
}
-# A constraint may be a regex pattern
-regex = element regex
-{
- text
-}
-
-# A constraint may also use an external validator
+# A constraint may also use an external validator rather than regex
validator = element validator
{
- (validatorNameAttr & validatorArgumentAttr),
- empty
-}
-
-# Validators are named
-validatorNameAttr = attribute name
-{
- text
-}
-
-# An argument can be passed to validator, in addition to the value to be validated
-validatorArgumentAttr = attribute argument
-{
- text
-}
-
-# Tag nodes are containers for nodes without predefined names, like network interfaces
-# or user names (e.g. "interfaces ethernet eth0" or "user jrandomhacker")
-# Tag nodes may contain node and leafNode elements, and also nameConstraint tags
-# They must not contain other tag nodes
-tagNode = element tagNode
-{
- (ownerAttr? & nodeNameAttr),
- (properties? & children )
-}
-
-# Leaf nodes are terminal configuration nodes that can't have children,
-# but can have values.
-# Leaf node may contain one or more valueConstraint tags
-# If multiple valueConstraint tags are used, they work a logical OR
-# Leaf nodes can have "multi" attribute that indicated that it can have
-# more than one value
-leafNode = element leafNode
-{
- nodeNameAttr,
- properties
-}
-
-# Some leaf nodes may have more than one value
-multi = element multi
-{
- empty
-}
-
-# Some leaf nodes may not have values (e.g. enable/disable flags)
-valueless = element valueless
-{
+ ( (attribute argument { text }) &
+ (attribute name { text }) ),
empty
}
diff --git a/data/schemata/interface_definition.rng b/data/schemata/interface_definition.rng
index 7766716..4625b67 100644
--- a/data/schemata/interface_definition.rng
+++ b/data/schemata/interface_definition.rng
@@ -43,43 +43,6 @@
<define name="extendsAttr">
<attribute name="extends"/>
</define>
- <!-- Normal and tag nodes may have children -->
- <define name="children">
- <element name="children">
- <oneOrMore>
- <choice>
- <ref name="node"/>
- <ref name="tagNode"/>
- <ref name="leafNode"/>
- </choice>
- </oneOrMore>
- </element>
- </define>
- <!--
- Nodes may have properties
- For simplicity, any property is allowed in any node,
- but whether they are used or not is implementation-defined
- -->
- <define name="properties">
- <element name="properties">
- <optional>
- <ref name="help"/>
- </optional>
- <optional>
- <ref name="constraint"/>
- </optional>
- <optional>
- <!-- These are meaningful only for leaf nodes -->
- <ref name="valueHelp"/>
- </optional>
- <optional>
- <choice>
- <ref name="multi"/>
- <ref name="valueless"/>
- </choice>
- </optional>
- </element>
- </define>
<!--
node tag may contain node, leafNode, or tagNode tags
Those are intermediate configuration nodes that may only contain
@@ -103,71 +66,10 @@
</interleave>
</element>
</define>
- <!-- All nodes must have "name" attribute -->
- <define name="nodeNameAttr">
- <attribute name="name"/>
- </define>
- <!--
- Ordinary nodes and tag nodes can have "owner" attribute.
- Owner is the component that is notified when node changes.
- -->
- <define name="ownerAttr">
- <attribute name="owner"/>
- </define>
- <!--
- Tag and leaf nodes may have constraints on their names and values
- (respectively).
- When multiple constraints are listed, they work as logical OR
- -->
- <define name="constraint">
- <element name="constraint">
- <interleave>
- <oneOrMore>
- <choice>
- <ref name="regex"/>
- <ref name="validator"/>
- </choice>
- </oneOrMore>
- <optional>
- <ref name="errorMessage"/>
- </optional>
- </interleave>
- </element>
- </define>
- <!-- A constraint may be a regex pattern -->
- <define name="regex">
- <element name="regex">
- <text/>
- </element>
- </define>
- <!-- A constraint may also use an external validator -->
- <define name="validator">
- <element name="validator">
- <interleave>
- <ref name="validatorNameAttr"/>
- <ref name="validatorArgumentAttr"/>
- </interleave>
- <empty/>
- </element>
- </define>
- <!-- Validators are named -->
- <define name="validatorNameAttr">
- <attribute name="name"/>
- </define>
- <!-- An argument can be passed to validator, in addition to the value to be validated -->
- <define name="validatorArgumentAttr">
- <attribute name="argument"/>
- </define>
- <!-- When validation fails, a message can be shown -->
- <define name="errorMessage">
- <element name="errorMessage">
- <text/>
- </element>
- </define>
<!--
Tag nodes are containers for nodes without predefined names, like network interfaces
or user names (e.g. "interfaces ethernet eth0" or "user jrandomhacker")
- Tag nodes may contain node and leafNode elements, and also nameConstraint tags
+ Tag nodes may contain node and leafNode elements, and also nameConstraint tags
They must not contain other tag nodes
-->
<define name="tagNode">
@@ -200,15 +102,97 @@
<ref name="properties"/>
</element>
</define>
- <!-- Some leaf nodes may have more than one value -->
- <define name="multi">
- <element name="multi">
- <empty/>
+ <!-- Normal and tag nodes may have children -->
+ <define name="children">
+ <element name="children">
+ <oneOrMore>
+ <choice>
+ <ref name="node"/>
+ <ref name="tagNode"/>
+ <ref name="leafNode"/>
+ </choice>
+ </oneOrMore>
+ </element>
+ </define>
+ <!--
+ Nodes may have properties
+ For simplicity, any property is allowed in any node,
+ but whether they are used or not is implementation-defined
+
+ Leaf nodes may differ in number of values that can be
+ associated with them.
+ By default, a leaf node can have only one value.
+ "multi" tag means a node can have one or more values,
+ "valueless" means it can have no values at all.
+ -->
+ <define name="properties">
+ <element name="properties">
+ <interleave>
+ <optional>
+ <ref name="help"/>
+ </optional>
+ <optional>
+ <ref name="constraint"/>
+ </optional>
+ <optional>
+ <element name="constraintErrorMessage">
+ <text/>
+ </element>
+ </optional>
+ <optional>
+ <!-- These are meaningful only for leaf nodes -->
+ <group>
+ <element name="valueless">
+ <empty/>
+ </element>
+ </group>
+ </optional>
+ <optional>
+ <element name="multi">
+ <empty/>
+ </element>
+ </optional>
+ <zeroOrMore>
+ <ref name="valueHelp"/>
+ </zeroOrMore>
+ </interleave>
</element>
</define>
- <!-- Some leaf nodes may not have values (e.g. enable/disable flags) -->
- <define name="valueless">
- <element name="valueless">
+ <!-- All nodes must have "name" attribute -->
+ <define name="nodeNameAttr">
+ <attribute name="name"/>
+ </define>
+ <!--
+ Ordinary nodes and tag nodes can have "owner" attribute.
+ Owner is the component that is notified when node changes.
+ -->
+ <define name="ownerAttr">
+ <attribute name="owner"/>
+ </define>
+ <!--
+ Tag and leaf nodes may have constraints on their names and values
+ (respectively).
+ When multiple constraints are listed, they work as logical OR
+ -->
+ <define name="constraint">
+ <element name="constraint">
+ <oneOrMore>
+ <choice>
+ <element name="regex">
+ <text/>
+ </element>
+ <ref name="validator"/>
+ </choice>
+ </oneOrMore>
+ </element>
+ </define>
+ <!-- A constraint may also use an external validator rather than regex -->
+ <define name="validator">
+ <element name="validator">
+ <interleave>
+ <attribute name="argument"/>
+ <attribute name="name"/>
+ </interleave>
<empty/>
</element>
</define>