--- 1/draft-ietf-netmod-dsdl-map-09.txt 2010-10-21 21:14:14.000000000 +0200 +++ 2/draft-ietf-netmod-dsdl-map-10.txt 2010-10-21 21:14:14.000000000 +0200 @@ -1,19 +1,19 @@ NETMOD L. Lhotka, Ed. Internet-Draft CESNET Intended status: Standards Track October 21, 2010 Expires: April 24, 2011 Mapping YANG to Document Schema Definition Languages and Validating NETCONF Content - draft-ietf-netmod-dsdl-map-09 + draft-ietf-netmod-dsdl-map-10 Abstract This document specifies the mapping rules for translating YANG data models into Document Schema Definition Languages (DSDL), a coordinated set of XML schema languages standardized as ISO/IEC 19757. The following DSDL schema languages are addressed by the mapping: RELAX NG, Schematron and DSRL. The mapping takes one or more YANG modules and produces a set of DSDL schemas for a selected target document type - datastore content, NETCONF message etc. @@ -130,29 +130,30 @@ 10.45. The 'presence' Statement . . . . . . . . . . . . . . . . 55 10.46. The 'range' Statement . . . . . . . . . . . . . . . . . 55 10.47. The 'reference' Statement . . . . . . . . . . . . . . . 55 10.48. The 'require-instance' Statement . . . . . . . . . . . . 55 10.49. The 'revision' Statement . . . . . . . . . . . . . . . . 55 10.50. The 'rpc' Statement . . . . . . . . . . . . . . . . . . 55 10.51. The 'status' Statement . . . . . . . . . . . . . . . . . 56 10.52. The 'submodule' Statement . . . . . . . . . . . . . . . 56 10.53. The 'type' Statement . . . . . . . . . . . . . . . . . . 56 10.53.1. The "empty" Type . . . . . . . . . . . . . . . . . 57 - 10.53.2. The "boolean" and "binary" Types . . . . . . . . . 58 - 10.53.3. The "bits" Type . . . . . . . . . . . . . . . . . . 58 - 10.53.4. The "enumeration" and "union" Types . . . . . . . . 58 - 10.53.5. The "identityref" Type . . . . . . . . . . . . . . 58 - 10.53.6. The "instance-identifier" Type . . . . . . . . . . 59 - 10.53.7. The "leafref" Type . . . . . . . . . . . . . . . . 59 - 10.53.8. The Numeric Types . . . . . . . . . . . . . . . . . 59 - 10.53.9. The "string" Type . . . . . . . . . . . . . . . . . 61 - 10.53.10. Derived Types . . . . . . . . . . . . . . . . . . . 62 + 10.53.2. The "boolean" Type . . . . . . . . . . . . . . . . 57 + 10.53.3. The "binary" Type . . . . . . . . . . . . . . . . . 58 + 10.53.4. The "bits" Type . . . . . . . . . . . . . . . . . . 58 + 10.53.5. The "enumeration" and "union" Types . . . . . . . . 58 + 10.53.6. The "identityref" Type . . . . . . . . . . . . . . 58 + 10.53.7. The "instance-identifier" Type . . . . . . . . . . 59 + 10.53.8. The "leafref" Type . . . . . . . . . . . . . . . . 59 + 10.53.9. The Numeric Types . . . . . . . . . . . . . . . . . 59 + 10.53.10. The "string" Type . . . . . . . . . . . . . . . . . 61 + 10.53.11. Derived Types . . . . . . . . . . . . . . . . . . . 62 10.54. The 'typedef' Statement . . . . . . . . . . . . . . . . 63 10.55. The 'unique' Statement . . . . . . . . . . . . . . . . . 63 10.56. The 'units' Statement . . . . . . . . . . . . . . . . . 64 10.57. The 'uses' Statement . . . . . . . . . . . . . . . . . . 64 10.58. The 'value' Statement . . . . . . . . . . . . . . . . . 64 10.59. The 'when' Statement . . . . . . . . . . . . . . . . . . 64 10.60. The 'yang-version' Statement . . . . . . . . . . . . . . 64 10.61. The 'yin-element' Statement . . . . . . . . . . . . . . 64 11. Mapping the Hybrid Schema to DSDL . . . . . . . . . . . . . . 65 11.1. Generating RELAX NG Schemas for Various Document Types . 65 @@ -691,27 +692,27 @@ | | 10.16 | 1 | | | | | | | 10.17 | 1 | | | | | | @nma:if-feature | 10.22 | | | | | | | @nma:implicit | 10.11, 10.7, 10.12 | | | | | | | | 8.1 | 4 | | | | | - | | 10.53.6 | 2 | + | | 10.53.7 | 2 | | | | | | @nma:key | 10.26 | | | | | | | @nma:leaf-list | 10.28 | | | | | | - | @nma:leafref | 10.53.7 | | + | @nma:leafref | 10.53.8 | | | | | | | @nma:mandatory | 10.8 | | | | | | | @nma:max-elements | 10.28 | | | | | | | @nma:min-elements | 10.28 | | | | | | | @nma:module | 10.34 | | | | | | | | 10.35 | 3 | @@ -1774,31 +1775,31 @@ used for augmenting the schema tree of another YANG module. If the augmented module is not processed within the same mapping session, the top-level 'augment' statement MUST be ignored. Otherwise, the contents of the statement are added to the foreign module with the namespace of the module where the 'augment' statement appears. 10.4. The 'base' Statement This statement is ignored as a substatement of 'identity' and handled within the 'identityref' type if it appears as a substatement of that - type definition, see Section 10.53.5. + type definition, see Section 10.53.6. 10.5. The 'belongs-to' Statement This statement is not used since the processing of submodules is always initiated from the main module, see Section 10.24. 10.6. The 'bit' Statement This statement is handled within the "bits" type, see - Section 10.53.3. + Section 10.53.4. 10.7. The 'case' Statement This statement is mapped to or element, depending on whether the statement belongs to an definition of an RPC operation or not. If the argument of a sibling 'default' statement equals to ARGUMENT, @nma:implicit attribute with the value of "true" MUST be added to that or element. The @nma:implicit attribute MUST NOT be used for nodes at the top-level of a non-default case (see Section 7.9.3 in [RFC6020]). @@ -2138,21 +2139,21 @@ 10.29. The 'length' Statement This statement is handled within the "string" type, see - Section 10.53.9. + Section 10.53.10. 10.30. The 'list' Statement This statement is mapped exactly as the 'leaf-list' statement, see Section 10.28. The only difference is that the @nma:leaf-list annotation either MUST NOT be present or MUST have the value of "false". When mapping the substatements of 'list', the order of children of the list element MUST be specified so that list keys, if there are @@ -2262,21 +2263,21 @@ is mapped to The default-lease-time must be less than max-lease-time 10.36. The 'namespace' Statement - This statement is mapped in two ways: + This statement is mapped simultaneously in two ways: 1. To the @xmlns:PREFIX attribute of the root element where PREFIX is the namespace prefix specified by the sibling 'prefix' statement. ARGUMENT becomes the value of this attribute. 2. To the @ns attribute of PARENT, which is an embedded pattern. ARGUMENT becomes the value of this attribute. 10.37. The 'notification' Statement @@ -2310,57 +2311,57 @@ authorship information. 10.40. The 'output' Statement This statement is handled within the 'rpc' statement, see Section 10.50. 10.41. The 'path' Statement This statement is handled within the "leafref" type, see - Section 10.53.7. + Section 10.53.8. 10.42. The 'pattern' Statement This statement is handled within the "string" type, see - Section 10.53.9. + Section 10.53.10. 10.43. The 'position' Statement This statement is ignored. 10.44. The 'prefix' Statement This statement is handled within the sibling 'namespace' statement, see Section 10.36, or within the parent 'import' statement, see Section 10.23. As a substatement of 'belongs-to' (in submodules), the 'prefix' statement is ignored. 10.45. The 'presence' Statement This statement influences the mapping of the parent container (Section 10.11): the parent container definition MUST be wrapped in , regardless of its contents. See also Section 9.1.1. 10.46. The 'range' Statement - This statement is handled within numeric types, see Section 10.53.8. + This statement is handled within numeric types, see Section 10.53.9. 10.47. The 'reference' Statement This statement is mapped to element and its text is set to ARGUMENT prefixed with "See: ". 10.48. The 'require-instance' Statement This statement is handled within "instance-identifier" type - (Section 10.53.6). + (Section 10.53.7). 10.49. The 'revision' Statement The mapping uses only the most recent instance of the 'revision' statement, i.e., one with the latest date in ARGUMENT, which specifies the current revision of the input YANG module [RFC6020]. This date SHOULD be recorded, together with the name of the YANG module, in the corresponding Dublin Core element (see Section 10.34), for example in this form: @@ -2422,22 +2423,20 @@ | uint8 | unsignedByte | 8-bit unsigned integer value | | | | | | uint16 | unsignedShort | 16-bit unsigned integer value | | | | | | uint32 | unsignedInt | 32-bit unsigned integer value | | | | | | uint64 | unsignedLong | 64-bit unsigned integer value | | | | | | string | string | character string | | | | | - | boolean | boolean | "true" or "false" | - | | | | | binary | base64Binary | binary data in base64 encoding | +-----------+---------------+--------------------------------+ Table 4: YANG built-in datatypes with equivalents in the W3C XML Schema Type Library Two important datatypes of the XSD datatype library - "dateTime" and "anyURI" - are not built-in types in YANG but instead are defined as derived types in the standard modules [RFC6021]: "date-and-time" in the "ietf-yang-types" module and "uri" in the "ietf-inet-types" @@ -2446,43 +2445,57 @@ to-DSDL mapping SHOULD detect these derived types in source YANG modules and map them to "dateType" and "anyURI", respectively. Details about the mapping of individual YANG built-in types are given in the following subsections. 10.53.1. The "empty" Type This type is mapped to . -10.53.2. The "boolean" and "binary" Types +10.53.2. The "boolean" Type - These two built-in types do not allow any restrictions and are mapped - simply by inserting element whose @type attribute is set - to ARGUMENT mapped according to Table 4 above. + This built-in type does not allow any restrictions and is mapped to + the following XML fragment: -10.53.3. The "bits" Type + + true + false + + + Note that the XSD "boolean" type cannot be used here because it + allows, unlike YANG, an alternative numeric representation of boolean + values: 0 for "false" and 1 for "true". + +10.53.3. The "binary" Type + + This built-in type does not allow any restrictions and is mapped + simply by inserting element whose @type attribute value is + set to "base64Binary" (see also Table 4). + +10.53.4. The "bits" Type This type is mapped to and for each 'bit' substatement the following XML fragment is inserted as a child of : bit_name where bit_name is the name of the bit as found in the argument of a 'bit' substatement. -10.53.4. The "enumeration" and "union" Types +10.53.5. The "enumeration" and "union" Types These types are mapped to the element. -10.53.5. The "identityref" Type +10.53.6. The "identityref" Type This type is mapped to the following named pattern reference: where PREFIX:BASE is the qualified name of the identity appearing in the argument of the 'base' substatement. For example, assume that module "des" in Section 10.21 contains the following leaf definition: @@ -2485,49 +2498,48 @@ the argument of the 'base' substatement. For example, assume that module "des" in Section 10.21 contains the following leaf definition: leaf foo { type identityref { base crypto:crypto-alg; } } - This leaf would then be mapped to the following element pattern: -10.53.6. The "instance-identifier" Type +10.53.7. The "instance-identifier" Type This type is mapped to element with @type attribute set to "string". In addition, an empty element MUST be inserted as a child of PARENT. The argument of the 'require-instance' substatement, if it exists, becomes the value of the @require-instance attribute of the element. -10.53.7. The "leafref" Type +10.53.8. The "leafref" Type This type is mapped exactly as the type of the leaf given in the argument of 'path' substatement. However, if the type of the referred leaf defines a default value, this default value MUST be ignored by the mapping. In addition, @nma:leafref attribute MUST be added to PARENT. The argument of the 'path' substatement, translated according to Section 9.3, is set as the value of this attribute. -10.53.8. The Numeric Types +10.53.9. The Numeric Types YANG built-in numeric types are "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64" and "decimal64". They are mapped to element with @type attribute set to ARGUMENT translated according to Table 4 above. An exception is the "decimal64" type, which is mapped to the "decimal" type of the XSD datatype library. Its precision and number of fractional digits are controlled with the following facets, which MUST always be present: @@ -2597,27 +2608,27 @@ 42 42 100 See Section 9.2.2 for further details on mapping the restrictions. -10.53.9. The "string" Type +10.53.10. The "string" Type This type is mapped to element with the @type attribute set to "string". The 'length' restriction is handled analogically to the 'range' - restriction for the numeric types (Section 10.53.8): + restriction for the numeric types (Section 10.53.9): If the length expression has just a single range, then o if the length range consists of a single number LENGTH, the following datatype facet is inserted: LENGTH. o Otherwise the length range is of the form LO..HI, i.e., it consists of both the lower and upper bound. The following two @@ -2663,21 +2674,21 @@ 1 [A-Z][a-z]* 3 8 [A-Z][a-z]* -10.53.10. Derived Types +10.53.11. Derived Types If the 'type' statement refers to a derived type, it is mapped in one of the following ways depending on whether it contains any restrictions as its substatements: 1. Without restrictions, the 'type' statement is mapped simply to the element, i.e., a reference to a named pattern. If the RELAX NG definition of this named pattern has not been added to the hybrid schema yet, the corresponding type definition MUST be found and its mapping installed as a subelement of either the @@ -2702,21 +2713,21 @@ without restrictions in at least one of the input modules. In this case, the named pattern definition becomes a child of either the root or an embedded element, depending on whether the 'typedef' statement appears at the top level of a YANG module or not. The name of this named pattern definition is set to ARGUMENT mangled according to the rules specified in Section 9.2. Whenever a derived type is used with additional restrictions, the ancestor built-in type for the derived type is used instead with restrictions (facets) that are a combination of all restrictions - specified along the type derivation chain. See Section 10.53.10 for + specified along the type derivation chain. See Section 10.53.11 for further details and an example. An implementation MAY offer the option of recording all 'typedef' statements as named patterns in the output RELAX NG schema even if they are not referenced. This is useful for mapping YANG "library" modules containing only 'typedef' and/or 'grouping' statements. 10.55. The 'unique' Statement This statement is mapped to @nma:unique attribute. ARGUMENT MUST be