<?xml version='1.0' encoding='utf-8'?>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" version="3" category="std" consensus="true" docName="draft-ietf-netmod-yang-data-ext-05" indexInclude="true" ipr="trust200902" number="8791" prepTime="2020-06-17T16:33:36" scripts="Common,Latin" sortRefs="true" submissionType="IETF" symRefs="true" tocDepth="3" tocInclude="true" updates="8340" xml:lang="en">
  <link href="https://datatracker.ietf.org/doc/draft-ietf-netmod-yang-data-ext-05" rel="prev"/>
  <link href="https://dx.doi.org/10.17487/rfc8791" rel="alternate"/>
  <link href="urn:issn:2070-1721" rel="alternate"/>
  <front>
    <title abbrev="YANG Data Structure Extensions">YANG Data Structure Extensions</title>
    <seriesInfo name="RFC" value="8791" stream="IETF"/>
    <author initials="A" surname="Bierman" fullname="Andy Bierman">
      <organization showOnFrontPage="true">YumaWorks</organization>
      <address>
        <email>andy@yumaworks.com</email>
      </address>
    </author>
    <author initials="M" surname="Bjorklund" fullname="Martin Bjorklund">
      <organization showOnFrontPage="true">Cisco</organization>
      <address>
        <email>mbj+ietf@4668.se</email>
      </address>
    </author>
    <author initials="K" surname="Watsen" fullname="Kent Watsen">
      <organization showOnFrontPage="true">Watsen Networks</organization>
      <address>
        <email>kent+ietf@watsen.net</email>
      </address>
    </author>
    <date month="06" year="2020"/>
    <abstract pn="section-abstract">
      <t pn="section-abstract-1">
This document describes YANG mechanisms for
defining abstract data structures with YANG.
      </t>
    </abstract>
    <boilerplate>
      <section anchor="status-of-memo" numbered="false" removeInRFC="false" toc="exclude" pn="section-boilerplate.1">
        <name slugifiedName="name-status-of-this-memo">Status of This Memo</name>
        <t pn="section-boilerplate.1-1">
            This is an Internet Standards Track document.
        </t>
        <t pn="section-boilerplate.1-2">
            This document is a product of the Internet Engineering Task Force
            (IETF).  It represents the consensus of the IETF community.  It has
            received public review and has been approved for publication by
            the Internet Engineering Steering Group (IESG).  Further
            information on Internet Standards is available in Section 2 of 
            RFC 7841.
        </t>
        <t pn="section-boilerplate.1-3">
            Information about the current status of this document, any
            errata, and how to provide feedback on it may be obtained at
            <eref target="https://www.rfc-editor.org/info/rfc8791" brackets="none"/>.
        </t>
      </section>
      <section anchor="copyright" numbered="false" removeInRFC="false" toc="exclude" pn="section-boilerplate.2">
        <name slugifiedName="name-copyright-notice">Copyright Notice</name>
        <t pn="section-boilerplate.2-1">
            Copyright (c) 2020 IETF Trust and the persons identified as the
            document authors. All rights reserved.
        </t>
        <t pn="section-boilerplate.2-2">
            This document is subject to BCP 78 and the IETF Trust's Legal
            Provisions Relating to IETF Documents
            (<eref target="https://trustee.ietf.org/license-info" brackets="none"/>) 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 Simplified BSD License text as described in
            Section 4.e of the Trust Legal Provisions and are provided without
            warranty as described in the Simplified BSD License.
        </t>
      </section>
    </boilerplate>
    <toc>
      <section anchor="toc" numbered="false" removeInRFC="false" toc="exclude" pn="section-toc.1">
        <name slugifiedName="name-table-of-contents">Table of Contents</name>
        <ul bare="true" empty="true" indent="2" spacing="compact" pn="section-toc.1-1">
          <li pn="section-toc.1-1.1">
            <t pn="section-toc.1-1.1.1"><xref derivedContent="1" format="counter" sectionFormat="of" target="section-1"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-introduction">Introduction</xref></t>
            <ul bare="true" empty="true" indent="2" spacing="compact" pn="section-toc.1-1.1.2">
              <li pn="section-toc.1-1.1.2.1">
                <t keepWithNext="true" pn="section-toc.1-1.1.2.1.1"><xref derivedContent="1.1" format="counter" sectionFormat="of" target="section-1.1"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-terminology">Terminology</xref></t>
                <ul bare="true" empty="true" indent="2" spacing="compact" pn="section-toc.1-1.1.2.1.2">
                  <li pn="section-toc.1-1.1.2.1.2.1">
                    <t keepWithNext="true" pn="section-toc.1-1.1.2.1.2.1.1"><xref derivedContent="1.1.1" format="counter" sectionFormat="of" target="section-1.1.1"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-nmda">NMDA</xref></t>
                  </li>
                  <li pn="section-toc.1-1.1.2.1.2.2">
                    <t keepWithNext="true" pn="section-toc.1-1.1.2.1.2.2.1"><xref derivedContent="1.1.2" format="counter" sectionFormat="of" target="section-1.1.2"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-yang">YANG</xref></t>
                  </li>
                </ul>
              </li>
            </ul>
          </li>
          <li pn="section-toc.1-1.2">
            <t pn="section-toc.1-1.2.1"><xref derivedContent="2" format="counter" sectionFormat="of" target="section-2"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-definitions">Definitions</xref></t>
          </li>
          <li pn="section-toc.1-1.3">
            <t pn="section-toc.1-1.3.1"><xref derivedContent="3" format="counter" sectionFormat="of" target="section-3"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-yang-data-structures-in-yan">YANG Data Structures in YANG Tree Diagrams</xref></t>
          </li>
          <li pn="section-toc.1-1.4">
            <t pn="section-toc.1-1.4.1"><xref derivedContent="4" format="counter" sectionFormat="of" target="section-4"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-yang-data-structure-extensi">YANG Data Structure Extensions Module</xref></t>
          </li>
          <li pn="section-toc.1-1.5">
            <t pn="section-toc.1-1.5.1"><xref derivedContent="5" format="counter" sectionFormat="of" target="section-5"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-iana-considerations">IANA Considerations</xref></t>
            <ul bare="true" empty="true" indent="2" spacing="compact" pn="section-toc.1-1.5.2">
              <li pn="section-toc.1-1.5.2.1">
                <t pn="section-toc.1-1.5.2.1.1"><xref derivedContent="5.1" format="counter" sectionFormat="of" target="section-5.1"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-yang-module-registry">YANG Module Registry</xref></t>
              </li>
            </ul>
          </li>
          <li pn="section-toc.1-1.6">
            <t pn="section-toc.1-1.6.1"><xref derivedContent="6" format="counter" sectionFormat="of" target="section-6"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-security-considerations">Security Considerations</xref></t>
          </li>
          <li pn="section-toc.1-1.7">
            <t pn="section-toc.1-1.7.1"><xref derivedContent="7" format="counter" sectionFormat="of" target="section-7"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-references">References</xref></t>
            <ul bare="true" empty="true" indent="2" spacing="compact" pn="section-toc.1-1.7.2">
              <li pn="section-toc.1-1.7.2.1">
                <t pn="section-toc.1-1.7.2.1.1"><xref derivedContent="7.1" format="counter" sectionFormat="of" target="section-7.1"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-normative-references">Normative References</xref></t>
              </li>
              <li pn="section-toc.1-1.7.2.2">
                <t pn="section-toc.1-1.7.2.2.1"><xref derivedContent="7.2" format="counter" sectionFormat="of" target="section-7.2"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-informative-references">Informative References</xref></t>
              </li>
            </ul>
          </li>
          <li pn="section-toc.1-1.8">
            <t pn="section-toc.1-1.8.1"><xref derivedContent="Appendix A" format="default" sectionFormat="of" target="section-appendix.a"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-examples">Examples</xref></t>
            <ul bare="true" empty="true" indent="2" spacing="compact" pn="section-toc.1-1.8.2">
              <li pn="section-toc.1-1.8.2.1">
                <t pn="section-toc.1-1.8.2.1.1"><xref derivedContent="A.1" format="counter" sectionFormat="of" target="section-a.1"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-structure-example">"structure" Example</xref></t>
              </li>
              <li pn="section-toc.1-1.8.2.2">
                <t pn="section-toc.1-1.8.2.2.1"><xref derivedContent="A.2" format="counter" sectionFormat="of" target="section-a.2"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-augmentstructure-example">"augment‑structure" Example</xref></t>
              </li>
              <li pn="section-toc.1-1.8.2.3">
                <t pn="section-toc.1-1.8.2.3.1"><xref derivedContent="A.3" format="counter" sectionFormat="of" target="section-a.3"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-xml-encoding-example">XML Encoding Example</xref></t>
              </li>
              <li pn="section-toc.1-1.8.2.4">
                <t pn="section-toc.1-1.8.2.4.1"><xref derivedContent="A.4" format="counter" sectionFormat="of" target="section-a.4"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-json-encoding-example">JSON Encoding Example</xref></t>
              </li>
              <li pn="section-toc.1-1.8.2.5">
                <t pn="section-toc.1-1.8.2.5.1"><xref derivedContent="A.5" format="counter" sectionFormat="of" target="section-a.5"/>.  <xref derivedContent="" format="title" sectionFormat="of" target="name-structure-example-that-defi">"structure" Example That Defines a Non-top-level Structure</xref></t>
              </li>
            </ul>
          </li>
          <li pn="section-toc.1-1.9">
            <t pn="section-toc.1-1.9.1"><xref derivedContent="" format="none" sectionFormat="of" target="section-appendix.b"/><xref derivedContent="" format="title" sectionFormat="of" target="name-authors-addresses">Authors' Addresses</xref></t>
          </li>
        </ul>
      </section>
    </toc>
  </front>
  <middle>
    <section anchor="introduction" numbered="true" toc="include" removeInRFC="false" pn="section-1">
      <name slugifiedName="name-introduction">Introduction</name>
      <t pn="section-1-1">
There is a need for standard mechanisms to allow the
definition of abstract data that is not intended to
be implemented as configuration or operational state.
The "yang-data" extension statement from RFC 8040 <xref target="RFC8040" format="default" sectionFormat="of" derivedContent="RFC8040"/> was defined for this purpose, but it is limited in its
functionality.
      </t>
      <t pn="section-1-2">
The intended use of the "yang-data" extension was to model all or part
of a protocol message, such as the "errors" definition in the 
YANG module "ietf-restconf" <xref target="RFC8040" format="default" sectionFormat="of" derivedContent="RFC8040"/>, or the
contents of a file.  However, 
protocols are often layered such that the header or payload portions
of the message can be extended by external documents.  The YANG
statements that model a protocol need to support this extensibility
that is already found in that protocol.
      </t>
      <t pn="section-1-3">
This document defines a new YANG extension statement called
"structure", which is similar to but more flexible than the
"yang-data" extension from <xref target="RFC8040" format="default" sectionFormat="of" derivedContent="RFC8040"/>.

There is no assumption that a 
YANG data structure can only be used as a top-level abstraction, and
it may also be nested within some other data structure.
      </t>
      <t pn="section-1-4">
This document also defines a new YANG extension statement called
"augment‑structure", which allows abstract data structures to be
augmented from external modules and is similar to the existing YANG "augment"
statement.  Note that "augment" cannot be used to augment a YANG data
structure since a YANG compiler or other tool is not required to understand
the "structure" extension.
      </t>
      <section anchor="terminology" numbered="true" toc="include" removeInRFC="false" pn="section-1.1">
        <name slugifiedName="name-terminology">Terminology</name>
        <t pn="section-1.1-1">
The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>",
"<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL NOT</bcp14>", 
"<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>",
"<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>",
"<bcp14>MAY</bcp14>", and
"<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as described in
BCP 14 <xref target="RFC2119" format="default" sectionFormat="of" derivedContent="RFC2119"/> <xref target="RFC8174" format="default" sectionFormat="of" derivedContent="RFC8174"/> when, and only when, they appear in all 
capitals, as shown here.
        </t>
        <t pn="section-1.1-2">
The following term is used within this document:
        </t>
        <dl newline="false" spacing="normal" pn="section-1.1-3">
          <dt pn="section-1.1-3.1">YANG data structure:</dt>
          <dd pn="section-1.1-3.2">A data structure defined with the "structure"
statement.</dd>
        </dl>
        <section anchor="nmda" numbered="true" toc="include" removeInRFC="false" pn="section-1.1.1">
          <name slugifiedName="name-nmda">NMDA</name>
          <t pn="section-1.1.1-1">
The following terms are defined in the
Network Management Datastore Architecture
(NMDA) <xref target="RFC8342" format="default" sectionFormat="of" derivedContent="RFC8342"/>
and are not redefined here:</t>
          <ul spacing="normal" bare="false" empty="false" pn="section-1.1.1-2">
            <li pn="section-1.1.1-2.1">configuration</li>
            <li pn="section-1.1.1-2.2">operational state</li>
          </ul>
        </section>
        <section anchor="yang" numbered="true" toc="include" removeInRFC="false" pn="section-1.1.2">
          <name slugifiedName="name-yang">YANG</name>
          <t pn="section-1.1.2-1">The following terms are defined in <xref target="RFC7950" format="default" sectionFormat="of" derivedContent="RFC7950"/> and are not redefined here:</t>
          <ul spacing="normal" bare="false" empty="false" pn="section-1.1.2-2">
            <li pn="section-1.1.2-2.1">absolute-schema-nodeid</li>
            <li pn="section-1.1.2-2.2">container</li>
            <li pn="section-1.1.2-2.3">data definition statement</li>
            <li pn="section-1.1.2-2.4">data node</li>
            <li pn="section-1.1.2-2.5">leaf</li>
            <li pn="section-1.1.2-2.6">leaf-list</li>
            <li pn="section-1.1.2-2.7">list</li>
          </ul>
        </section>
      </section>
    </section>
    <section anchor="definitions" numbered="true" toc="include" removeInRFC="false" pn="section-2">
      <name slugifiedName="name-definitions">Definitions</name>
      <t pn="section-2-1">
A YANG data structure is defined with the "structure" extension
statement, which is defined in the YANG module
"ietf-yang-structure-ext".  The
argument to the "structure" extension statement is the name of the
data structure.  The data structures are considered to be in the same
identifier namespace as defined in <xref target="RFC7950" sectionFormat="of" section="6.2.1" format="default" derivedLink="https://rfc-editor.org/rfc/rfc7950#section-6.2.1" derivedContent="RFC7950"/>. In particular, the seventh bullet states:
      </t>
      <blockquote pn="section-2-2">
   All leafs, leaf-lists, lists, containers, choices, rpcs, actions,
   notifications, anydatas, and anyxmls defined (directly or through
   a "uses" statement) within a parent node or at the top level of
   the module or its submodules share the same identifier namespace.
</blockquote>
      <t pn="section-2-3">
This means that data structures defined with the "structure" statement
cannot have the same name as sibling nodes from regular YANG data
definition statements or other "structure" statements in the same YANG
module.
      </t>
      <t pn="section-2-4">
This does not mean a YANG data structure, once defined, has to be used
as a top-level protocol message or other top-level data structure.
      </t>
      <t pn="section-2-5">
A YANG data structure is encoded in the same way as an "anydata" node.
This means that the name of the structure is encoded as a "container",
with the instantiated children encoded as child nodes to this
node.  For example, this structure:
      </t>
      <sourcecode type="yang" markers="false" pn="section-2-6">
  module example-errors {
    ...

    sx:structure my-error {
      leaf error-number {
        type int;
      }
    }
  }

</sourcecode>
      <t pn="section-2-7">
can be encoded in JSON as:
      </t>
      <sourcecode type="json" markers="false" pn="section-2-8">
  "example-errors:my-error": {
    "error-number": 131
  }

</sourcecode>
    </section>
    <section anchor="yang-data-structures-in-yang-tree-diagrams" numbered="true" toc="include" removeInRFC="false" pn="section-3">
      <name slugifiedName="name-yang-data-structures-in-yan">YANG Data Structures in YANG Tree Diagrams</name>
      <t pn="section-3-1">
A YANG data structure can be printed in a YANG tree diagram <xref target="RFC8340" format="default" sectionFormat="of" derivedContent="RFC8340"/>. 
This document updates RFC 8340 <xref target="RFC8340" format="default" sectionFormat="of" derivedContent="RFC8340"/> by defining
two new sections in the 
tree diagram for a module:
      </t>
      <ol spacing="normal" start="1" type="1" pn="section-3-2">
        <li pn="section-3-2.1" derivedCounter="1.">YANG data structures, which are offset by two spaces and identified by the keyword
"structure" followed by the name of the YANG data structure and a colon (":")
character. </li>
        <li pn="section-3-2.2" derivedCounter="2.">YANG data structure augmentations, which are offset by 2 spaces and identified by
the keyword "augment‑structure" followed by the augment target structure
name and a colon (":") character.</li>
      </ol>
      <t pn="section-3-3">
   The new sections, including spaces conventions, appear as follows:
      </t>
      <sourcecode type="yangtree" markers="false" pn="section-3-4">
  structure &lt;structure-name&gt;:
    +--&lt;node&gt;
       +--&lt;node&gt;
       |  +--&lt;node&gt;
       +--&lt;node&gt;
  structure &lt;structure-name&gt;:
    +--&lt;node&gt;

  augment-structure &lt;structure-name&gt;:
    +--&lt;node&gt;
       +--&lt;node&gt;
       |  +--&lt;node&gt;
       +--&lt;node&gt;
  augment-structure &lt;structure-name&gt;:
    +--&lt;node&gt;

</sourcecode>
      <t pn="section-3-5">
Nodes in YANG data structures are printed according to the rules defined in
<xref target="RFC8340" sectionFormat="of" section="2.6" format="default" derivedLink="https://rfc-editor.org/rfc/rfc8340#section-2.6" derivedContent="RFC8340"/>. The nodes in YANG
data structures do not have any &lt;flags&gt;.
      </t>
    </section>
    <section anchor="mod" numbered="true" toc="include" removeInRFC="false" pn="section-4">
      <name slugifiedName="name-yang-data-structure-extensi">YANG Data Structure Extensions Module</name>
      <sourcecode type="yang" name="ietf-yang-structure-ext@2020-06-17.yang" markers="true" pn="section-4-1">
module ietf-yang-structure-ext {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-yang-structure-ext";
  prefix sx;

  organization
    "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
  contact
    "WG Web:   &lt;https://datatracker.ietf.org/wg/netmod/&gt;
     WG List:  &lt;mailto:netmod@ietf.org&gt;

     Author:   Andy Bierman
               &lt;mailto:andy@yumaworks.com&gt;

     Author:   Martin Bjorklund
               &lt;mailto:mbj+ietf@4668.se&gt;

     Author:   Kent Watsen
               &lt;mailto:kent+ietf@watsen.net&gt;";
  description
    "This module contains conceptual YANG specifications for defining
     abstract data structures.

     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 (RFC 2119) (RFC 8174) when, and only when,
     they appear in all capitals, as shown here.

     Copyright (c) 2020 IETF Trust and the persons identified as
     authors of the code.  All rights reserved.

     Redistribution and use in source and binary forms, with or
     without modification, is permitted pursuant to, and subject to
     the license terms contained in, the Simplified BSD License set
     forth in Section 4.c of the IETF Trust's Legal Provisions
     Relating to IETF Documents
     (http://trustee.ietf.org/license-info).

     This version of this YANG module is part of RFC 8791
     (https://www.rfc-editor.org/info/rfc8791); see the RFC itself
     for full legal notices.";

  revision 2020-06-17 {
    description
      "Initial revision.";
    reference
      "RFC 8791: YANG Data Structure Extensions.";
  }

  extension structure {
    argument name {
      yin-element true;
    }
    description
      "This extension is used to specify a YANG data structure that
       represents conceptual data defined in YANG.  It is intended to
       describe hierarchical data independent of protocol context or
       specific message encoding format.  Data definition statements
       within a 'structure' extension statement specify the generic
       syntax for the specific YANG data structure, whose name is the
       argument of the 'structure' extension statement.

       Note that this extension does not define a media type.  A
       specification using this extension MUST specify the message
       encoding rules, including the content media type, if
       applicable.

       The mandatory 'name' parameter value identifies the YANG data
       structure that is being defined.

       This extension is only valid as a top-level statement, i.e.,
       given as a substatement to 'module' or 'submodule'.

       The substatements of this extension MUST follow the ABNF
       rules below, where the rules are defined in RFC 7950:

         *must-stmt
         [status-stmt]
         [description-stmt]
         [reference-stmt]
         *(typedef-stmt / grouping-stmt)
         *data-def-stmt

       A YANG data structure defined with this extension statement is
       encoded in the same way as an 'anydata' node.  This means
       that the name of the structure is encoded as a 'container',
       with the instantiated child statements encoded as child nodes
       to this node.

       The module name and namespace value for the YANG module using
       the extension statement are assigned to each of the data
       definition statements resulting from the YANG data structure.

       The XPath document element is the extension statement itself,
       such that the child nodes of the document element are
       represented by the data-def-stmt substatements within this
       extension.  This conceptual document is the context for the
       following YANG statements:

         - must-stmt
         - when-stmt
         - path-stmt
         - min-elements-stmt
         - max-elements-stmt
         - mandatory-stmt
         - unique-stmt
         - ordered-by
         - instance-identifier data type

       The following data-def-stmt substatements are constrained
       when used within a 'structure' extension statement.

         - The list-stmt is not required to have a key-stmt defined.
         - The config-stmt is ignored if present.
      ";
  }

  extension augment-structure {
    argument path {
      yin-element true;
    }
    description
      "This extension is used to specify an augmentation to a YANG
       data structure defined with the 'structure' statement.  It is
       intended to describe hierarchical data independent of protocol
       context or specific message encoding format.

       This statement has almost the same structure as the
       'augment-stmt'.  Data definition statements within this
       statement specify the semantics and generic syntax for the
       additional data to be added to the specific YANG data
       structure, identified by the 'path' argument.

       The mandatory 'path' parameter value identifies the YANG
       conceptual data node that is being augmented and is
       represented as an absolute-schema-nodeid string, where the
       first node in the absolute-schema-nodeid string identifies the
       YANG data structure to augment, and the rest of the nodes in
       the string identifies the node within the YANG structure to
       augment.

       This extension is only valid as a top-level statement, i.e.,
       given as a substatement to 'module' or 'submodule'.

       The substatements of this extension MUST follow the ABNF
       rules below, where the rules are defined in RFC 7950:

         [status-stmt]
         [description-stmt]
         [reference-stmt]
         1*(data-def-stmt / case-stmt)

       The module name and namespace value for the YANG module using
       the extension statement are assigned to instance document data
       conforming to the data definition statements within this
       extension.

       The XPath document element is the augmented extension
       statement itself, such that the child nodes of the document
       element are represented by the data-def-stmt substatements
       within the augmented 'structure' statement.

       The context node of the 'augment-structure' statement is
       derived in the same way as the 'augment' statement, as defined
       in Section 6.4.1 of [RFC7950]. This conceptual node is
       considered the context node for the following YANG statements:

         - must-stmt
         - when-stmt
         - path-stmt
         - min-elements-stmt
         - max-elements-stmt
         - mandatory-stmt
         - unique-stmt
         - ordered-by
         - instance-identifier data type

       The following data-def-stmt substatements are constrained
       when used within an 'augment-structure' extension statement.

         - The list-stmt is not required to have a key-stmt defined.
         - The config-stmt is ignored if present.

       Example:

          module foo {
             import ietf-yang-structure-ext { prefix sx; }

             sx:structure foo-data {
               container foo-con { }
             }
          }

          module bar {
             import ietf-yang-structure-ext { prefix sx; }
             import foo { prefix foo; }

             sx:augment-structure /foo:foo-data/foo:foo-con {
               leaf add-leaf1 { type int32; }
               leaf add-leaf2 { type string; }
             }
          }
      ";
  }
}

</sourcecode>
    </section>
    <section anchor="iana" numbered="true" toc="include" removeInRFC="false" pn="section-5">
      <name slugifiedName="name-iana-considerations">IANA Considerations</name>
      <section anchor="yang-module-registry" numbered="true" toc="include" removeInRFC="false" pn="section-5.1">
        <name slugifiedName="name-yang-module-registry">YANG Module Registry</name>
        <t pn="section-5.1-1">
IANA has registered the following URI in the "ns" subregistry within the "IETF
XML Registry" <xref target="RFC3688" format="default" sectionFormat="of" derivedContent="RFC3688"/>:
        </t>
        <dl newline="false" spacing="compact" indent="6" pn="section-5.1-2">
          <dt pn="section-5.1-2.1">URI:</dt>
          <dd pn="section-5.1-2.2">urn:ietf:params:xml:ns:yang:ietf-yang-structure-ext</dd>
          <dt pn="section-5.1-2.3">Registrant Contact: </dt>
          <dd pn="section-5.1-2.4">The IESG.</dd>
          <dt pn="section-5.1-2.5">XML: </dt>
          <dd pn="section-5.1-2.6">N/A; the requested URI is an XML namespace.</dd>
        </dl>
        <t pn="section-5.1-3">
IANA has registered the following YANG module in the "YANG Module Names" subregistry
<xref target="RFC6020" format="default" sectionFormat="of" derivedContent="RFC6020"/> within the "YANG Parameters" registry:
        </t>
        <dl newline="false" spacing="compact" indent="6" pn="section-5.1-4">
          <dt pn="section-5.1-4.1">Name:</dt>
          <dd pn="section-5.1-4.2">ietf-yang-structure-ext</dd>
          <dt pn="section-5.1-4.3">Namespace:</dt>
          <dd pn="section-5.1-4.4">urn:ietf:params:xml:ns:yang:ietf-yang-structure-ext</dd>
          <dt pn="section-5.1-4.5">Prefix:</dt>
          <dd pn="section-5.1-4.6">sx</dd>
          <dt pn="section-5.1-4.7">Reference:</dt>
          <dd pn="section-5.1-4.8">RFC 8791</dd>
        </dl>
      </section>
    </section>
    <section anchor="security-considerations" numbered="true" toc="include" removeInRFC="false" pn="section-6">
      <name slugifiedName="name-security-considerations">Security Considerations</name>
      <t pn="section-6-1"> This document defines YANG extensions that are used to define conceptual
YANG data structures. It does not introduce any new vulnerabilities beyond
those specified in YANG 1.1 <xref target="RFC7950" format="default" sectionFormat="of" derivedContent="RFC7950"/>.</t>
    </section>
  </middle>
  <back>
    <references pn="section-7">
      <name slugifiedName="name-references">References</name>
      <references pn="section-7.1">
        <name slugifiedName="name-normative-references">Normative References</name>
        <reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119" quoteTitle="true" derivedAnchor="RFC2119">
          <front>
            <title>Key words for use in RFCs to Indicate Requirement Levels</title>
            <author initials="S." surname="Bradner" fullname="S. Bradner">
              <organization showOnFrontPage="true"/>
            </author>
            <date year="1997" month="March"/>
            <abstract>
              <t>In many standards track documents several words are used to signify the requirements in the specification.  These words are often capitalized. This document defines these words as they should be interpreted in IETF documents.  This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t>
            </abstract>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="2119"/>
          <seriesInfo name="DOI" value="10.17487/RFC2119"/>
        </reference>
        <reference anchor="RFC7950" target="https://www.rfc-editor.org/info/rfc7950" quoteTitle="true" derivedAnchor="RFC7950">
          <front>
            <title>The YANG 1.1 Data Modeling Language</title>
            <author initials="M." surname="Bjorklund" fullname="M. Bjorklund" role="editor">
              <organization showOnFrontPage="true"/>
            </author>
            <date year="2016" month="August"/>
            <abstract>
              <t>YANG is a data modeling language used to model configuration data, state data, Remote Procedure Calls, and notifications for network management protocols.  This document describes the syntax and semantics of version 1.1 of the YANG language.  YANG version 1.1 is a maintenance release of the YANG language, addressing ambiguities and defects in the original specification.  There are a small number of backward incompatibilities from YANG version 1.  This document also specifies the YANG mappings to the Network Configuration Protocol (NETCONF).</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="7950"/>
          <seriesInfo name="DOI" value="10.17487/RFC7950"/>
        </reference>
        <reference anchor="RFC8040" target="https://www.rfc-editor.org/info/rfc8040" quoteTitle="true" derivedAnchor="RFC8040">
          <front>
            <title>RESTCONF Protocol</title>
            <author initials="A." surname="Bierman" fullname="A. Bierman">
              <organization showOnFrontPage="true"/>
            </author>
            <author initials="M." surname="Bjorklund" fullname="M. Bjorklund">
              <organization showOnFrontPage="true"/>
            </author>
            <author initials="K." surname="Watsen" fullname="K. Watsen">
              <organization showOnFrontPage="true"/>
            </author>
            <date year="2017" month="January"/>
            <abstract>
              <t>This document describes an HTTP-based protocol that provides a programmatic interface for accessing data defined in YANG, using the datastore concepts defined in the Network Configuration Protocol (NETCONF).</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="8040"/>
          <seriesInfo name="DOI" value="10.17487/RFC8040"/>
        </reference>
        <reference anchor="RFC8174" target="https://www.rfc-editor.org/info/rfc8174" quoteTitle="true" derivedAnchor="RFC8174">
          <front>
            <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
            <author initials="B." surname="Leiba" fullname="B. Leiba">
              <organization showOnFrontPage="true"/>
            </author>
            <date year="2017" month="May"/>
            <abstract>
              <t>RFC 2119 specifies common key words that may be used in protocol  specifications.  This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the  defined special meanings.</t>
            </abstract>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="8174"/>
          <seriesInfo name="DOI" value="10.17487/RFC8174"/>
        </reference>
        <reference anchor="RFC8340" target="https://www.rfc-editor.org/info/rfc8340" quoteTitle="true" derivedAnchor="RFC8340">
          <front>
            <title>YANG Tree Diagrams</title>
            <author initials="M." surname="Bjorklund" fullname="M. Bjorklund">
              <organization showOnFrontPage="true"/>
            </author>
            <author initials="L." surname="Berger" fullname="L. Berger" role="editor">
              <organization showOnFrontPage="true"/>
            </author>
            <date year="2018" month="March"/>
            <abstract>
              <t>This document captures the current syntax used in YANG module tree diagrams.  The purpose of this document is to provide a single location for this definition.  This syntax may be updated from time to time based on the evolution of the YANG language.</t>
            </abstract>
          </front>
          <seriesInfo name="BCP" value="215"/>
          <seriesInfo name="RFC" value="8340"/>
          <seriesInfo name="DOI" value="10.17487/RFC8340"/>
        </reference>
        <reference anchor="RFC8342" target="https://www.rfc-editor.org/info/rfc8342" quoteTitle="true" derivedAnchor="RFC8342">
          <front>
            <title>Network Management Datastore Architecture (NMDA)</title>
            <author initials="M." surname="Bjorklund" fullname="M. Bjorklund">
              <organization showOnFrontPage="true"/>
            </author>
            <author initials="J." surname="Schoenwaelder" fullname="J. Schoenwaelder">
              <organization showOnFrontPage="true"/>
            </author>
            <author initials="P." surname="Shafer" fullname="P. Shafer">
              <organization showOnFrontPage="true"/>
            </author>
            <author initials="K." surname="Watsen" fullname="K. Watsen">
              <organization showOnFrontPage="true"/>
            </author>
            <author initials="R." surname="Wilton" fullname="R. Wilton">
              <organization showOnFrontPage="true"/>
            </author>
            <date year="2018" month="March"/>
            <abstract>
              <t>Datastores are a fundamental concept binding the data models written in the YANG data modeling language to network management protocols such as the Network Configuration Protocol (NETCONF) and RESTCONF. This document defines an architectural framework for datastores based on the experience gained with the initial simpler model, addressing requirements that were not well supported in the initial model.  This document updates RFC 7950.</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="8342"/>
          <seriesInfo name="DOI" value="10.17487/RFC8342"/>
        </reference>
        <reference anchor="W3C.REC-xml-20081126" target="http://www.w3.org/TR/2008/REC-xml-20081126" quoteTitle="true" derivedAnchor="W3C.REC-xml-20081126">
          <front>
            <title>Extensible Markup Language (XML) 1.0 (Fifth Edition)</title>
            <author initials="T." surname="Bray" fullname="Tim Bray">
              <organization showOnFrontPage="true"/>
            </author>
            <author initials="J." surname="Paoli" fullname="Jean Paoli">
              <organization showOnFrontPage="true"/>
            </author>
            <author initials="M." surname="Sperberg-McQueen" fullname="Michael Sperberg-McQueen">
              <organization showOnFrontPage="true"/>
            </author>
            <author initials="E." surname="Maler" fullname="Eve Maler">
              <organization showOnFrontPage="true"/>
            </author>
            <author initials="F." surname="Yergeau" fullname="François Yergeau">
              <organization showOnFrontPage="true"/>
            </author>
            <date month="November" year="2008"/>
          </front>
          <seriesInfo name="World Wide Web Consortium Recommendation" value="REC-xml-20081126"/>
          <format type="HTML" target="http://www.w3.org/TR/2008/REC-xml-20081126"/>
        </reference>
      </references>
      <references pn="section-7.2">
        <name slugifiedName="name-informative-references">Informative References</name>
        <reference anchor="RFC3688" target="https://www.rfc-editor.org/info/rfc3688" quoteTitle="true" derivedAnchor="RFC3688">
          <front>
            <title>The IETF XML Registry</title>
            <author initials="M." surname="Mealling" fullname="M. Mealling">
              <organization showOnFrontPage="true"/>
            </author>
            <date year="2004" month="January"/>
            <abstract>
              <t>This document describes an IANA maintained registry for IETF standards which use Extensible Markup Language (XML) related items such as Namespaces, Document Type Declarations (DTDs), Schemas, and Resource Description Framework (RDF) Schemas.</t>
            </abstract>
          </front>
          <seriesInfo name="BCP" value="81"/>
          <seriesInfo name="RFC" value="3688"/>
          <seriesInfo name="DOI" value="10.17487/RFC3688"/>
        </reference>
        <reference anchor="RFC6020" target="https://www.rfc-editor.org/info/rfc6020" quoteTitle="true" derivedAnchor="RFC6020">
          <front>
            <title>YANG - A Data Modeling Language for the Network Configuration Protocol (NETCONF)</title>
            <author initials="M." surname="Bjorklund" fullname="M. Bjorklund" role="editor">
              <organization showOnFrontPage="true"/>
            </author>
            <date year="2010" month="October"/>
            <abstract>
              <t>YANG is a data modeling language used to model configuration and state data manipulated by the Network Configuration Protocol (NETCONF), NETCONF remote procedure calls, and NETCONF notifications. [STANDARDS-TRACK]</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="6020"/>
          <seriesInfo name="DOI" value="10.17487/RFC6020"/>
        </reference>
      </references>
    </references>
    <section anchor="examples" numbered="true" toc="include" removeInRFC="false" pn="section-appendix.a">
      <name slugifiedName="name-examples">Examples</name>
      <section anchor="structure-example" numbered="true" toc="include" removeInRFC="false" pn="section-a.1">
        <name slugifiedName="name-structure-example">"structure" Example</name>
        <t pn="section-a.1-1">
This example shows a simple address book that could be stored as an
artifact:
        </t>
        <sourcecode type="yang" markers="false" pn="section-a.1-2">
module example-module {
  yang-version 1.1;
  namespace "urn:example:example-module";
  prefix exm;

  import ietf-yang-structure-ext {
    prefix sx;
  }

  sx:structure address-book {
    list address {
      key "last first";
      leaf last {
        type string;
        description "Last name";
      }
      leaf first {
        type string;
        description "First name";
      }
      leaf street {
        type string;
        description "Street name";
      }
      leaf city {
        type string;
        description "City name";
      }
      leaf state {
        type string;
        description "State name";
      }
    }
  }
}

</sourcecode>
        <t pn="section-a.1-3">
Below is the tree diagram of this module:
        </t>
        <sourcecode type="yangtree" markers="false" pn="section-a.1-4">
module: example-module

  structure address-book:
    +-- address* [last first]
       +-- last      string
       +-- first     string
       +-- street?   string
       +-- city?     string
       +-- state?    string

</sourcecode>
      </section>
      <section anchor="augment-structure-example" numbered="true" toc="include" removeInRFC="false" pn="section-a.2">
        <name slugifiedName="name-augmentstructure-example">"augment‑structure" Example</name>
        <t pn="section-a.2-1">
This example adds "county" and "zipcode" leafs to the address book:
        </t>
        <sourcecode type="yang" markers="false" pn="section-a.2-2">
module example-module-aug {
  yang-version 1.1;
  namespace "urn:example:example-module-aug";
  prefix exma;

  import ietf-yang-structure-ext {
    prefix sx;
  }
  import example-module {
    prefix exm;
  }

  sx:augment-structure "/exm:address-book/exm:address" {
    leaf county {
      type string;
      description "County name";
    }
    leaf zipcode {
      type string;
      description "Postal zipcode";
    }
  }
}

</sourcecode>
        <t pn="section-a.2-3">
Below is the tree diagram of this module:
        </t>
        <sourcecode type="yangtree" markers="false" pn="section-a.2-4">
module: example-module-aug

  augment-structure /exm:address-book/exm:address:
    +-- county?    string
    +-- zipcode?   string

</sourcecode>
      </section>
      <section anchor="xml-encoding-example" numbered="true" toc="include" removeInRFC="false" pn="section-a.3">
        <name slugifiedName="name-xml-encoding-example">XML Encoding Example</name>
        <t pn="section-a.3-1">
This example shows how an address book can be encoded in XML <xref target="W3C.REC-xml-20081126" format="default" sectionFormat="of" derivedContent="W3C.REC-xml-20081126"/>:
        </t>
        <sourcecode type="xml" markers="false" pn="section-a.3-2">
&lt;address-book xmlns="urn:example:example-module"&gt;
  &lt;address&gt;
    &lt;last&gt;Flintstone&lt;/last&gt;
    &lt;first&gt;Fred&lt;/first&gt;
    &lt;street&gt;301 Cobblestone Way&lt;/street&gt;
    &lt;city&gt;Bedrock&lt;/city&gt;
    &lt;zipcode xmlns="urn:example:example-module-aug"&gt;70777&lt;/zipcode&gt;
  &lt;/address&gt;
  &lt;address&gt;
    &lt;last&gt;Root&lt;/last&gt;
    &lt;first&gt;Charlie&lt;/first&gt;
    &lt;street&gt;4711 Cobblestone Way&lt;/street&gt;
    &lt;city&gt;Bedrock&lt;/city&gt;
    &lt;zipcode xmlns="urn:example:example-module-aug"&gt;70777&lt;/zipcode&gt;
  &lt;/address&gt;
&lt;/address-book&gt;

</sourcecode>
      </section>
      <section anchor="json-encoding-example" numbered="true" toc="include" removeInRFC="false" pn="section-a.4">
        <name slugifiedName="name-json-encoding-example">JSON Encoding Example</name>
        <t pn="section-a.4-1">
This example shows how an address book can be encoded in JSON:
        </t>
        <sourcecode type="json" markers="false" pn="section-a.4-2">
"example-module:address-book": {
  "address": [
    {
      "city": "Bedrock",
      "example-module-aug:zipcode": "70777",
      "first": "Fred",
      "last": "Flintstone",
      "street": "301 Cobblestone Way"
    },
    {
      "city": "Bedrock",
      "example-module-aug:zipcode": "70777",
      "first": "Charlie",
      "last": "Root",
      "street": "4711 Cobblestone Way"
    }
  ]
}

</sourcecode>
      </section>
      <section anchor="structure-example-that-defines-a-non-top-level-structure" numbered="true" toc="include" removeInRFC="false" pn="section-a.5">
        <name slugifiedName="name-structure-example-that-defi">"structure" Example That Defines a Non-top-level Structure</name>
        <t pn="section-a.5-1">
The following example defines a data structure with error information
that can be included in an &lt;error‑info&gt; element in an
&lt;rpc‑error&gt;:
        </t>
        <sourcecode type="yang" markers="false" pn="section-a.5-2">
module example-error-info {
  yang-version 1.1;
  namespace "urn:example:example-error-info";
  prefix exei;

  import ietf-yang-structure-ext {
    prefix sx;
  }

  sx:structure my-example-error-info {
    leaf error-code {
      type uint32;
    }
  }

}

</sourcecode>
        <t pn="section-a.5-3">
The example below shows how this structure can be used in an
&lt;rpc‑error&gt;:
        </t>
        <sourcecode type="xml" markers="false" pn="section-a.5-4">
&lt;rpc-reply message-id="101"
     xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"&gt;
  &lt;rpc-error&gt;
    &lt;error-type&gt;protocol&lt;/error-type&gt;
    &lt;error-tag&gt;operation-failed&lt;/error-tag&gt;
    &lt;error-severity&gt;error&lt;/error-severity&gt;
    &lt;error-info&gt;
      &lt;my-example-error-info
          xmlns="urn:example:example-error-info"&gt;
        &lt;error-code&gt;42&lt;/error-code&gt;
      &lt;/my-example-error-info&gt;
    &lt;/error-info&gt;
  &lt;/rpc-error&gt;
&lt;/rpc-reply&gt;

</sourcecode>
      </section>
    </section>
    <section anchor="authors-addresses" numbered="false" removeInRFC="false" toc="include" pn="section-appendix.b">
      <name slugifiedName="name-authors-addresses">Authors' Addresses</name>
      <author initials="A" surname="Bierman" fullname="Andy Bierman">
        <organization showOnFrontPage="true">YumaWorks</organization>
        <address>
          <email>andy@yumaworks.com</email>
        </address>
      </author>
      <author initials="M" surname="Bjorklund" fullname="Martin Bjorklund">
        <organization showOnFrontPage="true">Cisco</organization>
        <address>
          <email>mbj+ietf@4668.se</email>
        </address>
      </author>
      <author initials="K" surname="Watsen" fullname="Kent Watsen">
        <organization showOnFrontPage="true">Watsen Networks</organization>
        <address>
          <email>kent+ietf@watsen.net</email>
        </address>
      </author>
    </section>
  </back>
</rfc>
