NETMOD Working Group K. Watsen
Internet-Draft Watsen Networks
Intended status: Standards Track 17 May 2024
Expires: 18 November 2024
XML Encoding of Data Modeled with YANG
draft-yn-netmod-yang-xml-00
Abstract
This document defines encoding rules for representing YANG modeled
configuration data, state data, parameters of Remote Procedure Call
(RPC) operations or actions, and notifications defined using XML.
GitHub Information (to be removed by RFC Editor)
This document is developed on GitHub (https://github.com/netmod-wg/
rfc7950bis). If you wish to contribute, please consider opening a
pull request (PR). Please see the README (https://github.com/netmod-
wg/rfc7950bis/blob/main/README.md) file for details.
Special Thanks
The following individuals were entrusted to review all of the design
proposals and specification updates made by authors. Sorted by first
name: Kent Watsen.
Status of This Memo
This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."
This Internet-Draft will expire on 18 November 2024.
Watsen Expires 18 November 2024 [Page 1]
Internet-Draft XML Encoding of YANG Data May 2024
Copyright Notice
Copyright (c) 2024 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents (https://trustee.ietf.org/
license-info) in effect on the date of publication of this document.
Please review these documents carefully, as they describe your rights
and restrictions with respect to this document. Code Components
extracted from this document must include Revised BSD License text as
described in Section 4.e of the Trust Legal Provisions and are
provided without warranty as described in the Revised BSD License.
This document may contain material from IETF Documents or IETF
Contributions published or made publicly available before November
10, 2008. The person(s) controlling the copyright in some of this
material may not have granted the IETF Trust the right to allow
modifications of such material outside the IETF Standards Process.
Without obtaining an adequate license from the person(s) controlling
the copyright in such materials, this document may not be modified
outside the IETF Standards Process, and derivative works of it may
not be created outside the IETF Standards Process, except to format
it for publication as an RFC or to translate it into languages other
than English.
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3
2. Terminology and Notation . . . . . . . . . . . . . . . . . . 3
3. Properties of the XML Encoding . . . . . . . . . . . . . . . 4
4. Names and Namespaces . . . . . . . . . . . . . . . . . . . . 4
5. Encoding of YANG Data Node Instances . . . . . . . . . . . . 6
5.1. The "leaf" Data Node . . . . . . . . . . . . . . . . . . 6
5.2. The "container" Data Node . . . . . . . . . . . . . . . . 6
5.3. The "leaf-list" Data Node . . . . . . . . . . . . . . . . 6
5.4. The "list" Data Node . . . . . . . . . . . . . . . . . . 7
5.5. The "anydata" Data Node . . . . . . . . . . . . . . . . . 7
5.6. The "anyxml" Data Node . . . . . . . . . . . . . . . . . 7
5.7. Metadata Objects . . . . . . . . . . . . . . . . . . . . 7
6. Representing YANG Data Types in JSON Values . . . . . . . . . 7
6.1. Numeric Types . . . . . . . . . . . . . . . . . . . . . . 7
6.2. The "string" Type . . . . . . . . . . . . . . . . . . . . 7
6.3. The "boolean" Type . . . . . . . . . . . . . . . . . . . 7
6.4. The "enumeration" Type . . . . . . . . . . . . . . . . . 7
6.5. The "bits" Type . . . . . . . . . . . . . . . . . . . . . 7
6.6. The "binary" Type . . . . . . . . . . . . . . . . . . . . 7
6.7. The "leafref" Type . . . . . . . . . . . . . . . . . . . 7
Watsen Expires 18 November 2024 [Page 2]
Internet-Draft XML Encoding of YANG Data May 2024
6.8. The "identityref" Type . . . . . . . . . . . . . . . . . 8
6.9. The "empty" Type . . . . . . . . . . . . . . . . . . . . 8
6.10. The "union" Type . . . . . . . . . . . . . . . . . . . . 8
6.11. The "instance-identifier" Type . . . . . . . . . . . . . 8
7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 8
8. Security Considerations . . . . . . . . . . . . . . . . . . . 8
9. References . . . . . . . . . . . . . . . . . . . . . . . . . 8
9.1. Normative References . . . . . . . . . . . . . . . . . . 8
9.2. Informative References . . . . . . . . . . . . . . . . . 9
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 9
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 9
1. Introduction
This document defines encoding rules for representing YANG [RFC7950]
modeled configuration data, state data, parameters of Remote
Procedure Call (RPC) operations or actions, and notifications defined
using the Extensible Markup Language (XML) [XML].
2. Terminology and Notation
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in
BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all
capitals, as shown here.
The following terms are defined in [RFC7950]:
* action
* anydata
* anyxml
* augment
* container
* data node
* data tree
* identity
* instance identifier
* leaf
* leaf-list
* list
* module
* RPC operation
* submodule
The following terms are defined in [RFC6241]:
* configuration data
Watsen Expires 18 November 2024 [Page 3]
Internet-Draft XML Encoding of YANG Data May 2024
* notification
* state data
3. Properties of the XML Encoding
This document defines XML encoding for YANG data trees and their
subtrees. It is always assumed that there may be one or more top-
level elements in XML-encoded configuration data and state data. RPC
operations and notifications contain a single top-level element.
Instances of YANG data nodes (leafs, containers, leaf-lists, lists,
anydata nodes, and anyxml nodes) are encoded as XML elements having
the name of the YANG data node. Section 4) defines how the name is
qualified with a namespace, and the following sections deal with the
value part. The encoding rules are identical for all types of data
trees, i.e., configuration data, state data, parameters of RPC
operations, actions, and notifications.
With the exception of "anydata" encoding (Section 5.5), all rules in
this document are also applicable to YANG 1.0 [RFC6020].
With the exception of anyxml and schema-less anydata nodes, it is
possible to map an XML-encoded data tree to other encodings, such as
the JSON encoding as defined in [RFC7951], and vice versa. However,
such conversions require the YANG data model to be available.
4. Names and Namespaces
An XML element name is always identical to the identifier of the
corresponding YANG data node.
All XML elements encoding YANG data are namespace qualified. The XML
default namespace is never used in YANG encoded data.
The namespace of an XML element is either inherited from its ancestor
or set using the "xmlns" attribute in the element.
The "xmlns" attribute may either set the XML default namespace or
define and use a prefix for the namespace. For instance, the
following two XML documents are the same.
Document 1:
Document 2:
Watsen Expires 18 November 2024 [Page 4]
Internet-Draft XML Encoding of YANG Data May 2024
The "namespace" statement of a module determines the namespace of all
data node names defined in that module. If a data node is defined in
a submodule, then the namespace of the main module is used.
A namespace MUST be set for all top-level XML elements and then also
whenever the namespaces of the data node and its parent node are
different.
For example, consider the following YANG module:
module example-foomod {
namespace "https://example.com/foomod";
prefix "foomod";
container top {
leaf foo {
type uint8;
}
}
}
If the data model consists only of this module, then the following is
valid XML-encoded configuration data:
54
Note that the top-level element sets the default namespace which
"foo" leaf inherits its parent container "top".
Now, assume that the container "top" is augmented from another
module, "example-barmod":
Watsen Expires 18 November 2024 [Page 5]
Internet-Draft XML Encoding of YANG Data May 2024
module example-barmod {
namespace "https://example.com/barmod";
prefix "barmod";
import example-foomod {
prefix "foomod";
}
augment "/foomod:top" {
leaf bar {
type boolean;
}
}
}
Valid XML-encoded configuration data containing both leafs may then
look like this:
54
true
The "bar" leaf's element sets a new default namespace because its
parent is defined in a different module.
Prefixed namespace identifiers are sometimes needed when encoding
values of the "identityref" and "instance-identifier" types. See
Section 6.8 and Section 6.11 for details.
5. Encoding of YANG Data Node Instances
5.1. The "leaf" Data Node
TBD
5.2. The "container" Data Node
TBD
5.3. The "leaf-list" Data Node
TBD
Watsen Expires 18 November 2024 [Page 6]
Internet-Draft XML Encoding of YANG Data May 2024
5.4. The "list" Data Node
TBD
5.5. The "anydata" Data Node
TBD
5.6. The "anyxml" Data Node
TBD
5.7. Metadata Objects
TBD
6. Representing YANG Data Types in JSON Values
6.1. Numeric Types
TBD
6.2. The "string" Type
TBD
6.3. The "boolean" Type
TBD
6.4. The "enumeration" Type
TBD
6.5. The "bits" Type
TBD
6.6. The "binary" Type
TBD
6.7. The "leafref" Type
TBD
Watsen Expires 18 November 2024 [Page 7]
Internet-Draft XML Encoding of YANG Data May 2024
6.8. The "identityref" Type
TBD
6.9. The "empty" Type
TBD
6.10. The "union" Type
TBD
6.11. The "instance-identifier" Type
TBD
7. IANA Considerations
This document registers one capability identifier URN from the
"Network Configuration Protocol (NETCONF) Capability URNs" registry:
8. Security Considerations
This document defines a language with which to write and read
descriptions of management information. The language itself has no
security impact on the Internet.
9. References
9.1. Normative References
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119,
DOI 10.17487/RFC2119, March 1997,
.
[RFC7950] Bjorklund, M., Ed., "The YANG 1.1 Data Modeling Language",
RFC 7950, DOI 10.17487/RFC7950, August 2016,
.
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
May 2017, .
[I-D.yn-netmod-rfc7950bis]
IETF, "The YANG 1.1 Data Modeling Language", 2024.
Watsen Expires 18 November 2024 [Page 8]
Internet-Draft XML Encoding of YANG Data May 2024
[XML] Bray, T., Paoli, J., Sperberg-McQueen, C., Maler, E., and
F. Yergeau, "Extensible Markup Language (XML) 1.0 (Fifth
Edition)", W3C Recommendation REC-xml-20081126, 26
November 2008,
.
9.2. Informative References
[RFC6020] Bjorklund, M., Ed., "YANG - A Data Modeling Language for
the Network Configuration Protocol (NETCONF)", RFC 6020,
DOI 10.17487/RFC6020, October 2010,
.
[RFC7951] Lhotka, L., "JSON Encoding of Data Modeled with YANG",
RFC 7951, DOI 10.17487/RFC7951, August 2016,
.
Acknowledgements
Substantial text in this document was copied from [RFC7951]. The
authors wish to thank Ladislav Lhotka for authoring RFC 7951.
Author's Address
Kent Watsen
Watsen Networks
Watsen Expires 18 November 2024 [Page 9]