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

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

Copyright © 2012 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:variable name="gdefs-file">
    <xsl:value-of select="concat($basename,'-gdefs')"/>
    <xsl:choose>
      <xsl:when test="$target='get-config-reply' or $target='config'">
	<xsl:text>-config</xsl:text>
      </xsl:when>
      <xsl:when test="$target='edit-config'">
	<xsl:text>-edit</xsl:text>
      </xsl:when>
    </xsl:choose>
    <xsl:text>.rng</xsl:text>
  </xsl:variable>

  <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="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="rng:*|text()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="/">
    <xsl:choose>
      <xsl:when test="$gdefs-only=1">
        <xsl:apply-templates select="rng:grammar" mode="gdefs"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="check-input-pars"/>
        <xsl:apply-templates select="rng:grammar"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

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

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

  <xsl:template match="/rng:grammar/rng:start">
    <xsl:copy>
      <xsl:choose>
	<xsl:when test="$target='data'">
	  <xsl:element name="element" namespace="{$rng-uri}">
	    <xsl:attribute name="name">data</xsl:attribute>
	    <xsl:apply-templates
		select="rng:grammar[descendant::nma:data]"/>
	  </xsl:element>
	</xsl:when>
	<xsl:when test="$target='config'">
	  <xsl:element name="element" namespace="{$rng-uri}">
	    <xsl:attribute name="name">config</xsl:attribute>
	    <xsl:apply-templates
		select="rng:grammar[descendant::nma:data]"/>
	  </xsl:element>
	</xsl:when>
	<xsl:when test="$target='get-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:element>
	</xsl:when>
	<xsl:when test="$target='edit-config'">
	  <xsl:element name="element" namespace="{$rng-uri}"><commit_msg>RNG: Real fix of issue 66.<commit_after><?xml version="1.0" encoding="utf-8"?>

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

Copyright © 2012 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:variable name="gdefs-file">
    <xsl:value-of select="concat($basename,'-gdefs')"/>
    <xsl:choose>
      <xsl:when test="$target='get-config-reply' or $target='config'">
	<xsl:text>-config</xsl:text>
      </xsl:when>
      <xsl:when test="$target='edit-config'">
	<xsl:text>-edit</xsl:text>
      </xsl:when>
    </xsl:choose>
    <xsl:text>.rng</xsl:text>
  </xsl:variable>

  <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="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="rng:*|text()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="/">
    <xsl:choose>
      <xsl:when test="$gdefs-only=1">
        <xsl:apply-templates select="rng:grammar" mode="gdefs"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="check-input-pars"/>
        <xsl:apply-templates select="rng:grammar"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

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

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

  <xsl:template match="/rng:grammar/rng:start">
    <xsl:copy>
      <xsl:choose>
	<xsl:when test="$target='data'">
	  <xsl:element name="element" namespace="{$rng-uri}">
	    <xsl:attribute name="name">data</xsl:attribute>
	    <xsl:apply-templates
		select="rng:grammar[descendant::nma:data]"/>
	  </xsl:element>
	</xsl:when>
	<xsl:when test="$target='config'">
	  <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:when>
	<xsl:when test="$target='get-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:element>
	</xsl:when>
	<xsl:when test="$target='edit-config'">
	  <xsl:element name="element" namespace="{$rng-uri}">
{'fraction_non_alphanumeric': 0.18085006125718595, 'fraction_numerical': 0.005654509471303365, 'mean_word_length': 3.636085626911315, 'pattern_counts': {'":': 0, '<': 245, '<?xml version=': 2, '>': 245, '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': '5963414', 'n_tokens_mistral': 3919, 'n_tokens_neox': 3465, 'n_words': 668}