<?xml version='1.0'?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes" ?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<?rfc linkmailto="no" ?>
<?rfc editing="no" ?>
<?rfc comments="yes" ?>
<?rfc inline="yes"?>
<?rfc rfcedstyle="yes"?>
<!-- <?rfc-ext allow-markup-in-artwork="yes" ?> what does this do? -->
<?rfc-ext include-index="no" ?>
<!--<?rfc strict="no"?> -->
<rfc category="bcp" ipr="trust200902" docName="draft-kwatsen-git-xiax-automation-00">
  <front>
      <title abbrev="XIAX">eXtract or Insert artwork And source code to/from Xml (xiax)</title>
      <author initials="K.W." surname="Watsen" fullname="Kent Watsen">
          <organization>Watsen Networks</organization>
          <address>
              <email>kent+ietf@watsen.net</email>
          </address>
      </author>
      <date/>
      <area>General</area>
      <workgroup>GitHub Integration and Tooling (git)</workgroup>
      <abstract>
        <t>This document describes motivations behind and solutions for tooling
          to automate the extraction/insertion of artwork and source code to/from `rfc2xml`
          documents.</t>
        <t>While much may appear to be working, the author believes that, in order
          to be such automation to be maximally useful, it is necessary to solicit
          broad input from the community (co-authors are welcomed, both on the draft
          and the tool).</t>
      </abstract>
  </front>
  <middle>
    <section title="Introduction">
      <t>This document describes motivations behind and solutions for tooling
      to automate the extraction/insertion of artwork and source code to/from
      `rfc2xml` v2 <xref target="RFC7749"/> and v3 <xref target="RFC7991"/>.</t>

      <t>For authors, adoption of the automation ensures completely up-to-date
      &lt;artwork&gt; and &lt;sourcecode&gt; inclusions every time the document
      is published.</t>

    <t>For reviewers (especially shepherds, doctors, and copy editors), use of
      the automation offers assurance that the &lt;artwork&gt; and &lt;sourcecode&gt;
      inclusions are syntactically valid, and the ability to quickly verify that
      they are when needed.</t>
    </section>

    <section title="Applicability Statement">
      <t>At the time of this writing, `rfc2xml` v3 <xref target="RFC7991"/>
      is not yet in production, and thus the tooling support described herein
      is intended to apply to both v2 and v3.</t>
      <t>Whenever ambiguity may arise, this document will fully write out text
      such as "...source code stored in the v2 &lt;artwork&gt; element...".</t>
    </section>

    <section title="Notational Conventions">
      <t>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 <xref target="RFC2119"/> <xref target="RFC8174"/>
      when, and only when, they appear in all capitals, as shown here.</t>
    </section>

    <section title="Terminology">
      <t>This document uses the following terms (sorted by name):
        <list style="hanging" hangIndent="4">
           <t hangText="Artwork:">The term "artwork" is used throughout
           to represent two-dimensional imagery (e.g., ASCII art), such
           as would be referenced by the &lt;artwork&gt; element
           defined in Section 2.5 of <xref target="RFC7991"/>.</t>

           <t hangText="Source code:">The term "source code" is used 
           throughout to represent a structured sequence of lines, such
           as would be referenced by the &lt;sourcecode&gt; element
           defined in Section 2.48 of <xref target="RFC7991"/>.</t>
        </list>
      </t>
    </section>

    <section title="Updates to RFC 7991">
      <t>This section is just a placeholder for now, but it is expected
      that <xref target="RFC7991"/> will need to be modified in order
      to support some of this work.</t>
      <t>At a minimum, <xref target="RFC7991"/> should be updated to
      support attributes from other namespaces, such that the `rfc2xml`
      tool would neither process nor discard them.</t>
    </section>

    <section title="Motivation">
      <t>The driving motivation for this work is twofold:
        <list style="symbols">
          <t>To ensure the correctness of works in progress.</t>
          <t>To simplify the formal verification process.</t>
        </list>
      </t>
      <t>Firstly, far too often, throughout the lifecycle of a draft, is
        it that authors overlook updating artwork and/or source code in
        their drafts, leading to confusion and wasting some of the precious
        little time of other working group members.  While repeated 
        encouragement from chairs and others to embrace automation, it
        seems that the bar is too high for some authors to bother for
        their one and perhaps only draft.  It is actually a self-defeating
        strategy, as it has been shown time and again that the effort
        invested to do necessary script-fu would be recouped by the authors
        themselves over the lifetime of their draft.</t>
      <t>Next, for formal verifications, the YANG Doctor <xref target="yang-doctors"/>,
        reviews are first in mind, but the automation is equally useful for any
        structured syntax other than YANG <xref target="RFC6020"/> <xref target="RFC7950"/>,
        such as ASN.1 <xref target="ITU.X690.2015"/> and ABNF <xref target="RFC5234"/>
        <xref target="RFC7405"/>.  That said, publication process experience shows
        that doctor reviews are often out of synch with the document submitted for
        publication, sometimes even by several draft revisions.  Thusly, it is common 
        for the draft shepherds themselves to verify the correctness of inclusions
        when doing the shepherd writeup. Further, the document may be subsequently
        updated by IESG and/or copy editor reviews, steps for which the automation
        would continue to support.</t>
    </section>

    <section title="Previous Work">
      <t>
        <list style="symbols">
          <t>Section 3.2 of <xref target="RFC8407"/> states that normative YANG
          modules and submodules contained within Internet-Drafts and RFCs must
          be bracketed by &lt;CODE BEGINS&gt; and &lt;CODE ENDS&gt; markers.
          Section 3.1.18 of <xref target="I-D.levkowetz-xml2rfc-v3-implementation-notes"/>
          notes support for this in `xml2rfc` through the use of a `markers`
          attribute in the &lt;sourcecode&gt; element.   [PS: these markers
          attempt to support extraction from plain-text documents but, as
          this document shows, extraction from XML is superior and, besides,
          there are many interesting things to extract beyond YANG modules.]</t>

          <t>The `xym` <xref target="xym"/> and `rfcstrip` <xref target="rfcstrip"/>
          utilities have been developed to extract YANG modules from Internet-Drafts
          and RFCs using the &lt;CODE BEGINS&gt; and &lt;CODE ENDS&gt; markers.</t>

          <t>The RFC Submit <xref target="submit"/> tool has been modified to
          test YANG modules contained within I-Ds, and the resulting document
          page in Datatracker [datatracker] displays a new "Yang Validation"
          field containing a varying color yin-yang symbol (green if no errors,
          red if errors) along with counts.  This tool is okay for what it is,
          but it neither aids authors between updates nor validates anything
          beyond YANG modules.</t>

          <t>The YANG Validator site <xref target="yang-validator"/> provides
          an Internet-facing service, with a REST-based API, for validating
          YANG modules in drafts.  Having a REST API enables its use throughout
          a document's lifecycle but, again, it doesn't validate anything beyond
          YANG modules.</t>
        </list>
      </t>
    </section>

    <section title="Automated Construction">
      <t>When asked to build a submittable `rfc2xml` document, the automation
      should perform the following steps, in order:
        <list style="numbers">
          <t>Prime artwork and source code as needed.  Known priming steps include:
            <list style="format %i">
              <t>Draft revision addition/substitution for the `docName` attribute
              in the &lt;rfc&gt; element as well as in the filename.</t>
              <t>Date substitution (e.g., replacing the string "YYYY-MM-DD"
              with the current date.  This substitution needs to occur both within
              files and in filenames.</t>
              <t>Generation of derived views (e.g., YANG tree diagrams
              <xref target="RFC8340"/>).  Technically, the derived views should
              be generated after the validation (discussed next) but, said
              generation is rightly part of the "priming" step and, besides,
              if there is an error, the validation step would still catch it,
              so there's no harm in generating the derived views first.</t>
            </list>
          </t>
          <t>Validate source code and artwork.  This step includes:
            <list style="format %i">
              <t>Validating data models (e.g., YANG modules) against the schema
              describing their syntax.</t>
              <t>Validating data instance examples (e.g., a snippet of configuration)
              against the governing data models (e.g., the aforementioned YANG modules).</t>
            <t>Validating the derived views.  Technically, this step is not needed
              during the insertion process, since the derived views were just generated
              in the previous step but, since the same validation logic is used by
              automated verification (see <xref target="auto-verification"/>), it
              is automatically executed here as well.  Validating derived views is
              accomplished by running the script to generate the view and then
              comparing the result to the view extracted in the draft.</t>
            </list>
          </t>
          <t>Pack the final submittable XML file.  This step includes:
            <list style="format %i">
              <t>Pasting the contents referenced by attributes in the &lt;artwork&gt; and
                &lt;sourcecode&gt; elements into the XML document, and storing information
                enabling the content to be extracted back to its original filename.</t>
              <t>Additional attributes can control if markers are added (e.g., the
                &lt;CODE BEGINS&gt; and &lt;CODE ENDS&gt; markers described by
                RFC 8407 Section 3.2).</t>
              <t>Character data (CDATA) wrappers may be added.</t>
              <t>Folding (line wrapping) may be added, per
                <xref target="I-D.ietf-netmod-artwork-folding"/>.</t>
              <t>Additional date substitutions (e.g., YYYY-MM-DD) in the body of the
                draft may be needed.</t>
              <t>Draft revision substitution (i.e., replacing placeholder "-latest"
                with, e.g., "-03").</t>
            </list>
          </t>
        </list>
      </t>
    </section>

    <section title="Automated Verification" anchor="auto-verification">
      <t>When asked to extract/verify a submitted `rfc2xml` document, the automation
      should perform the following steps, in order:
        <list style="numbers">
          <t>Extract the contents of the &lt;artwork&gt; and &lt;sourcecode&gt;
            elements to their original file-based forms, retaining their file names
            and directory paths.</t>
          <t>Extract any additional files that may be necessary to generate the
            derived views and/or validate the inclusions.</t>
          <t>Optionally, if requested, also save the "primed" or "unpacked" XML
            file (i.e., the source XML file before the content was packed into it).</t>
          <t>At this point, the local directory tree represents the "primed" state,
          and thus the same validation logic described above can executed again.</t>
        </list>
      </t>
    </section>

    <section title="Security Considerations">
      <section title="Automated Execution of Arbitrary Scripts">
        <t>In order to support the auto-generation of derived views and the 
          validation of data models and data instance examples, the automation
          solution must not automatically execute arbitrary scripts.</t>
        <t>A couple solutions present themselves:
          <list style="symbols">
            <t>Allow arbitrary scripts, but don't execute them automatically
              when a document is extracted.  This solution is appealing as it
              still ensures these scripts were executed on the author's computer
              at time of construction, and the scripts themselves can be extracted
              and audited on the reviewer's computer.  If desired, after auditing
              a script, a reviewer could choose to manually execute it on their
              own computer.</t>
            <t>Don't allow arbitrary scripts but, instead, support parameterized
              files that declare all the information necessary to construct the
              command(s) necessary to generate derived views and/or validate
              inclusions.</t>
          </list>
        </t>
      </section>
    </section>

<!--
    <section title="IANA Considerations">
      <t>Unlikely</t>
    </section>
-->

  </middle>

  <back>

    <references title="Normative References">
      <?rfc include="reference.RFC.2119.xml"?>
      <?rfc include="reference.RFC.7991.xml"?>
      <?rfc include="reference.RFC.8174.xml"?>
    </references>



    <references title="Informative References">
      <?rfc include="reference.RFC.5234.xml"?>
      <?rfc include="reference.RFC.6020.xml"?>
      <?rfc include="reference.RFC.7405.xml"?>
      <?rfc include="reference.RFC.7749.xml"?>
      <?rfc include="reference.RFC.7950.xml"?>
      <?rfc include="reference.RFC.8340.xml"?>
      <?rfc include="reference.RFC.8407.xml"?>
      <?rfc include="reference.I-D.levkowetz-xml2rfc-v3-implementation-notes"?>
      <?rfc include="reference.I-D.ietf-netmod-artwork-folding"?>

      <reference anchor="submit" target="https://datatracker.ietf.org/submit">
        <front><title>Datatracker Internet-Draft Submission Service</title><author/><date/></front>
      </reference>
      <reference anchor="rfcstrip" target="https://github.com/mbj4668/rfcstrip">
        <front><title>The `rfcstrip` GitHub Repository</title><author/><date/></front>
      </reference>
      <reference anchor="xiax" target="https://github.com/kwatsen/xiax">
        <front><title>The `xiax` GitHub Repository</title><author/><date/></front>
      </reference>
      <reference anchor="xym" target="https://github.com/xym-tool/xym">
        <front><title>The `xym` GitHub Repository</title><author/><date/></front>
      </reference>
      <reference anchor="yang-doctors" target="https://datatracker.ietf.org/group/yangdoctors/about">
        <front><title>The YANG Doctors "about" Page</title><author/><date/></front>
      </reference>
      <reference anchor="yang-validator" target="http://www.yangvalidator.com">
        <front><title>The YANG Validator Service</title><author/><date/></front>
      </reference>
      <!-- THE FOLLOWING LINE DOESN'T RESOLVE BECAUSE _reference.ITU.X744.1996.xml
           DOES NOT EXIST HERE: http://xml2rfc.tools.ietf.org/public/rfc/bibxml2/
           <?rfc include="reference.ITU.X690.2015.xml"?> -->
      <reference anchor="ITU.X690.2015" target="https://www.itu.int/rec/T-REC-X.690/">
        <front>
          <title>Information Technology - ASN.1 encoding rules: Specification of Basic
          Encoding Rules (BER), Canonical Encoding Rules (CER) and Distinguished
          Encoding Rules (DER)</title>
          <author>
            <organization>International Telecommunication Union</organization>
          </author>
          <date month="August" year="2015"/>
        </front>
        <seriesInfo name="ITU-T Recommendation X.690," value="ISO/IEC 8825-1"/>
      </reference>

    </references>

    <section title="Examples">

      <t>This section illustrates bits working using the `xiax` tool <xref target="xiax"/>.</t>

      <t>This entire document has been processed by `xiax`, albeit with a little
        manual tweaking to return some of the "YYYY-MM-DD" strings (such as this one)
        back to their original forms.</t>

      <t>Note that, as this is an `xml2rfc` v2 document, all examples use the
      `xml2rfc` v2 &lt;artwork&gt; element.</t>

      <section title="Static Inclusion">
        <t>This example illustrates inclusion of static content with no additional
          processing, such as might be useful for pre-generated artwork.</t>
        <t>This is what the original `xml2rfc` XML looked like:</t>
        <t>
          <figure>
            <artwork>
&lt;preamble&gt;START FIGURE&lt;/preamble&gt;
&lt;artwork xiax:src="art/hello.txt"/&gt;
&lt;postamble&gt;END FIGURE&lt;/postamble&gt;</artwork>
          </figure>
        </t>
        <t>Here is the rendered content:</t>
        <t>
          <figure>
            <preamble>START FIGURE</preamble>
            <artwork><![CDATA[ _          _ _       
| |        | | |      
| |__   ___| | | ___  
| '_ \ / _ \ | |/ _ \ 
| | | |  __/ | | (_) |
|_| |_|\___|_|_|\___/ 
]]></artwork>
            <postamble>END FIGURE</postamble>
          </figure>
        </t>
      </section> 

      <section title="Static Inclusion and Date Substitution">
        <t>This example illustrates inclusion of static content along with date substitution.
          Date substitution is triggered by the string "YYYY-MM-DD" appearing in the name of
          the file being included.  The date-substitution is applied to both the filename as
          well as to the content of the file.</t>
        <t>This is what the original `xml2rfc` XML looked like:</t>
        <t>
          <figure>
            <artwork>
&lt;preamble&gt;START FIGURE&lt;/preamble&gt;
&lt;artwork xiax:src="art/email-YYYY-MM-DD.txt"/&gt;
&lt;postamble&gt;END FIGURE&lt;/postamble&gt;</artwork>
          </figure>
        </t>
        <t>Here is the rendered content:</t>
        <t>
          <figure>
            <preamble>START FIGURE</preamble>
            <artwork><![CDATA[+-------------------------------+
| To: all                       |
| Date: 2019-02-25              |
| Subject: hello world          |
|                               |
| ...                           |
+-------------------------------+
]]></artwork>
            <postamble>END FIGURE</postamble>
          </figure>
        </t>
        <t>The content of the original "src" file (before date-substitute):</t>
        <t>
          <figure>  <!-- manually tweaked by author post-xiax -->
            <artwork><![CDATA[+-------------------------------+
| To: all                       |
| Date: YYYY-MM-DD              |
| Subject: hello world          |
|                               |
| ...                           |
+-------------------------------+
]]></artwork>
          </figure>
        </t>
      </section> 

      <section title="Generated Inclusion and Date Substitution">
        <t>This example illustrates both inclusion of generated content along with date
          substitution.</t>
        <t>This is what the original `xml2rfc` XML looked like:</t>
        <t>
          <figure>
            <artwork>
&lt;preamble&gt;START FIGURE&lt;/preamble&gt;
&lt;artwork xiax:gen="xiax/gen-foo-tree-diagram@YYYY-MM-DD.xml"/&gt;
&lt;postamble&gt;END FIGURE&lt;/postamble&gt;</artwork>
          </figure>
        </t>
        <t>Here is the rendered content:</t>
        <t>
          <figure>
            <preamble>START FIGURE</preamble>
            <artwork><![CDATA[module: foo
  +--rw foo?   empty
]]></artwork>
            <postamble>END FIGURE</postamble>
          </figure>
        </t>
        <t>The content of the "gen" file being referenced is:</t>
        <t>
          <figure>  <!-- manually tweaked by author post-xiax -->
            <artwork><![CDATA[<generate xmlns="https://watsen.net/xiax" version="1">
  <yang-tree-diagram>
    <source>foo@YYYY-MM-DD.yang</source>
  </yang-tree-diagram>
</generate>
]]></artwork>
          </figure>
        </t>
      </section> 


      <section title="Static Inclusion, Date Substitution, and Validation">
        <t>This example illustrates inclusion of static content with date substitution
          and behind-the-scenes validation.  Note that, in this example, the date
          substitution occurs on the validation input file (since it references
          a date-substituted file).</t>
  
        <t>This is what the original `xml2rfc` XML looked like:</t>
        <t>
          <figure>
            <artwork>
&lt;preamble&gt;START FIGURE&lt;/preamble&gt;
&lt;artwork xiax:src="examples/ex-foo.json" xiax:val="xiax/val-xml-ex-foo@YYYY-MM-DD.xml"/&gt;
&lt;postamble&gt;END FIGURE&lt;/postamble&gt;</artwork>
          </figure>
        </t>
  
        <t>Here is the rendered content:</t>
        <t>
          <figure>
            <preamble>START FIGURE</preamble>
            <artwork><![CDATA[{
  "foo:foo": [null]
}
]]></artwork>
            <postamble>END FIGURE</postamble>
          </figure>
        </t>

        <t>The content of the "val" file being referenced is:</t>
        <t>
          <figure>  <!-- manually tweaked by author post-xiax -->
            <artwork><![CDATA[<validate xmlns="https://watsen.net/xiax">
  <xml-document>
    <using-yang>
      <yang-modules>
        <yang-module>
          <name>foo@YYYY-MM-DD.yang</name>
          <uri>foo@YYYY-MM-DD.yang</uri>
        </yang-module>
      </yang-modules>
    </using-yang>
  </xml-document>
</validate>
]]></artwork>
          </figure>
        </t>
      </section> 


      <section title="Static Inclusion, Date Substitution, Markers, and Validation">
        <t>This example illustrates inclusion of static content with date substitution,
          &lt;BEGIN CODE&gt; and &lt;END CODE&gt; markers, and behind-the-scenes validation.</t>
  
        <t>This is what the original `xml2rfc` XML looked like:</t>
        <t>
          <figure>
            <artwork>
&lt;preamble&gt;START FIGURE&lt;/preamble&gt;
&lt;artwork xiax:src="foo@YYYY-MM-DD.yang" xiax:markers="true" xiax:val="xiax/val-yang-foo@YYYY-MM-DD.xml"/&gt;
&lt;postamble&gt;END FIGURE&lt;/postamble&gt;
  </artwork>
          </figure>
        </t>
  
        <t>Here is the rendered content:</t>
        <t>
          <figure>
            <preamble>START FIGURE</preamble>
            <artwork><![CDATA[<CODE BEGINS> file "foo@2019-02-25.yang"

module foo {
  yang-version 1.1;
  namespace "https://example.com/foo";
  prefix "f";

  revision "2019-02-25" {
    description
     "Initial version";
  }

  leaf foo {
    type empty;
  }
}

<CODE ENDS>]]></artwork>
            <postamble>END FIGURE</postamble>
          </figure>
        </t>

        <t>The content of the "val" file being referenced is:</t>
        <t>
          <figure>  <!-- manually tweaked by author post-xiax -->
            <artwork><![CDATA[<validate xmlns="https://watsen.net/xiax">
  <xml-document>
    <using-yang>
      <yang-modules>
        <yang-module>
          <name>foo@YYYY-MM-DD.yang</name>
          <uri>foo@YYYY-MM-DD.yang</uri>
        </yang-module>
      </yang-modules>
    </using-yang>
  </xml-document>
</validate>
]]></artwork>
          </figure>
        </t>
      </section> 

    </section> <!-- end Examples -->



    <section title="Details for the `xiax` Utility">
      <section title="The &quot;xiax-block&quot; Comment">
        <t>In order to support extractions, `xiax` needs to encode metadata into the
          `xml2rfc` XML file.  This metadata encodes, for instance, the original names
          of files, contents of the 'gen' and 'val' files, and and additional files
          that may have been used by the 'gen' and/or 'val' files.</t>  
        <t>There are limited options for encoding metadata into the `xml2rfc` format
          in a way that doesn't generate errors or is discarded during the Internet-Draft
          submission process.</t>
        <t>The only option that was discovered is to encode the metadata into an XML
          comment.  Thus, `xiax` adds a special XML comment referred to as the "xiax-block"
          to the end of the `xml2rfc` XML file.</t>
        <t>An example xiax-block follows:</t>
        <t>
          <figure>
            <artwork><![CDATA[<!-- FANTASTIC RFC CONTENT ABOVE THIS LINE -->

  </back>
<!-- ##xiax-block-v1:
H4sIAMcX/82WTW/iMBCG7/wKlruZQsuhKzcqWq697aVCHEwYwMWxke206b/vOB8lgUhdsrDb
nJzxTOad8EyKjC2ViXf9LFHaPQy23u/dT4A34R3qoUYPIWkQ9fp9LnWsUieNDnd0vxd+Gy1F
vAOHsaf4L/38dgFruUktgrD+zdgdh7yoqHc2Lla0Ft5buYwoDbaolBn6zHMoo0U6lPkcGkLO
kzXuLAsT34zu2c2YjSdXVXj3nRXefu3hBvWxwsARUJytjWHeIrKVFBsrkseaYsKwqZjq11Jh
xH/Mf82m8Gi0wuNXyPZf0YaJHgajAt93oTeNxpWbJrUxRiSrriRkk13FXu5YSz2HSk3UWywi
DrnW0urS+mwYull9GTjuOr1gmIlkr9ABZkH08MUZfQLCq1DV+mhW2mE0DyuqH5/pYk9PbDZr
A+oUKSqXKncj9FmZOE1Q+3IgMofQCHx8as1hScwqpaFqjWvhQ5TiWiQFgTXpBYH5Tj01tbI9
M2wcOkFLVafeVM+hOSCHyp0TxEPy55lckJ5uvB8xcH3SJ51Ib/3MnAV6foZXx7xGCvxrCib/
kQIOh7+isdFI8SMJAAA=

-->

</rfc>
]]></artwork>
          </figure>
        </t>
        <t>Note that this data is the base64-encoding of the GZIP-ed string for the
          encoded metadata.</t>
        <t>Also note that the xiax-block is versioned.  The intention is that, while
          a given version of `xiax` will only produce the "current" xiax-block version,
          it should be capable of extracting content from a draft produced by any prior
          version.</t>
      </section>

      <section title="Extensible Support to Content Types">
        <t>Before diving into the "xiax-block", and in the interest of full
          disclosure, it should be known that `xiax` currently has limited support for
          content types.  Specifically:
          <list style="symbols">
            <t>For generating content, `xiax` currently only knows how to generate YANG tree
              diagrams <xref target="RFC8340"/>.</t>
            <t>For validating content, `xiax` currently only knows how to validate YANG modules 
              <xref target="RFC7950"/> and XML/JSON documents against YANG schema.</t>
          </list>
        </t>
        <t>However, the code has been developed anticipating a desire to extend it
          to support other content types. And, being an open source project on 
          GitHub, it is hoped that others will take interest to add support for
          additional content types.</t>
      </section>

      <section title="The &quot;xiax-block&quot; Data Model">
        <t>Being that `xiax` operates on XML files, it was intuitive to use XML to
          encode the xiax-block.</t>
        <t>In IETF fashion, the schema for the XML data model is defined using YANG
          <xref target="RFC7950"/>.</t>
        <section title="Tree Diagram">
          <t>Following is the YANG Tree Diagram <xref target="RFC8340"/> for the xiax-block:</t>
          <t>
            <figure>
              <artwork><![CDATA[module: xiax-structures-v1

  yang-data xiax-block:
    +-- xiax-block
       +-- inclusion* [path]
          +-- path    string
          +-- src
          |  +-- attrib?   inet:uri
          |  +-- val
          |     +-- attrib?   inet:uri
          |     +-- file?     <anydata>
          +-- gen
             +-- attrib?   inet:uri
             +-- file?     <anydata>
             +-- val
                +-- attrib?   inet:uri
                +-- file?     <anydata>
  yang-data generate:
    +-- generate
       +-- (generate-type)?
          +--:(yang-tree-diagram)
             +-- yang-tree-diagram
                +-- source?            string
                +-- print-yang-data?   empty
  yang-data validate:
    +-- validate
       +-- (content-type)?
          +--:(yang-module)
          |  +-- yang-module
          |     +-- additional-yang-modules
          |        +-- additional-yang-module* [name]
          |           +-- name    string
          |           +-- uri*    inet:uri
          +--:(xml-document)
             +-- xml-document
                +-- (schema-type)?
                |  +--:(using-yang)
                |     +-- using-yang
                |        +-- yang-modules
                |           +-- yang-module* [name]
                |              +-- name    string
                |              +-- uri*    inet:uri
                +-- additional-xml-documents
                   +-- additional-xml-document* [name]
                      +-- name    string
                      +-- uri*    inet:uri
]]></artwork>
            </figure>
          </t>
        </section>
        <section title="YANG Module">
          <t>Following is the YANG module for the xiax-block follows:</t>
          <t>
            <figure>
              <artwork><![CDATA[module xiax-structures-v1 {
  yang-version 1.1;
  namespace "https://watsen.net/xiax";
  prefix "xb";

  import ietf-inet-types {
    prefix inet;
    reference "RFC 6991: Common YANG Data Types";
  }

  import ietf-restconf {
    prefix rc;
    reference "RFC 8040: RESTCONF Protocol";
  }

  organization "Watsen Networks";

  contact "Kent Watsen <mailto:kent+ietf@watsen.net>";

  description
   "This module defines the data model for xiax data block.

    Copyright (c) 2019 Watsen Networks.  All rights reserved.";


  revision "2019-02-25" {
    description
     "Initial version";
  }

  grouping val-grouping {
    container val {
      leaf attrib {
        type inet:uri;
        description
          "The original 'xiax:val' attribute that was in the 
           <sourcecode> element (<artwork> cannot be validated).";
      }
      anydata file {
        description
          "The content of the file per the 'xiax:val' attribute";
      }
    }
  }

  rc:yang-data "xiax-block" {
    container xiax-block {

      description
        "Contains lists of inclusions that were processed by `xiax`
         during its 'packing' step.";
  
      list inclusion {
        key path;
  
        description
          "A list of inclusions, one for each <artwork> and/or
           <sourcecode> element processed by `xiax`.";
  
        leaf path {
          type string;
          description
            "The DOM path of the <artwork> or <sourcecode> element.";
        }

        container src {
          leaf attrib {
            type inet:uri;
            description
              "The original 'xiax:src' attribute that was in the 
               <artwork> or <sourcecode> element.";
          }
          uses val-grouping;
        }

        container gen {
          leaf attrib {
            type inet:uri;
            description
              "The original 'xiax:gen' attribute that was in the 
               <artwork> or <sourcecode> element.";
          }
          anydata file {
            description
              "The content of the file per the 'xiax:gen' attribute";
          }
          uses val-grouping;
        }


      } // end list inclusion
    } // end container xiax-block
  } // end rc:yang-data xiax-block




  rc:yang-data "generate" {
    container generate {

      description
        "Contains instructions to `xiax` for how to generate content";

      choice generate-type {
        description
          "The type of content to generate, and information for how
           to do so.";

        container yang-tree-diagram {
          leaf source {
            type string;
            description
              "The YANG file to generate the tree-diagram from.";
          }
          leaf print-yang-data {
            type empty;
          }
        }

        /*** add more gen-types here ***/

      } // end choice gen-type
    } // end container xiax-block
  } // end rc:yang-data generate




  rc:yang-data "validate" {
    container validate {

      description
        "Contains information for how to validate content.  Currently
         just the list of modules and ";

      choice content-type {
        description
          "The type of content to validate, and information for how
           to do so.";

        container yang-module {
          description
            "Provides information for how to validate the YANG module.";
          container additional-yang-modules {
            description
              "Additional YANG documents that may be needed in order to
               resolve, e.g., import statements.   Do not include the
               YANG module being validated.";
            list additional-yang-module {
              key name;
              leaf name {
                type string;
              }
              leaf-list uri {
                type inet:uri;
                description
                  "Location for where the YANG module is located.
                   Multiple URIs are used to address availability
                   concerns.  A copy of files referenced using the 
                   'file' schema is embedded into the xiax-block.
                   A file will only be stored into the xiax-block
                   at most once, in case it referenced by more
                   than one validation.";
              }
            } // end list additional-yang-module
          } // end container additional-yang-modules
        } // end container yang-module

        container xml-document {
          description
            "Provides information for how to validate a XML document.";

          choice schema-type {
            description
              "Enables the schema-type to be selected.";

            container using-yang {
              description
                "Provides information for how to validate the XML
                 document using YANG.";

              container yang-modules {
                list yang-module {
                  key name;
                    leaf name {
                    type string;
                  }
                  leaf-list uri {
                    type inet:uri;
                    description
                      "Location for where the YANG module is located.
                       Multiple URIs are used to address availability
                       concerns.  A copy of files referenced using the 
                       'file' schema is embedded into the xiax-block.
                       A file will only be stored into the xiax-block
                       at most once, in case it referenced by more
                       than one validation.";
                  }
                } // end list yang-module
              } // end container yang-modules
            } // end container using-yang

          /*** add other XML-validating schema-types here ***/

          } // end choice schema-type
  
          container additional-xml-documents {
            description
              "Additional XML documents that may be needed in order to
               resolve, e.g., data references.   Do not include the XML
               document being validated.";
         
            list additional-xml-document {
              key name;
              leaf name {
                type string;
              }
              leaf-list uri {
                type inet:uri;
                description
                  "Location for where the XML document is located.  
                   Multiple URIs are used to address availability
                   concerns.  A copy of files referenced using the 
                   'file' schema is embedded into the xiax-block.
                   A file will only be stored into the xiax-block
                   at most once, in case it referenced by more
                   than one validation.";
              }
            } // end additional-xml-document
          } // end container additional-xml-documents
        } // end container xml-document
  
        /*** add content-types here ***/

      } // end choice content-type
    } // end container validate
  } // end rc:yang-data validate

} // end module xiax-structures-v1

]]></artwork>
            </figure>
          </t>
        </section>
      </section>

      <section title="Examples">
        <section title="A peak inside the &quot;xiax-block&quot;">
          <t>The following is a snippet of the xiax-block used in this draft.</t>
          <t>Thie example illustrates three inclusions:
            <list style="numbers">
              <t>A "xiax:src" attribute.</t>
              <t>A "xiax:gen" attribute, including the gen-file itself.</t>
              <t>Both "xiax:src" and "xiax:val" attributes, including the val-file itself.</t>
            </list>
          </t>
          <t>
            <figure>
              <artwork><![CDATA[<?xml version="1.0"?>
<xiax-block xmlns="https://watsen.net/xiax">
  <inclusion>
    <path>back/section[1]/section[1]/t[3]/figure/artwork</path>
    <src>
      <attrib>hello.txt</attrib>
    </src>
  </inclusion>
  <inclusion>
    <path>back/section[1]/section[3]/t[3]/figure/artwork</path>
    <gen>
      <attrib>xiax/gen-foo-tree-diagram@2019-02-25.xml</attrib>
      <file>
        <generate xmlns="https://watsen.net/xiax" version="1">
          <yang-tree-diagram>
            <source>foo@2019-02-25.yang</source>
          </yang-tree-diagram>
        </generate>
      </file>
    </gen>
  </inclusion>
  <inclusion>
    <path>back/section[1]/section[5]/t[4]/figure/artwork</path>
    <src>
      <attrib>examples/ex-foo.xml</attrib>
      <val>
        <attrib>xiax/val-xml-ex-foo@2019-02-25.xml</attrib>
        <file>
          <validate xmlns="https://watsen.net/xiax">
            <xml-document>
              <using-yang>
                <yang-modules>
                  <yang-module>
                    <name>foo@2019-02-25.yang</name>
                    <uri>foo@2019-02-25.yang</uri>
                  </yang-module>
                </yang-modules>
              </using-yang>
            </xml-document>
          </validate>
        </file>
      </val>
    </src>
  </inclusion>
</xiax-block>
]]></artwork>
            </figure>
          </t>
        </section>

        <section title="A &quot;gen&quot; file (for a tree diagram)">
          <t>This example shows what the "gen" file for generating a YANG tree diagram
            looks like.</t>
          <t>
            <figure>
              <artwork><![CDATA[<generate xmlns="https://watsen.net/xiax">
  <yang-tree-diagram>
    <source>xiax-block-v1@YYYY-MM-DD.yang</source>
  </yang-tree-diagram>
</generate>
]]></artwork>
            </figure>
          </t>
        </section>

        <section title="A &quot;val&quot; file (for an YANG module)">
          <t>This example shows what the "val" file for validating a YANG module
            looks like.</t>
          <t>
            <figure>
              <artwork><![CDATA[<validate xmlns="https://watsen.net/xiax">
  <yang-module>
    <additional-yang-modules>
      <additional-yang-module>
        <name>ietf-restconf@2017-01-26.yang</name>
        <uri>https://raw.githubusercontent.com/YangModels/yang/master/standard/ietf/RFC/ietf-restconf%402017-01-26.yang</uri>
      </additional-yang-module>
    </additional-yang-modules>
  </yang-module>
</validate>
]]></artwork>
            </figure>
          </t>
        </section>

        <section title="A &quot;val&quot; file (for an XML document)">
          <t>This example shows what the "val" file for validating an XML document
            looks like.</t>
          <t>
            <figure>
              <artwork><![CDATA[<validate xmlns="https://watsen.net/xiax">
  <xml-document>
    <using-yang>
      <yang-modules>
        <yang-module>
          <name>xiax-block-v1.yang</name>
          <uri>./xiax-block-v1.yang</uri>
        </yang-module>
        <yang-module>
          <name>ietf-restconf@2017-01-26.yang</name>
          <uri>https://raw.githubusercontent.com/YangModels/yang/master/standard/ietf/RFC/ietf-restconf%402017-01-26.yang</uri>
        </yang-module>
      </yang-modules>
    </using-yang>
  </xml-document>
</validate>
]]></artwork>
            </figure>
          </t>
        </section>

      </section>

    </section> <!-- end `xiax` Details -->

<!--
    <section title="Change Log">
      <section title="I-D to 00">
        <t>
          <list style="symbols">
          </list>
        </t>
      </section>
    </section>
-->

<!--
    <section title="Acknowledgements" numbered="no">
      <t>The author would like to thank for following for lively discussions on
      list and in the halls (ordered by last name):
     </t>
    </section>
-->
  
  </back>
<!-- ##xiax-block-v1:
H4sIAMcXEUkC/82WTY/aMBCG7/wKyt3MEkBVK2+0q+W6t71UiIMJBlwSB9kOm/77jvOxOBCVJgQE
J2c8xu+8fvxBU8FSsgzjYNdPo1Dq58HWmL3+CfDJjOZyKLkBmzTwe/0+FTIIEy1iab/we8/M1l+y
YAeaBwbj89HCbZr5dAFrsUkUB6bMZ6x2FLJB+XitgryFbWaMEksf02DLwzAemtRQKKJ5OhT5FCpC
msnyWsviERMh8Z5GP8iTR7zpTRV+f2SF48sebrg8VWg5AoyTdRwTozgnK8E2ikUvjmLEsKoYx69F
yH36bf42e/14ndu/5ooZfgnZ/oErW9HzYJTj+4fJTWXi0s04UQH3UZarxGajXXlf5ljNeAqlGr+3
WPgUMq2F1YUH11vdGIZ2VncDx6TVBuMpi/Yh18BTK3r4W8fyDIQDC8v2Sa3YQ7Aeko9++YU/8v5O
ZrM6oM6RwuFi9R9IZW7YeVZxkERcmqIgNAfRsHx8ac1gieJVgkU5EzvhYxTjkkU5gY70nMCsx01N
lKjPtB3HmaBmqkpQl6teVU+hWiCF0p0zxG3y15p0SE873k8YuD3p01ak1x4zjUDP1vDmmDukwL0p
mD46Bd617xz3vDu+wjq9sL3KLVKR67W+u49aH/EKz7ozrZlObVQSGCxTk8PoX3e79U8JafKthZQz
uPOVX79Y3uXFqmGrmQvd0zY5oW3cvoDK7kD5t9rEk+48R8klIPcRPL5ecHm2E+fQv4/4SYfi3XdL
A/UUjoj5vb8rP1COFA8AAA==

-->

</rfc>
