Download XML Prague 2011 Conference Proceedings

Transcript
Configuring Network Devices with NETCONF and YANG
biguate the names to avoid clashes: it prepends the originating module name separated by two underscores.
Further, RELAX NG named pattern definitions are always global inside a
grammar, whereas YANG allows for lexically scoped definitions appearing anywhere
in the schema tree. Again, the mapping procedure has to disambiguate their names,
this time by prepending the full schema context in the form of a sequence of names
of all ancestor containers.
Several examples of mangled names may be found in Section A.1.
Another feature of YANG groupings is that their contents adopts the namespace
of the module in which the grouping used. In other words, if module A imports and
uses a grouping from module B, all data nodes defined inside the grouping belong
to the namespace of module A. This is the so-called “chameleon design” [17], which
is also possible in RELAX NG but requires a special arrangement of the including
and included schemas. Consequently, the mapping procedure has to follow this
arrangement when generating the validation RELAX NG schemas:
1. Groupings with the global scope, i.e. those that may be imported by other
modules, must be collected from all input modules, mapped and stored in a
separate RELAX NG schema file.
2. Every input module is mapped to an embedded grammar which has the local
module namespace as the value of its ns attribute. The schema with global
definitions is then included into this embedded grammar and the grouping
contents adopt the namespace declared in the ns attribute.
4.2.2. Augments
In order to simulate the effects of an augment statement, the mapping procedure
must explicitly add the new nodes as element patterns to the RELAX NG schema
at the location pointed to by the argument of the augment statement.
Augments also influence the handling of groupings. For example, if the target
node of an augment happens to come from a grouping, then the grouping must be
expanded at the place where it is used so that the augment may be applied to this
particular use of the grouping but not to other uses of the same grouping elsewhere.
In practice, an implementation of the mapping algorithm has to process augments
from all input modules into a list of “patches” and apply them at the right places
when traversing the schema tree.
4.3. Mapping Semantic Constraints
Schematron rules are constructed from semantic annotations appearing in the hybrid
schema. For example, the hybrid schema for our coffee machine (see Section A.1)
contains the following RELAX NG element pattern in which the nma:key declares
the cm:address child element as the list key:
110