From dd2fc4d0d4b675220a6d66d5b4f57c10bfa25793 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 16 Apr 2015 04:56:38 +0600 Subject: Group node properties and children into their own tags. Make order of elements unimportant. Remove unused references. --- data/examples/interface_definition_sample.xml | 32 +++-- data/schemata/interface_definition.rnc | 61 +++++---- data/schemata/interface_definition.rng | 182 ++++++++++++++------------ 3 files changed, 155 insertions(+), 120 deletions(-) diff --git a/data/examples/interface_definition_sample.xml b/data/examples/interface_definition_sample.xml index e77240b..fe22e17 100644 --- a/data/examples/interface_definition_sample.xml +++ b/data/examples/interface_definition_sample.xml @@ -1,15 +1,29 @@ - - User name - - [a-z][a-zA-Z0-9]+ - User name must start with a letter and consist of letters and digits - - - User full name + + + + User name + + [a-z][a-zA-Z0-9]+ + User name must start with a letter and consist of letters and digits + + + + + + User full name + + + + + + + System hostname + text + - + diff --git a/data/schemata/interface_definition.rnc b/data/schemata/interface_definition.rnc index a20207b..d28d06d 100644 --- a/data/schemata/interface_definition.rnc +++ b/data/schemata/interface_definition.rnc @@ -34,15 +34,23 @@ extendsAttr = attribute extends text } -# Extends tag defines path prepended to the nodes -extends = element extends +# Normal and tag nodes may have children +children = element children { - path + (node | tagNode | leafNode)+ } -path = attribute path +# Nodes may have properties +# For simplicity, any property is allowed in any node, +# but whether they are used or not is implementation-defined +properties = element properties { - text + helpString?, + constraint?, + + # These are meaningful only for leaf nodes + valueHelpString?, + (multi | valueless)? } # node tag may contain node, leafNode, or tagNode tags @@ -50,10 +58,8 @@ path = attribute path # other nodes and must not have values node = element node { - ownerAttr?, - nodeNameAttr, - helpString?, - (node | tagNode | leafNode)* + (ownerAttr? & nodeNameAttr), + (properties? & children? ) } # All nodes must have "name" attribute @@ -74,7 +80,7 @@ ownerAttr = attribute owner # When multiple constraints are listed, they work as logical OR constraint = element constraint { - (regex | validator)+, + (regex | validator)+ & errorMessage? } @@ -87,8 +93,7 @@ regex = element regex # A constraint may also use an external validator validator = element validator { - validatorNameAttr, - validatorArgumentAttr, + (validatorNameAttr & validatorArgumentAttr), empty } @@ -116,11 +121,8 @@ errorMessage = element errorMessage # They must not contain other tag nodes tagNode = element tagNode { - ownerAttr?, - nodeNameAttr, - helpString?, - constraint?, - (node | leafNode)+ + (ownerAttr? & nodeNameAttr), + (properties? & children ) } # Leaf nodes are terminal configuration nodes that can't have children, @@ -132,10 +134,19 @@ tagNode = element tagNode leafNode = element leafNode { nodeNameAttr, - multiAttr?, - helpString?, - constraint?, - valueHelpString* + 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 +{ + empty } # helpString tag contains brief description of the purpose of the node @@ -150,11 +161,3 @@ valueHelpString = element valueHelpString { text } - -# multi= attribute indicates that a leaf node can have -# multiple values -# If not present, treated as "false" -multiAttr = attribute multi -{ - xsd:boolean -} diff --git a/data/schemata/interface_definition.rng b/data/schemata/interface_definition.rng index 7a53182..bc55542 100644 --- a/data/schemata/interface_definition.rng +++ b/data/schemata/interface_definition.rng @@ -1,5 +1,5 @@ - + - + - - - - - - - - + + + + + + + - - - - + + + + + + + + + + - - - - - + + - + - - + - + + + + + - - - + + - + + + + + + + + + + + + + + + + + + + + @@ -94,15 +121,17 @@ --> - - - - - - - - - + + + + + + + + + + + @@ -114,8 +143,10 @@ - - + + + + @@ -141,22 +172,18 @@ --> - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - -- cgit v1.2.3