<commit_before><?xml version="1.0" encoding="utf-8"?>

<!-- Program name: gen-relaxng.xsl

Copyright © 2011 by <NAME>, CESNET <<EMAIL>>

Creates RELAX NG schema from the hybrid DSDL schema (see RFC 6110).

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:rng="http://relaxng.org/ns/structure/1.0"
                xmlns:nma="urn:ietf:params:xml:ns:netmod:dsdl-annotations:1"
                xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"                version="1.0">

  <xsl:output method="xml" encoding="utf-8"/>
  <xsl:strip-space elements="*"/>

  <xsl:include href="gen-common.xsl"/>

  <xsl:template name="ns-attribute">
    <xsl:attribute name="ns">
      <xsl:choose>
	<xsl:when test="$target='get-reply' or $target='config' or
			$target='edit-config' or
			$target='data' or $target='get-config-reply'
			or $target='rpc' or $target='rpc-reply'">
	  <xsl:text>urn:ietf:params:xml:ns:netconf:base:1.0</xsl:text>
	</xsl:when>
	<xsl:when test="$target='notification'">
	  <xsl:text>urn:ietf:params:xml:ns:netconf:notification:1.0</xsl:text>
	</xsl:when>
      </xsl:choose>
    </xsl:attribute>
  </xsl:template>

  <xsl:template name="grammar-choice">
    <xsl:choose>
      <xsl:when test="count(rng:grammar)>1">
        <xsl:element name="choice" namespace="{$rng-uri}">
          <xsl:apply-templates select="rng:grammar"/>
        </xsl:element>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates select="rng:grammar"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="inner-grammar">
    <xsl:param name="subtrees"/>
    <xsl:if test="$subtrees">
    </xsl:if>
  </xsl:template>

  <xsl:template name="include-grammar">
    <xsl:param name="file-name"/>
    <xsl:element name="include" namespace="{$rng-uri}">
      <xsl:attribute name="href">
	<xsl:value-of select="$file-name"/>
      </xsl:attribute>
    </xsl:element>
  </xsl:template>

  <xsl:template name="message-id">
    <xsl:element name="ref" namespace="{$rng-uri}">
      <xsl:attribute name="name">message-id-attribute</xsl:attribute>
    </xsl:element>
  </xsl:template>

  <xsl:template name="copy-and-continue">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates select="*|text()"/ose>
    </xsl:copy>
  </xsl:template  <xsl:template match="/">
    <xsl:call-template name="check-input-pars"/>
    <xsl:choose>
      <xsl:when test="$gdefs-only=1">
        <xsl:apply-templates select="rng:grammar" mode="        defs"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates select="rng:grammar"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="/rng:grammar" mode="gdefs">
    <xcopy>
      <xsl:attribute name="datatypeLibrary">
           <xsl:value-of select="@datatypeLibrary"/>
      </xsl:attribute>
      <xsl:apply-templates select="rng:define"/>
    </xcopyent>
  </xsl:template>

  <xsl:template match="/rng:grammar">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:call-template name="ns-attribute"/>
      <xcall-template name="include-grammar">
	<xsl:with-param name="file-name" select="concat($rng-lib,'/relaxng-lib.rng')"/>
      </xsl:call-templateent>
      <xsl:apply-templates select="rng:start"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="/rng:grammar/rng:start">
    <xsl:copy>
    <xsl:choose>
      <xsl:when test="$targetataply'">
        <xsl:element name="element" namespace="{$rng-uri}">
          <xsl:attribute name="namdata</xsl:attribute>
          <xsl:apply-templates
              select="rng:grammar[descendant::nma:data]"/ent>
        </xsl:element>
      </xsl:when>
      <xsl:when test="$targeconfigply'">
        <xsl:element name="element" namespace="{$rng-uri}">
          <xsl:attribute name="namconfig</xsl:attribute>
          <xsl:apply-templates
              select="rng:grammar[descendant::nma:data]"/ent>
        </xsl:element>
      </xsl:when>
      <xsl:when test="$targeget-reply' or
                      $target='get-config-reply'">
	<xsl:element name="element" namespace="{$rng-uri}">
	  <xsl:attribute name="name">rpc-reply</xsl:attribute>
	  <xsl:call-template name="message-id"/>
	  <xsl:element name="element" namespace="{$rng-uri}">
	    <xsl:attribute name="name">data</xsl:attribute>
	    <xsl:element name="interleave" namespace="{$rng-uri}">
	      <xsl:apply-templates
		  select="rng:grammar[descendant::nma:data]"/>
	    </xsl:element>
	  </xsl:element>
	</xsl:elementent>
      </xsl:when>
      <xsl:when test="$targeedit-config'">
	<xsl:element name="element" namespace="{$rng-uri}">
	  <xsl:attribute name="name">rpc</xsl:attribute>
	  <xsl:call-template name="message-id"/>
	  <xsl:element name="element" namespace="{$rng-uri}">
	    <xsl:attribute name="name">edit-config</xsl:attribute>
	    <xsl:element name="ref" namespace="{$rng-uri}">
	      <xsl:attribute name="name">edit-config-parameters</xsl:attribute>
	    </xsl:element>
	    <xsl:element name="element" namespace="{$rng-uri}">
	      <xsl:attribute name="name">config</xsl:attribute>
	      <xsl:element name="interleave" namespace="{$rng-uri}">
		<xsl:apply-templates
		    select="rng:grammar[descendant::nma:data]"/>
	      </xsl:element>
	    </xsl:element>
	  </xsl:element>
	   </xsl:element>
      </xsl:when>
      <xsl:when test="$targerpcply'">
        <xsl:element name="element" namespace="{$rng-uri}">
          <xsl:attribute name="name">ply</xsl:attribute>
          <xsl:call-template name="message-id"/>
          <xsl:element namchoice" namespace="{$rng-uri}">
            <xsl:apply-templates
                select="rng:grammar[descendant::nma:rpcs]"/>
        >
	  </xsl:element>
        </xsl:element>
      </xsl:when>
      <xsl:when test="$target='rpc-reply'">
        <xsl:element name="element" namespace="{$rng-uri}">
          <xsl:attribute name="name">rpc-reply</xsl:attribute>
          <xsl:call-template name="message-id"          <xsl:element name="choice" namespace="{$rng-uri}">
            <xsl:if test="descendant::nma:rpc[not(nma:output)]">
              <xsl:element name="ref" namespace="{$rng-uri}">
                <xsl:attribute name="name">ok-element</xsl:attribute>
              </xsl:element>
            </xsl:if>
            <xsl:apply-templates
                select="rng:grammar[descendant::nma:output]"/>
        >
	  </xsl:element>
        </xsl:element>
      </xsl:when>
      <xsl:when test="$targenotificationply'">
        <xsl:element name="element" namespace="{$rng-uri}">
          <xsl:attribute name="name">notification</xsl:attribute>
          <xsl:element name="ref" namespace="{$rng-uri}">
            <xsl:attribute name="name">eventTime-element</xsl:attribute>
          </xsl:elemen          <xsl:element name="choice" namespace="{$rng-uri}">
            <xsl:apply-templates
                select="rng:grammar[descendant::nma:notification]"/>
          </xsl:element>
        >
	</xsl:element>
      </xsl:when>
    </xsl:choose>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="rng:grammar">
    <xvariable
        name="subtree"
        select="descendant::nma:data[
                $target='data' or $target='config' or
		$target='edit-config' or $target='get-reply'
		or $target='get-config-reply']
                |descendant::nma:rpcs[$target='rpc' or
                $target='rpc-reply']
                |descendant::nma:notifications[$target='notification']"/>
    <xsl:if test="$subtree/*">
      <xsl:element name="grammar" namespace="{$rng-uri}">
        <xsl:attribute name="ns">
          <xsl:value-of select="@ns"/>
        </xsl:attribute>
	<xsl:if test="$target='edit-config'">
	  <xsl:call-template name="include-grammar">
	    <xsl:with-param name="file-name"
			    select="concat($rng-lib,'/edit-config-attributes.rng')"/>
	  </xsl:call-template>
	</xsl:if>
        <xsl:if test="/rng:grammar/rng:define">
	  <xsl:call-template name="include-grammar">
	    <xsl:with-param name="file-name" select="concat($basename,'-gdefs.rng')"/>
	  </xsl:call-template>
        </xsl:if>
        <xsl:element name="start" namespace="{$rng-uri}">
          <xsl:apply-templates select="$subtree"/>
        </xsl:element>
        <xsl:apply-templates select="rng:define"/>
      </xsl:element>
    </xsl:ifose>
  </xsl:template>

  <xsl:template matcnma:data">
    <xsl:apply-templates select="rng:*"/ose>
  </xsl:template>

  <xsl:template matcnma:rpcs">
    <xsl:choose>
      <xsl:when test="$target='rpc'">
        <xsl:choose>
          <xsl:when test="count(nma:rpc)>1">
            <xsl:element name="choice" namespace="{$rng-uri}">
              <xsl:apply-templates
                  select="descendant::nma:input"/>
            </xsl:element>
          </xsl:when>
          <xsl:otherwise>
            <xsl:apply-templates
                select="descendant::nma:input"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>
      <xsl:otherwise>
        <xsl:choose>
          <xsl:when test="count(descendant::nma:output)>1">
            <xsl:element name="choice" namespace="{$rng-uri}">
              <xsl:apply-templates
                  select="descendant::nma:output"/>
            </xsl:element>
          </xsl:when>
          <xsl:otherwise>
            <xsl:apply-templates
                select="descendant::nma:output"/>
          </xsl:otherwise>
        </xsl:chooser"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template matcnma:notifications">
    <xsl:choose>
      <xsl:when test="count(nma:notification)>1">
        <xsl:element name="choice" namespace="{$rng-uri}">
          <xsl:apply-templates select="nma:notification"/>
        </xsl:element>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates select="nma:notificationmar"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template matcnma:input|nma:output">
    <xsl:choose>
      <xsl:when test="count(rng:*)>1">
        <xsl:element name="group" namespace="{$rng-uri}">
          <xsl:apply-templates/>
        </xsl:element>
      </xsl:when>
      <xsl:otherwise>
        >
	<xsl:apply-templates/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template matcnma:notification">
    <xsl:choose>
      <xsl:when test="count(rng:*)>1">
        <xsl:element name="interleave" namespace="{$rng-uri}">
          <xsl:apply-templates/>
        </xsl:element>
      </xsl:when>
      <xsl:otherwise>
        >
	<xsl:apply-templates/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="@nma:*|nma:*|a:*"/>

  <xsl:template match="@*">
    <xsl:copy/>
  </xsl:template>

  <xsl:template match="r*[@nma:config='false']">
    <xsl:choose>
      <xsl:when test="($target='get-config-reply' or $target='config'
		      or $target='edit-config')">
	<xsl:element name="empty" namespace="{$rng-uri}"/>
      </xsl:when>
      <xsl:otherwise>
	<xsl:copy>
	  <xsl:apply-templates select="@*|*|text()"/>
	</xsl:copyr"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template matcrng:*[@nma:if-feature]">
    <xsl:choose>
      <xsl:when test="$features-off=1">
	<xsl:element name="empty" namespace="{$rng-uri}"/>
      </xsl:when>
      <xsl:otherwise>
	<xsl:copy>
	  <xsl:apply-templates select="@*|*|text()"/>
	</xsl:copyr"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template matcrng:element">
    <xsl:choose>
      <xsl:when test="$target='edit-config'">
	<xsl:choose>
	  <xsl:when test="parent::rng:optional or
			  parent::rng:zeroOrMore or
			  contains(concat(../@nma:key,'
			  '),concat(@name,' '))">
	    <xsl:apply-templates select="." mode="edit"/>
	  </xsl:when>
	  <xsl:otherwise>
	    <xsl:element name="optional" namespace="{$rng-uri}">
	      <xsl:apply-templates select="." mode="edit"/>
	    </xsl:element>
	  </xsl:otherwise>
	</xsl:choose>
      </xsl:when>
      <xsl:otherwise>
	<xsl:call-template name="copy-and-continue"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
<commit_msg>DSDL: Fix oneOrMore/optional in edit-config schema.<commit_after><?xml version="1.0" encoding="utf-8"?>

<!-- Program name: gen-relaxng.xsl

Copyright © 2011 by <NAME>, CESNET <<EMAIL>>

Creates RELAX NG schema from the hybrid DSDL schema (see RFC 6110).

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:rng="http://relaxng.org/ns/structure/1.0"
                xmlns:nma="urn:ietf:params:xml:ns:netmod:dsdl-annotations:1"
                xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"                version="1.0">

  <xsl:output method="xml" encoding="utf-8"/>
  <xsl:strip-space elements="*"/>

  <xsl:include href="gen-common.xsl"/>

  <xsl:template name="ns-attribute">
    <xsl:attribute name="ns">
      <xsl:choose>
	<xsl:when test="$target='get-reply' or $target='config' or
			$target='edit-config' or
			$target='data' or $target='get-config-reply'
			or $target='rpc' or $target='rpc-reply'">
	  <xsl:text>urn:ietf:params:xml:ns:netconf:base:1.0</xsl:text>
	</xsl:when>
	<xsl:when test="$target='notification'">
	  <xsl:text>urn:ietf:params:xml:ns:netconf:notification:1.0</xsl:text>
	</xsl:when>
      </xsl:choose>
    </xsl:attribute>
  </xsl:template>

  <xsl:template name="grammar-choice">
    <xsl:choose>
      <xsl:when test="count(rng:grammar)>1">
        <xsl:element name="choice" namespace="{$rng-uri}">
          <xsl:apply-templates select="rng:grammar"/>
        </xsl:element>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates select="rng:grammar"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="inner-grammar">
    <xsl:param name="subtrees"/>
    <xsl:if test="$subtrees">
    </xsl:if>
  </xsl:template>

  <xsl:template name="include-grammar">
    <xsl:param name="file-name"/>
    <xsl:element name="include" namespace="{$rng-uri}">
      <xsl:attribute name="href">
	<xsl:value-of select="$file-name"/>
      </xsl:attribute>
    </xsl:element>
  </xsl:template>

  <xsl:template name="message-id">
    <xsl:element name="ref" namespace="{$rng-uri}">
      <xsl:attribute name="name">message-id-attribute</xsl:attribute>
    </xsl:element>
  </xsl:template>

  <xsl:template name="copy-and-continue">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates select="*|text()"/ose>
    </xsl:copy>
  </xsl:template  <xsl:template match="/">
    <xsl:call-template name="check-input-pars"/>
    <xsl:choose>
      <xsl:when test="$gdefs-only=1">
        <xsl:apply-templates select="rng:grammar" mode="        defs"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates select="rng:grammar"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="/rng:grammar" mode="gdefs">
    <xcopy>
      <xsl:attribute name="datatypeLibrary">
           <xsl:value-of select="@datatypeLibrary"/>
      </xsl:attribute>
      <xsl:apply-templates select="rng:define"/>
    </xcopyent>
  </xsl:template>

  <xsl:template match="/rng:grammar">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:call-template name="ns-attribute"/>
      <xcall-template name="include-grammar">
	<xsl:with-param name="file-name" select="concat($rng-lib,'/relaxng-lib.rng')"/>
      </xsl:call-templateent>
      <xsl:apply-templates select="rng:start"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="/rng:grammar/rng:start">
    <xsl:copy>
    <xsl:choose>
      <xsl:when test="$targetataply'">
        <xsl:element name="element" namespace="{$rng-uri}">
          <xsl:attribute name="namdata</xsl:attribute>
          <xsl:apply-templates
              select="rng:grammar[descendant::nma:data]"/ent>
        </xsl:element>
      </xsl:when>
      <xsl:when test="$targeconfigply'">
        <xsl:element name="element" namespace="{$rng-uri}">
          <xsl:attribute name="namconfig</xsl:attribute>
          <xsl:apply-templates
              select="rng:grammar[descendant::nma:data]"/ent>
        </xsl:element>
      </xsl:when>
      <xsl:when test="$targeget-reply' or
                      $target='get-config-reply'">
	<xsl:element name="element" namespace="{$rng-uri}">
	  <xsl:attribute name="name">rpc-reply</xsl:attribute>
	  <xsl:call-template name="message-id"/>
	  <xsl:element name="element" namespace="{$rng-uri}">
	    <xsl:attribute name="name">data</xsl:attribute>
	    <xsl:element name="interleave" namespace="{$rng-uri}">
	      <xsl:apply-templates
		  select="rng:grammar[descendant::nma:data]"/>
	    </xsl:element>
	  </xsl:element>
	</xsl:elementent>
      </xsl:when>
      <xsl:when test="$targeedit-config'">
	<xsl:element name="element" namespace="{$rng-uri}">
	  <xsl:attribute name="name">rpc</xsl:attribute>
	  <xsl:call-template name="message-id"/>
	  <xsl:element name="element" namespace="{$rng-uri}">
	    <xsl:attribute name="name">edit-config</xsl:attribute>
	    <xsl:element name="ref" namespace="{$rng-uri}">
	      <xsl:attribute name="name">edit-config-parameters</xsl:attribute>
	    </xsl:element>
	    <xsl:element name="element" namespace="{$rng-uri}">
	      <xsl:attribute name="name">config</xsl:attribute>
	      <xsl:element name="interleave" namespace="{$rng-uri}">
		<xsl:apply-templates
		    select="rng:grammar[descendant::nma:data]"/>
	      </xsl:element>
	    </xsl:element>
	  </xsl:element>
	   </xsl:element>
      </xsl:when>
      <xsl:when test="$targerpcply'">
        <xsl:element name="element" namespace="{$rng-uri}">
          <xsl:attribute name="name">ply</xsl:attribute>
          <xsl:call-template name="message-id"/>
          <xsl:element namchoice" namespace="{$rng-uri}">
            <xsl:apply-templates
                select="rng:grammar[descendant::nma:rpcs]"/>
        >
	  </xsl:element>
        </xsl:element>
      </xsl:when>
      <xsl:when test="$target='rpc-reply'">
        <xsl:element name="element" namespace="{$rng-uri}">
          <xsl:attribute name="name">rpc-reply</xsl:attribute>
          <xsl:call-template name="message-id"          <xsl:element name="choice" namespace="{$rng-uri}">
            <xsl:if test="descendant::nma:rpc[not(nma:output)]">
              <xsl:element name="ref" namespace="{$rng-uri}">
                <xsl:attribute name="name">ok-element</xsl:attribute>
              </xsl:element>
            </xsl:if>
            <xsl:apply-templates
                select="rng:grammar[descendant::nma:output]"/>
        >
	  </xsl:element>
        </xsl:element>
      </xsl:when>
      <xsl:when test="$targenotificationply'">
        <xsl:element name="element" namespace="{$rng-uri}">
          <xsl:attribute name="name">notification</xsl:attribute>
          <xsl:element name="ref" namespace="{$rng-uri}">
            <xsl:attribute name="name">eventTime-element</xsl:attribute>
          </xsl:elemen          <xsl:element name="choice" namespace="{$rng-uri}">
            <xsl:apply-templates
                select="rng:grammar[descendant::nma:notification]"/>
          </xsl:element>
        >
	</xsl:element>
      </xsl:when>
    </xsl:choose>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="rng:grammar">
    <xvariable
        name="subtree"
        select="descendant::nma:data[
                $target='data' or $target='config' or
		$target='edit-config' or $target='get-reply'
		or $target='get-config-reply']
                |descendant::nma:rpcs[$target='rpc' or
                $target='rpc-reply']
                |descendant::nma:notifications[$target='notification']"/>
    <xsl:if test="$subtree/*">
      <xsl:element name="grammar" namespace="{$rng-uri}">
        <xsl:attribute name="ns">
          <xsl:value-of select="@ns"/>
        </xsl:attribute>
	<xsl:if test="$target='edit-config'">
	  <xsl:call-template name="include-grammar">
	    <xsl:with-param name="file-name"
			    select="concat($rng-lib,'/edit-config-attributes.rng')"/>
	  </xsl:call-template>
	</xsl:if>
        <xsl:if test="/rng:grammar/rng:define">
	  <xsl:call-template name="include-grammar">
	    <xsl:with-param name="file-name" select="concat($basename,'-gdefs.rng')"/>
	  </xsl:call-template>
        </xsl:if>
        <xsl:element name="start" namespace="{$rng-uri}">
          <xsl:apply-templates select="$subtree"/>
        </xsl:element>
        <xsl:apply-templates select="rng:define"/>
      </xsl:element>
    </xsl:ifose>
  </xsl:template>

  <xsl:template matcnma:data">
    <xsl:apply-templates select="rng:*"/ose>
  </xsl:template>

  <xsl:template matcnma:rpcs">
    <xsl:choose>
      <xsl:when test="$target='rpc'">
        <xsl:choose>
          <xsl:when test="count(nma:rpc)>1">
            <xsl:element name="choice" namespace="{$rng-uri}">
              <xsl:apply-templates
                  select="descendant::nma:input"/>
            </xsl:element>
          </xsl:when>
          <xsl:otherwise>
            <xsl:apply-templates
                select="descendant::nma:input"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>
      <xsl:otherwise>
        <xsl:choose>
          <xsl:when test="count(descendant::nma:output)>1">
            <xsl:element name="choice" namespace="{$rng-uri}">
              <xsl:apply-templates
                  select="descendant::nma:output"/>
            </xsl:element>
          </xsl:when>
          <xsl:otherwise>
            <xsl:apply-templates
                select="descendant::nma:output"/>
          </xsl:otherwise>
        </xsl:chooser"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template matcnma:notifications">
    <xsl:choose>
      <xsl:when test="count(nma:notification)>1">
        <xsl:element name="choice" namespace="{$rng-uri}">
          <xsl:apply-templates select="nma:notification"/>
        </xsl:element>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates select="nma:notificationmar"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template matcnma:input|nma:output">
    <xsl:choose>
      <xsl:when test="count(rng:*)>1">
        <xsl:element name="group" namespace="{$rng-uri}">
          <xsl:apply-templates/>
        </xsl:element>
      </xsl:when>
      <xsl:otherwise>
        >
	<xsl:apply-templates/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template matcnma:notification">
    <xsl:choose>
      <xsl:when test="count(rng:*)>1">
        <xsl:element name="interleave" namespace="{$rng-uri}">
          <xsl:apply-templates/>
        </xsl:element>
      </xsl:when>
      <xsl:otherwise>
        >
	<xsl:apply-templates/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="@nma:*|nma:*|a:*"/>

  <xsl:template match="@*">
    <xsl:copy/>
  </xsl:template>

  <xsl:template match="r*[@nma:config='false']">
    <xsl:choose>
      <xsl:when test="($target='get-config-reply' or $target='config'
		      or $target='edit-config')">
	<xsl:element name="empty" namespace="{$rng-uri}"/>
      </xsl:when>
      <xsl:otherwise>
	<xsl:copy>
	  <xsl:apply-templates select="@*|*|text()"/>
	</xsl:copyr"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template matcrng:*[@nma:if-feature]">
    <xsl:choose>
      <xsl:when test="$features-off=1">
	<xsl:element name="empty" namespace="{$rng-uri}"/>
      </xsl:when>
      <xsl:otherwise>
	<xsl:copy>
	  <xsl:apply-templates select="@*|*|text()"/>
	</xsl:copyr"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template matcrng:oneOrMore">
    <xsl:choose>
      <xsl:when test="$target='edit-config'">
	<xsl:element name="rng:zeroOrMore">
	  <xsl:apply-templates select="@*"/>
	  <xsl:apply-templates/>
	</xsl:element>
      </xsl:when>
      <xsl:otherwise>
	<xsl:call-template name="copy-and-continue"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="rng:element">
    <xsl:choose>
      <xsl:when test="$target='edit-config'">
	<xsl:choose>
	  <xsl:when test="parent::rng:optional or
			  parent::rng:zeroOrMore or
			  parent::rng:oneOrMore or
			  contains(concat(../@nma:key,'
			  '),concat(@name,' '))">
	    <xsl:apply-templates select="." mode="edit"/>
	  </xsl:when>
	  <xsl:otherwise>
	    <xsl:element name="optional" namespace="{$rng-uri}">
	      <xsl:apply-templates select="." mode="edit"/>
	    </xsl:element>
	  </xsl:otherwise>
	</xsl:choose>
      </xsl:when>
      <xsl:otherwise>
	<xsl:call-template name="copy-and-continue"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

{'fraction_non_alphanumeric': 0.18794653145886148, 'fraction_numerical': 0.0027656141968195437, 'mean_word_length': 3.080721003134796, 'pattern_counts': {'":': 0, '<': 660, '<?xml version=': 2, '>': 672, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 18}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1738052', 'n_tokens_mistral': 9633, 'n_tokens_neox': 8518, 'n_words': 1357}