From 5fe30d5400c55a78627f9b3f4c45cb304417afd9 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Fri, 24 Apr 2015 17:39:32 +0600 Subject: Reduce the amount of references in the interface definition schema. --- data/schemata/interface_definition.rnc | 111 ++++++++----------- data/schemata/interface_definition.rng | 196 +++++++++++++++------------------ 2 files changed, 135 insertions(+), 172 deletions(-) (limited to 'data') 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 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -200,15 +102,97 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3