From 3bb2b1f0770922fb2e0c8cc118ffe317f8f030c3 Mon Sep 17 00:00:00 2001
From: Ladislav Lhotka <lhotka@nic.cz>
Date: Tue, 23 Aug 2016 17:25:06 +0200
Subject: [PATCH] Fix XSLT stylesheets.

---
 tools/xslt/canonicalize.xsl | 1290 ++++++++++++++++++-----------------
 tools/xslt/yin2yang.xsl     |  992 +++++++++++++--------------
 2 files changed, 1147 insertions(+), 1135 deletions(-)

diff --git a/tools/xslt/canonicalize.xsl b/tools/xslt/canonicalize.xsl
index 83db2f1..7a680e9 100644
--- a/tools/xslt/canonicalize.xsl
+++ b/tools/xslt/canonicalize.xsl
@@ -18,659 +18,671 @@ 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"
+<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform"
 		xmlns:xi="http://www.w3.org/2001/XInclude"
 		xmlns:html="http://www.w3.org/1999/xhtml"
 		xmlns:yin="urn:ietf:params:xml:ns:yang:yin:1"
 		version="1.0">
-  <xsl:output method="xml" encoding="utf-8"/>
-  <xsl:strip-space elements="*"/>
-  <xsl:template name="preceding-comment">
-    <xsl:if
+  <output method="xml" encoding="utf-8"/>
+  <strip-space elements="*"/>
+  <template name="preceding-comment">
+    <if
 	test="count((preceding-sibling::*|preceding-sibling::comment())
 	      [last()]|preceding-sibling::comment()[1]) = 1">
-      <xsl:apply-templates select="preceding-sibling::comment()[1]"/>
-    </xsl:if>
-  </xsl:template>
-  <xsl:template match="html:*|xi:*|@*|comment()|text()">
-    <xsl:copy-of select="."/>
-  </xsl:template>
-  <xsl:template name="data-def-stmt">
-    <xsl:apply-templates
+      <apply-templates select="preceding-sibling::comment()[1]"/>
+    </if>
+  </template>
+  <template match="html:*|xi:*|@*|comment()|text()">
+    <copy-of select="."/>
+  </template>
+  <template name="data-def-stmt">
+    <apply-templates
 	select="yin:container|yin:leaf|yin:leaf-list|
 		yin:list|yin:choice|yin:anyxml|yin:uses"/>
-  </xsl:template>
+  </template>
 
-  <xsl:template match="yin:module">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:yang-version"/>
-      <xsl:apply-templates select="yin:namespace"/>
-      <xsl:apply-templates select="yin:prefix"/>
-      <xsl:apply-templates select="yin:import"/>
-      <xsl:apply-templates select="yin:include"/>
-      <xsl:apply-templates select="yin:organization"/>
-      <xsl:apply-templates select="yin:contact"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-      <xsl:apply-templates select="yin:revision"/>
-      <xsl:apply-templates
+  <template match="yin:module">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:yang-version"/>
+      <apply-templates select="yin:namespace"/>
+      <apply-templates select="yin:prefix"/>
+      <apply-templates select="yin:import"/>
+      <apply-templates select="yin:include"/>
+      <apply-templates select="yin:organization"/>
+      <apply-templates select="yin:contact"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+      <apply-templates select="yin:revision"/>
+      <apply-templates
 	  select="yin:extension|yin:feature|yin:identity|yin:typedef|
 		  yin:grouping|yin:container|yin:leaf|yin:leaf-list|
 		  yin:list|yin:choice|yin:anyxml|yin:uses|yin:augment|
 		  yin:rpc|yin:notification|yin:deviation"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:submodule">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:yang-version"/>
-      <xsl:apply-templates select="yin:belongs-to"/>
-      <xsl:apply-templates select="yin:import"/>
-      <xsl:apply-templates select="yin:include"/>
-      <xsl:apply-templates select="yin:organization"/>
-      <xsl:apply-templates select="yin:contact"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-      <xsl:apply-templates select="yin:revision"/>
-      <xsl:apply-templates
+    </copy>
+  </template>
+  <template match="yin:submodule">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:yang-version"/>
+      <apply-templates select="yin:belongs-to"/>
+      <apply-templates select="yin:import"/>
+      <apply-templates select="yin:include"/>
+      <apply-templates select="yin:organization"/>
+      <apply-templates select="yin:contact"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+      <apply-templates select="yin:revision"/>
+      <apply-templates
 	  select="yin:extension|yin:feature|yin:identity|yin:typedef|
 		  yin:grouping|yin:container|yin:leaf|yin:leaf-list|
 		  yin:list|yin:choice|yin:anyxml|yin:uses|yin:augment|
 		  yin:rpc|yin:notification|yin:deviation"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:feature">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:if-feature"/>
-      <xsl:apply-templates select="yin:status"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:if-feature">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:identity">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:base"/>
-      <xsl:apply-templates select="yin:status"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:base">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:yang-version">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:import">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:prefix"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:include">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:namespace">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:prefix">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:belongs-to">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:prefix"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:organization">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:text"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:text">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:contact">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:text"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:description">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:text"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:reference">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:text"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:units">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:revision">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:extension">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:argument"/>
-      <xsl:apply-templates select="yin:status"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:argument">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:yin-element"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:yin-element">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:typedef">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:type"/>
-      <xsl:apply-templates select="yin:units"/>
-      <xsl:apply-templates select="yin:default"/>
-      <xsl:apply-templates select="yin:status"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:type">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:fraction-digits"/>
-      <xsl:apply-templates select="yin:range"/>
-      <xsl:apply-templates select="yin:length"/>
-      <xsl:apply-templates select="yin:pattern"/>
-      <xsl:apply-templates select="yin:enum"/>
-      <xsl:apply-templates select="yin:bit"/>
-      <xsl:apply-templates select="yin:path"/>
-      <xsl:apply-templates select="yin:base"/>
-      <xsl:apply-templates select="yin:type"/>
-      <xsl:apply-templates select="yin:require-instance"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:fraction-digits">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:range">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:error-message"/>
-      <xsl:apply-templates select="yin:error-app-tag"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:length">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:error-message"/>
-      <xsl:apply-templates select="yin:error-app-tag"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:pattern">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:error-message"/>
-      <xsl:apply-templates select="yin:error-app-tag"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:default">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:enum">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:value"/>
-      <xsl:apply-templates select="yin:status"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:bit">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:position"/>
-      <xsl:apply-templates select="yin:status"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:position">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:path">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:require-instance">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:status">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:config">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:mandatory">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:presence">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:ordered-by">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:must">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:error-message"/>
-      <xsl:apply-templates select="yin:error-app-tag"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:error-message">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:value"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:value">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:error-app-tag">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:min-elements">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:max-elements">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:value">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:grouping">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:status"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-      <xsl:apply-templates select="yin:typedef"/>
-      <xsl:apply-templates select="yin:grouping"/>
-      <xsl:call-template name="data-def-stmt"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:container">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:when"/>
-      <xsl:apply-templates select="yin:if-feature"/>
-      <xsl:apply-templates select="yin:must"/>
-      <xsl:apply-templates select="yin:presence"/>
-      <xsl:apply-templates select="yin:config"/>
-      <xsl:apply-templates select="yin:status"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-      <xsl:apply-templates select="yin:typedef"/>
-      <xsl:apply-templates select="yin:grouping"/>
-      <xsl:call-template name="data-def-stmt"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:leaf">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:when"/>
-      <xsl:apply-templates select="yin:if-feature"/>
-      <xsl:apply-templates select="yin:type"/>
-      <xsl:apply-templates select="yin:units"/>
-      <xsl:apply-templates select="yin:must"/>
-      <xsl:apply-templates select="yin:default"/>
-      <xsl:apply-templates select="yin:config"/>
-      <xsl:apply-templates select="yin:mandatory"/>
-      <xsl:apply-templates select="yin:status"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:leaf-list">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:when"/>
-      <xsl:apply-templates select="yin:if-feature"/>
-      <xsl:apply-templates select="yin:type"/>
-      <xsl:apply-templates select="yin:units"/>
-      <xsl:apply-templates select="yin:must"/>
-      <xsl:apply-templates select="yin:config"/>
-      <xsl:apply-templates select="yin:min-elements"/>
-      <xsl:apply-templates select="yin:max-elements"/>
-      <xsl:apply-templates select="yin:ordered-by"/>
-      <xsl:apply-templates select="yin:status"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:list">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:when"/>
-      <xsl:apply-templates select="yin:if-feature"/>
-      <xsl:apply-templates select="yin:must"/>
-      <xsl:apply-templates select="yin:key"/>
-      <xsl:apply-templates select="yin:unique"/>
-      <xsl:apply-templates select="yin:config"/>
-      <xsl:apply-templates select="yin:min-elements"/>
-      <xsl:apply-templates select="yin:max-elements"/>
-      <xsl:apply-templates select="yin:ordered-by"/>
-      <xsl:apply-templates select="yin:status"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-      <xsl:apply-templates select="yin:typedef"/>
-      <xsl:apply-templates select="yin:grouping"/>
-      <xsl:call-template name="data-def-stmt"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:key">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:unique">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:choice">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:when"/>
-      <xsl:apply-templates select="yin:if-feature"/>
-      <xsl:apply-templates select="yin:default"/>
-      <xsl:apply-templates select="yin:config"/>
-      <xsl:apply-templates select="yin:mandatory"/>
-      <xsl:apply-templates select="yin:status"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-      <xsl:apply-templates select="yin:container"/>
-      <xsl:apply-templates select="yin:leaf"/>
-      <xsl:apply-templates select="yin:leaf-list"/>
-      <xsl:apply-templates select="yin:list"/>
-      <xsl:apply-templates select="yin:anyxml"/>
-      <xsl:apply-templates select="yin:case"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:case">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:when"/>
-      <xsl:apply-templates select="yin:if-feature"/>
-      <xsl:apply-templates select="yin:status"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-      <xsl:call-template name="data-def-stmt"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:anyxml">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:when"/>
-      <xsl:apply-templates select="yin:if-feature"/>
-      <xsl:apply-templates select="yin:must"/>
-      <xsl:apply-templates select="yin:config"/>
-      <xsl:apply-templates select="yin:mandatory"/>
-      <xsl:apply-templates select="yin:status"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:uses">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:when"/>
-      <xsl:apply-templates select="yin:if-feature"/>
-      <xsl:apply-templates select="yin:status"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-      <xsl:apply-templates select="yin:refine"/>
-      <xsl:apply-templates select="yin:augment"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:refine">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:must"/>
-      <xsl:apply-templates select="yin:presence"/>
-      <xsl:apply-templates select="yin:default"/>
-      <xsl:apply-templates select="yin:config"/>
-      <xsl:apply-templates select="yin:mandatory"/>
-      <xsl:apply-templates select="yin:min-elements"/>
-      <xsl:apply-templates select="yin:max-elements"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:augment">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:when"/>
-      <xsl:apply-templates select="yin:if-feature"/>
-      <xsl:apply-templates select="yin:status"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-      <xsl:call-template name="data-def-stmt"/>
-      <xsl:apply-templates select="yin:case"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:when">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:rpc">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:if-feature"/>
-      <xsl:apply-templates select="yin:status"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-      <xsl:apply-templates select="yin:typedef"/>
-      <xsl:apply-templates select="yin:grouping"/>
-      <xsl:apply-templates select="yin:input"/>
-      <xsl:apply-templates select="yin:output"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:input">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:typedef"/>
-      <xsl:apply-templates select="yin:grouping"/>
-      <xsl:call-template name="data-def-stmt"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:output">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:typedef"/>
-      <xsl:apply-templates select="yin:grouping"/>
-      <xsl:call-template name="data-def-stmt"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:notification">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:if-feature"/>
-      <xsl:apply-templates select="yin:status"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-      <xsl:apply-templates select="yin:typedef"/>
-      <xsl:apply-templates select="yin:grouping"/>
-      <xsl:call-template name="data-def-stmt"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:deviation">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:description"/>
-      <xsl:apply-templates select="yin:reference"/>
-      <xsl:apply-templates select="yin:deviate"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="yin:deviate">
-    <xsl:call-template name="preceding-comment"/>
-    <xsl:copy>
-      <xsl:apply-templates select="html:*|xi:*|@*|text()"/>
-      <xsl:apply-templates select="yin:type"/>
-      <xsl:apply-templates select="yin:units"/>
-      <xsl:apply-templates select="yin:must"/>
-      <xsl:apply-templates select="yin:unique"/>
-      <xsl:apply-templates select="yin:default"/>
-      <xsl:apply-templates select="yin:config"/>
-      <xsl:apply-templates select="yin:mandatory"/>
-      <xsl:apply-templates select="yin:min-elements"/>
-      <xsl:apply-templates select="yin:max-elements"/>
-    </xsl:copy>
-  </xsl:template>
-  <xsl:template match="/">
-    <xsl:apply-templates select="yin:module"/>
-    <xsl:apply-templates select="yin:submodule"/>
-  </xsl:template>
-</xsl:stylesheet>
+    </copy>
+  </template>
+  <template match="yin:feature">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:if-feature"/>
+      <apply-templates select="yin:status"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+    </copy>
+  </template>
+  <template match="yin:if-feature">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:identity">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:base"/>
+      <apply-templates select="yin:status"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+    </copy>
+  </template>
+  <template match="yin:base">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:yang-version">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:import">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:prefix"/>
+      <apply-templates select="yin:revision-date"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+    </copy>
+  </template>
+  <template match="yin:revision-date">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:include">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:revision-date"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+    </copy>
+  </template>
+  <template match="yin:namespace">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:prefix">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:belongs-to">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:prefix"/>
+    </copy>
+  </template>
+  <template match="yin:organization">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:text"/>
+    </copy>
+  </template>
+  <template match="yin:text">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:contact">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:text"/>
+    </copy>
+  </template>
+  <template match="yin:description">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:text"/>
+    </copy>
+  </template>
+  <template match="yin:reference">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:text"/>
+    </copy>
+  </template>
+  <template match="yin:units">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:revision">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+    </copy>
+  </template>
+  <template match="yin:extension">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:argument"/>
+      <apply-templates select="yin:status"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+    </copy>
+  </template>
+  <template match="yin:argument">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:yin-element"/>
+    </copy>
+  </template>
+  <template match="yin:yin-element">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:typedef">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:type"/>
+      <apply-templates select="yin:units"/>
+      <apply-templates select="yin:default"/>
+      <apply-templates select="yin:status"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+    </copy>
+  </template>
+  <template match="yin:type">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:fraction-digits"/>
+      <apply-templates select="yin:range"/>
+      <apply-templates select="yin:length"/>
+      <apply-templates select="yin:pattern"/>
+      <apply-templates select="yin:enum"/>
+      <apply-templates select="yin:bit"/>
+      <apply-templates select="yin:path"/>
+      <apply-templates select="yin:base"/>
+      <apply-templates select="yin:type"/>
+      <apply-templates select="yin:require-instance"/>
+    </copy>
+  </template>
+  <template match="yin:fraction-digits">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:range">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:error-message"/>
+      <apply-templates select="yin:error-app-tag"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+    </copy>
+  </template>
+  <template match="yin:length">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:error-message"/>
+      <apply-templates select="yin:error-app-tag"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+    </copy>
+  </template>
+  <template match="yin:pattern">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:error-message"/>
+      <apply-templates select="yin:error-app-tag"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+    </copy>
+  </template>
+  <template match="yin:default">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:enum">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:value"/>
+      <apply-templates select="yin:status"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+    </copy>
+  </template>
+  <template match="yin:bit">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:position"/>
+      <apply-templates select="yin:status"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+    </copy>
+  </template>
+  <template match="yin:position">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:path">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:require-instance">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:status">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:config">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:mandatory">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:presence">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:ordered-by">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:must">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:error-message"/>
+      <apply-templates select="yin:error-app-tag"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+    </copy>
+  </template>
+  <template match="yin:error-message">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:value"/>
+    </copy>
+  </template>
+  <template match="yin:value">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:error-app-tag">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:min-elements">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:max-elements">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:value">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:grouping">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:status"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+      <apply-templates select="yin:typedef"/>
+      <apply-templates select="yin:grouping"/>
+      <call-template name="data-def-stmt"/>
+    </copy>
+  </template>
+  <template match="yin:container">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:when"/>
+      <apply-templates select="yin:if-feature"/>
+      <apply-templates select="yin:must"/>
+      <apply-templates select="yin:presence"/>
+      <apply-templates select="yin:config"/>
+      <apply-templates select="yin:status"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+      <apply-templates select="yin:typedef"/>
+      <apply-templates select="yin:grouping"/>
+      <call-template name="data-def-stmt"/>
+    </copy>
+  </template>
+  <template match="yin:leaf">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:when"/>
+      <apply-templates select="yin:if-feature"/>
+      <apply-templates select="yin:type"/>
+      <apply-templates select="yin:units"/>
+      <apply-templates select="yin:must"/>
+      <apply-templates select="yin:default"/>
+      <apply-templates select="yin:config"/>
+      <apply-templates select="yin:mandatory"/>
+      <apply-templates select="yin:status"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+    </copy>
+  </template>
+  <template match="yin:leaf-list">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:when"/>
+      <apply-templates select="yin:if-feature"/>
+      <apply-templates select="yin:type"/>
+      <apply-templates select="yin:units"/>
+      <apply-templates select="yin:must"/>
+      <apply-templates select="yin:config"/>
+      <apply-templates select="yin:min-elements"/>
+      <apply-templates select="yin:max-elements"/>
+      <apply-templates select="yin:ordered-by"/>
+      <apply-templates select="yin:status"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+    </copy>
+  </template>
+  <template match="yin:list">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:when"/>
+      <apply-templates select="yin:if-feature"/>
+      <apply-templates select="yin:must"/>
+      <apply-templates select="yin:key"/>
+      <apply-templates select="yin:unique"/>
+      <apply-templates select="yin:config"/>
+      <apply-templates select="yin:min-elements"/>
+      <apply-templates select="yin:max-elements"/>
+      <apply-templates select="yin:ordered-by"/>
+      <apply-templates select="yin:status"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+      <apply-templates select="yin:typedef"/>
+      <apply-templates select="yin:grouping"/>
+      <call-template name="data-def-stmt"/>
+    </copy>
+  </template>
+  <template match="yin:key">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:unique">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+    </copy>
+  </template>
+  <template match="yin:choice">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:when"/>
+      <apply-templates select="yin:if-feature"/>
+      <apply-templates select="yin:default"/>
+      <apply-templates select="yin:config"/>
+      <apply-templates select="yin:mandatory"/>
+      <apply-templates select="yin:status"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+      <apply-templates select="yin:container"/>
+      <apply-templates select="yin:leaf"/>
+      <apply-templates select="yin:leaf-list"/>
+      <apply-templates select="yin:list"/>
+      <apply-templates select="yin:anyxml"/>
+      <apply-templates select="yin:case"/>
+    </copy>
+  </template>
+  <template match="yin:case">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:when"/>
+      <apply-templates select="yin:if-feature"/>
+      <apply-templates select="yin:status"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+      <call-template name="data-def-stmt"/>
+    </copy>
+  </template>
+  <template match="yin:anyxml">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:when"/>
+      <apply-templates select="yin:if-feature"/>
+      <apply-templates select="yin:must"/>
+      <apply-templates select="yin:config"/>
+      <apply-templates select="yin:mandatory"/>
+      <apply-templates select="yin:status"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+    </copy>
+  </template>
+  <template match="yin:uses">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:when"/>
+      <apply-templates select="yin:if-feature"/>
+      <apply-templates select="yin:status"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+      <apply-templates select="yin:refine"/>
+      <apply-templates select="yin:augment"/>
+    </copy>
+  </template>
+  <template match="yin:refine">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:must"/>
+      <apply-templates select="yin:presence"/>
+      <apply-templates select="yin:default"/>
+      <apply-templates select="yin:config"/>
+      <apply-templates select="yin:mandatory"/>
+      <apply-templates select="yin:min-elements"/>
+      <apply-templates select="yin:max-elements"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+    </copy>
+  </template>
+  <template match="yin:augment">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:when"/>
+      <apply-templates select="yin:if-feature"/>
+      <apply-templates select="yin:status"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+      <call-template name="data-def-stmt"/>
+      <apply-templates select="yin:case"/>
+    </copy>
+  </template>
+  <template match="yin:when">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+    </copy>
+  </template>
+  <template match="yin:rpc">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:if-feature"/>
+      <apply-templates select="yin:status"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+      <apply-templates select="yin:typedef"/>
+      <apply-templates select="yin:grouping"/>
+      <apply-templates select="yin:input"/>
+      <apply-templates select="yin:output"/>
+    </copy>
+  </template>
+  <template match="yin:input">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:typedef"/>
+      <apply-templates select="yin:grouping"/>
+      <call-template name="data-def-stmt"/>
+    </copy>
+  </template>
+  <template match="yin:output">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:typedef"/>
+      <apply-templates select="yin:grouping"/>
+      <call-template name="data-def-stmt"/>
+    </copy>
+  </template>
+  <template match="yin:notification">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:if-feature"/>
+      <apply-templates select="yin:status"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+      <apply-templates select="yin:typedef"/>
+      <apply-templates select="yin:grouping"/>
+      <call-template name="data-def-stmt"/>
+    </copy>
+  </template>
+  <template match="yin:deviation">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:description"/>
+      <apply-templates select="yin:reference"/>
+      <apply-templates select="yin:deviate"/>
+    </copy>
+  </template>
+  <template match="yin:deviate">
+    <call-template name="preceding-comment"/>
+    <copy>
+      <apply-templates select="html:*|xi:*|@*|text()"/>
+      <apply-templates select="yin:type"/>
+      <apply-templates select="yin:units"/>
+      <apply-templates select="yin:must"/>
+      <apply-templates select="yin:unique"/>
+      <apply-templates select="yin:default"/>
+      <apply-templates select="yin:config"/>
+      <apply-templates select="yin:mandatory"/>
+      <apply-templates select="yin:min-elements"/>
+      <apply-templates select="yin:max-elements"/>
+    </copy>
+  </template>
+  <template match="/">
+    <apply-templates select="yin:module"/>
+    <apply-templates select="yin:submodule"/>
+  </template>
+</stylesheet>
diff --git a/tools/xslt/yin2yang.xsl b/tools/xslt/yin2yang.xsl
index 9c65bf2..1203000 100644
--- a/tools/xslt/yin2yang.xsl
+++ b/tools/xslt/yin2yang.xsl
@@ -44,552 +44,552 @@ 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"
+<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform"
 		xmlns:yin="urn:ietf:params:xml:ns:yang:yin:1"
 		xmlns:html="http://www.w3.org/1999/xhtml"
 		version="1.0">
-  <xsl:output method="text"/>
-  <xsl:strip-space elements="*"/>
+  <output method="text"/>
+  <strip-space elements="*"/>
 
   <!-- The 'date' parameter, if set, overrides the value of the
        first 'revision' statement. -->
-  <xsl:param name="date"/>
+  <param name="date"/>
   <!-- Amount of indentation added for each YANG hierarchy level. -->
-  <xsl:param name="indent-step" select="2"/>
+  <param name="indent-step" select="2"/>
   <!-- Maximum line length -->
-  <xsl:param name="line-length" select="70"/>
+  <param name="line-length" select="70"/>
   <!-- Marks for unordered list items at different levels of
        embedding -->
-  <xsl:param name="list-bullets" select="'-*o+'"/>
-
-  <xsl:variable name="unit-indent">
-    <xsl:call-template name="repeat-string">
-      <xsl:with-param name="count" select="$indent-step"/>
-      <xsl:with-param name="string" select="' '"/>
-    </xsl:call-template>
-  </xsl:variable>
-
-  <xsl:template name="repeat-string">
-    <xsl:param name="count"/>
-    <xsl:param name="string"/>
-    <xsl:choose>
-      <xsl:when test="not($count) or not($string)"/>
-      <xsl:when test="$count = 1">
-	<xsl:value-of select="$string"/>
-      </xsl:when>
-      <xsl:otherwise>
-	<xsl:if test="$count mod 2">
-	  <xsl:value-of select="$string"/>
-	</xsl:if>
-	<xsl:call-template name="repeat-string">
-	  <xsl:with-param name="count" select="floor($count div 2)"/>
-	  <xsl:with-param name="string" select="concat($string,$string)"/>
-	</xsl:call-template> 
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:template>
-
-  <xsl:template name="indent">
-    <xsl:param name="level" select="count(ancestor::*)"/>
-    <xsl:call-template name="repeat-string">
-      <xsl:with-param name="count" select="$level"/>
-      <xsl:with-param name="string" select="$unit-indent"/>
-    </xsl:call-template>
-  </xsl:template>
-
-  <xsl:template name="fill-text">
-    <xsl:param name="text"/>
-    <xsl:param name="length"/>
-    <xsl:param name="remains" select="$length"/>
-    <xsl:param name="prefix"/>
-    <xsl:param name="wdelim" select="' '"/>
-    <xsl:param name="break" select="'&#xA;'"/>
-    <xsl:param name="at-start" select="false()"/>
-    <xsl:if test="string-length($text) &gt; 0">
-      <xsl:variable name="next-word">
-	<xsl:choose>
-	  <xsl:when test="contains($text, $wdelim)">
-	    <xsl:value-of select="substring-before($text, $wdelim)"/>
-	  </xsl:when>
-	  <xsl:otherwise>
-	    <xsl:value-of select="$text"/>
-	  </xsl:otherwise>
-	</xsl:choose>
-      </xsl:variable>
-      <xsl:variable name="rest">
-	<xsl:choose>
-	  <xsl:when test="contains($text, $wdelim)">
-	    <xsl:value-of select="substring-after($text, $wdelim)"/>
-	  </xsl:when>
-	  <xsl:otherwise>
-	    <xsl:text></xsl:text>
-	  </xsl:otherwise>
-	</xsl:choose>
-      </xsl:variable>
-      <xsl:variable
+  <param name="list-bullets" select="'-*o+'"/>
+
+  <variable name="unit-indent">
+    <call-template name="repeat-string">
+      <with-param name="count" select="$indent-step"/>
+      <with-param name="string" select="' '"/>
+    </call-template>
+  </variable>
+
+  <template name="repeat-string">
+    <param name="count"/>
+    <param name="string"/>
+    <choose>
+      <when test="not($count) or not($string)"/>
+      <when test="$count = 1">
+	<value-of select="$string"/>
+      </when>
+      <otherwise>
+	<if test="$count mod 2">
+	  <value-of select="$string"/>
+	</if>
+	<call-template name="repeat-string">
+	  <with-param name="count" select="floor($count div 2)"/>
+	  <with-param name="string" select="concat($string,$string)"/>
+	</call-template>
+      </otherwise>
+    </choose>
+  </template>
+
+  <template name="indent">
+    <param name="level" select="count(ancestor::*)"/>
+    <call-template name="repeat-string">
+      <with-param name="count" select="$level"/>
+      <with-param name="string" select="$unit-indent"/>
+    </call-template>
+  </template>
+
+  <template name="fill-text">
+    <param name="text"/>
+    <param name="length"/>
+    <param name="remains" select="$length"/>
+    <param name="prefix"/>
+    <param name="wdelim" select="' '"/>
+    <param name="break" select="'&#xA;'"/>
+    <param name="at-start" select="false()"/>
+    <if test="string-length($text) &gt; 0">
+      <variable name="next-word">
+	<choose>
+	  <when test="contains($text, $wdelim)">
+	    <value-of select="substring-before($text, $wdelim)"/>
+	  </when>
+	  <otherwise>
+	    <value-of select="$text"/>
+	  </otherwise>
+	</choose>
+      </variable>
+      <variable name="rest">
+	<choose>
+	  <when test="contains($text, $wdelim)">
+	    <value-of select="substring-after($text, $wdelim)"/>
+	  </when>
+	  <otherwise>
+	    <text></text>
+	  </otherwise>
+	</choose>
+      </variable>
+      <variable
 	  name="left"
 	  select="$remains - string-length(concat($wdelim,$next-word))"/>
-      <xsl:choose>
-	<xsl:when test="$at-start">
-	  <xsl:value-of select="$next-word"/>
-	  <xsl:call-template name="fill-text">
-	    <xsl:with-param name="text" select="$rest"/>
-	    <xsl:with-param name="length" select="$length"/>
-	    <xsl:with-param name="remains" select="$left + 1"/>
-	    <xsl:with-param name="prefix" select="$prefix"/>
-	    <xsl:with-param name="wdelim" select="$wdelim"/>
-	    <xsl:with-param name="break" select="$break"/>
-	  </xsl:call-template>
-	</xsl:when>
-	<xsl:when test="$left &lt; string-length($break)">
-	  <xsl:value-of select="concat($break,$prefix)"/>
-	  <xsl:call-template name="fill-text">
-	    <xsl:with-param name="text" select="$text"/>
-	    <xsl:with-param name="length" select="$length"/>
-	    <xsl:with-param name="remains" select="$length"/>
-	    <xsl:with-param name="prefix" select="$prefix"/>
-	    <xsl:with-param name="wdelim" select="$wdelim"/>
-	    <xsl:with-param name="break" select="$break"/>
-	    <xsl:with-param name="at-start" select="true()"/>
-	  </xsl:call-template>
-	</xsl:when>
-	<xsl:otherwise>
-	  <xsl:value-of select="concat($wdelim,$next-word)"/>
-	  <xsl:call-template name="fill-text">
-	    <xsl:with-param name="text" select="$rest"/>
-	    <xsl:with-param name="length" select="$length"/>
-	    <xsl:with-param name="remains" select="$left"/>
-	    <xsl:with-param name="prefix" select="$prefix"/>
-	    <xsl:with-param name="wdelim" select="$wdelim"/>
-	    <xsl:with-param name="break" select="$break"/>
-	  </xsl:call-template>
-	</xsl:otherwise>
-      </xsl:choose>
-    </xsl:if>
-  </xsl:template>
-
-  <xsl:template name="semi-or-sub">
-    <xsl:choose>
-      <xsl:when test="*">
-	<xsl:text> {&#xA;</xsl:text>
-	<xsl:apply-templates select="*|comment()"/>
-	<xsl:call-template name="indent"/>
-	<xsl:text>}&#xA;</xsl:text>
-      </xsl:when>
-      <xsl:otherwise>
-	<xsl:text>;&#xA;</xsl:text>
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:template>
-
-  <xsl:template name="keyword">
-    <xsl:if test="count(ancestor::*)=1">
-      <xsl:text>&#xA;</xsl:text>
-    </xsl:if>
-    <xsl:call-template name="indent"/>
-    <xsl:value-of select="local-name(.)"/>
-  </xsl:template>
-
-  <xsl:template name="statement">
-    <xsl:param name="arg"/>
-    <xsl:call-template name="keyword"/>
-    <xsl:value-of select="concat(' ', $arg)"/>
-    <xsl:call-template name="semi-or-sub"/>
-  </xsl:template>
-
-  <xsl:template name="statement-dq">    <!-- double-quoted arg -->
-    <xsl:param name="arg"/>
-    <xsl:call-template name="statement">
-      <xsl:with-param name="arg">
-	<xsl:text>"</xsl:text>
-	<xsl:call-template name="escape-text">
-	  <xsl:with-param name="text" select="$arg"/>
-	</xsl:call-template>
-	<xsl:text>"</xsl:text>
-      </xsl:with-param>
-    </xsl:call-template>
-  </xsl:template>
-
-  <xsl:template name="escape-text">
-    <xsl:param name="text"/>
-    <xsl:if test="string-length($text) &gt; 0">
-      <xsl:call-template name="escape-char">
-	<xsl:with-param name="char" select="substring($text,1,1)"/>
-      </xsl:call-template>
-      <xsl:call-template name="escape-text">
-	<xsl:with-param name="text" select="substring($text,2)"/>
-      </xsl:call-template>
-    </xsl:if>
-  </xsl:template>
-
-  <xsl:template name="escape-char">
-    <xsl:param name="char"/>
-    <xsl:variable name="simple-escapes">"\</xsl:variable>
-    <xsl:choose>
-      <xsl:when test="contains($simple-escapes, $char)">
-	<xsl:value-of select="concat('\', $char)"/>
-      </xsl:when>
-      <xsl:when test="$char='&#9;'">\t</xsl:when>
-      <xsl:when test="$char='&#10;'">\n</xsl:when>
-      <xsl:otherwise>
-	<xsl:value-of select="$char"/>
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:template>
-
-  <xsl:template name="chop-arg">
-    <xsl:param name="token-delim" select="'/'"/>
-    <xsl:variable name="qchar">"</xsl:variable>
-    <xsl:variable name="cind">
-      <xsl:call-template name="indent">
-	<xsl:with-param name="level" select="count(ancestor::*)-1"/>
-      </xsl:call-template>
-    </xsl:variable>
-    <xsl:variable name="txt">
-      <xsl:call-template name="escape-text">
-	<xsl:with-param name="text" select="normalize-space(.)"/>
-      </xsl:call-template>
-    </xsl:variable>
-    <xsl:choose>
-      <xsl:when
+      <choose>
+	<when test="$at-start">
+	  <value-of select="$next-word"/>
+	  <call-template name="fill-text">
+	    <with-param name="text" select="$rest"/>
+	    <with-param name="length" select="$length"/>
+	    <with-param name="remains" select="$left + 1"/>
+	    <with-param name="prefix" select="$prefix"/>
+	    <with-param name="wdelim" select="$wdelim"/>
+	    <with-param name="break" select="$break"/>
+	  </call-template>
+	</when>
+	<when test="$left &lt; string-length($break)">
+	  <value-of select="concat($break,$prefix)"/>
+	  <call-template name="fill-text">
+	    <with-param name="text" select="$text"/>
+	    <with-param name="length" select="$length"/>
+	    <with-param name="remains" select="$length"/>
+	    <with-param name="prefix" select="$prefix"/>
+	    <with-param name="wdelim" select="$wdelim"/>
+	    <with-param name="break" select="$break"/>
+	    <with-param name="at-start" select="true()"/>
+	  </call-template>
+	</when>
+	<otherwise>
+	  <value-of select="concat($wdelim,$next-word)"/>
+	  <call-template name="fill-text">
+	    <with-param name="text" select="$rest"/>
+	    <with-param name="length" select="$length"/>
+	    <with-param name="remains" select="$left"/>
+	    <with-param name="prefix" select="$prefix"/>
+	    <with-param name="wdelim" select="$wdelim"/>
+	    <with-param name="break" select="$break"/>
+	  </call-template>
+	</otherwise>
+      </choose>
+    </if>
+  </template>
+
+  <template name="semi-or-sub">
+    <choose>
+      <when test="*">
+	<text> {&#xA;</text>
+	<apply-templates select="*|comment()"/>
+	<call-template name="indent"/>
+	<text>}&#xA;</text>
+      </when>
+      <otherwise>
+	<text>;&#xA;</text>
+      </otherwise>
+    </choose>
+  </template>
+
+  <template name="keyword">
+    <if test="count(ancestor::*)=1">
+      <text>&#xA;</text>
+    </if>
+    <call-template name="indent"/>
+    <value-of select="local-name(.)"/>
+  </template>
+
+  <template name="statement">
+    <param name="arg"/>
+    <call-template name="keyword"/>
+    <value-of select="concat(' ', $arg)"/>
+    <call-template name="semi-or-sub"/>
+  </template>
+
+  <template name="statement-dq">    <!-- double-quoted arg -->
+    <param name="arg"/>
+    <call-template name="statement">
+      <with-param name="arg">
+	<text>"</text>
+	<call-template name="escape-text">
+	  <with-param name="text" select="$arg"/>
+	</call-template>
+	<text>"</text>
+      </with-param>
+    </call-template>
+  </template>
+
+  <template name="escape-text">
+    <param name="text"/>
+    <if test="string-length($text) &gt; 0">
+      <call-template name="escape-char">
+	<with-param name="char" select="substring($text,1,1)"/>
+      </call-template>
+      <call-template name="escape-text">
+	<with-param name="text" select="substring($text,2)"/>
+      </call-template>
+    </if>
+  </template>
+
+  <template name="escape-char">
+    <param name="char"/>
+    <variable name="simple-escapes">"\</variable>
+    <choose>
+      <when test="contains($simple-escapes, $char)">
+	<value-of select="concat('\', $char)"/>
+      </when>
+      <when test="$char='&#9;'">\t</when>
+      <when test="$char='&#10;'">\n</when>
+      <otherwise>
+	<value-of select="$char"/>
+      </otherwise>
+    </choose>
+  </template>
+
+  <template name="chop-arg">
+    <param name="token-delim" select="'/'"/>
+    <variable name="qchar">"</variable>
+    <variable name="cind">
+      <call-template name="indent">
+	<with-param name="level" select="count(ancestor::*)-1"/>
+      </call-template>
+    </variable>
+    <variable name="txt">
+      <call-template name="escape-text">
+	<with-param name="text" select="normalize-space(.)"/>
+      </call-template>
+    </variable>
+    <choose>
+      <when
 	  test="string-length(concat($cind,local-name(..),$txt))
 		&lt; $line-length - 5">
-	<xsl:value-of select="concat(' ',$qchar,$txt)"/>
-      </xsl:when>
-      <xsl:when test="string-length(concat($cind,$unit-indent,$txt))
+	<value-of select="concat(' ',$qchar,$txt)"/>
+      </when>
+      <when test="string-length(concat($cind,$unit-indent,$txt))
 		      &lt; $line-length - 4">
-	<xsl:text>&#xA;</xsl:text>
-	<xsl:call-template name="indent"/>
-	<xsl:value-of select="concat($qchar,$txt)"/>
-      </xsl:when>
-      <xsl:otherwise>
-	<xsl:value-of select="concat(' ',$qchar)"/>
-	<xsl:call-template name="fill-text">
-	  <xsl:with-param name="text" select="$txt"/>
-	  <xsl:with-param
+	<text>&#xA;</text>
+	<call-template name="indent"/>
+	<value-of select="concat($qchar,$txt)"/>
+      </when>
+      <otherwise>
+	<value-of select="concat(' ',$qchar)"/>
+	<call-template name="fill-text">
+	  <with-param name="text" select="$txt"/>
+	  <with-param
 	      name="length"
 	      select="$line-length - 2 -
 		      string-length(concat($cind, local-name(..)))"/>
-	  <xsl:with-param name="prefix">
-	    <xsl:value-of select="$cind"/>
-	    <xsl:call-template name="repeat-string">
-	      <xsl:with-param
+	  <with-param name="prefix">
+	    <value-of select="$cind"/>
+	    <call-template name="repeat-string">
+	      <with-param
 		  name="count"
 		  select="string-length(local-name(..)) - 1"/>
-	      <xsl:with-param name="string" select="' '"/>
-	    </xsl:call-template>
-	    <xsl:value-of select="concat('+ ',$qchar)"/>
-	  </xsl:with-param>
-	  <xsl:with-param name="wdelim" select="$token-delim"/>
-	  <xsl:with-param name="break"
+	      <with-param name="string" select="' '"/>
+	    </call-template>
+	    <value-of select="concat('+ ',$qchar)"/>
+	  </with-param>
+	  <with-param name="wdelim" select="$token-delim"/>
+	  <with-param name="break"
 			  select="concat($token-delim,$qchar,'&#xA;')"/>
-	  <xsl:with-param name="at-start" select="true()"/>
-	</xsl:call-template>
-      </xsl:otherwise>
-    </xsl:choose>
-    <xsl:value-of select="$qchar"/>
-  </xsl:template>
+	  <with-param name="at-start" select="true()"/>
+	</call-template>
+      </otherwise>
+    </choose>
+    <value-of select="$qchar"/>
+  </template>
 
   <!-- Root element -->
 
-  <xsl:template match="/">
-    <xsl:apply-templates select="yin:module|yin:submodule|comment()"/>
-  </xsl:template>
+  <template match="/">
+    <apply-templates select="yin:module|yin:submodule|comment()"/>
+  </template>
 
-  <xsl:template
+  <template
       match="yin:action|yin:anydata|yin:anyxml|yin:argument|yin:base
 	     |yin:bit|yin:case|yin:choice|yin:container|yin:enum
 	     |yin:extension|yin:feature|yin:grouping|yin:identity
 	     |yin:leaf|yin:leaf-list|yin:list
 	     |yin:module|yin:notification|yin:rpc|yin:submodule
 	     |yin:type|yin:typedef|yin:uses">
-    <xsl:call-template name="statement">
-      <xsl:with-param name="arg" select="@name"/>
-    </xsl:call-template>
-  </xsl:template>
-
-  <xsl:template match="yin:if-feature|yin:units">
-    <xsl:call-template name="statement-dq">
-      <xsl:with-param name="arg" select="@name"/>
-    </xsl:call-template>
-  </xsl:template>
-
-  <xsl:template match="yin:augment|yin:deviation|yin:refine">
-    <xsl:call-template name="keyword"/>
-    <xsl:apply-templates select="@target-node"/>
-    <xsl:call-template name="semi-or-sub"/>
-  </xsl:template>
-
-  <xsl:template match="yin:belongs-to|yin:import|yin:include">
-    <xsl:call-template name="statement">
-      <xsl:with-param name="arg" select="@module"/>
-    </xsl:call-template>
-  </xsl:template>
-
-  <xsl:template
+    <call-template name="statement">
+      <with-param name="arg" select="@name"/>
+    </call-template>
+  </template>
+
+  <template match="yin:if-feature|yin:units">
+    <call-template name="statement-dq">
+      <with-param name="arg" select="@name"/>
+    </call-template>
+  </template>
+
+  <template match="yin:augment|yin:deviation|yin:refine">
+    <call-template name="keyword"/>
+    <apply-templates select="@target-node"/>
+    <call-template name="semi-or-sub"/>
+  </template>
+
+  <template match="yin:belongs-to|yin:import|yin:include">
+    <call-template name="statement">
+      <with-param name="arg" select="@module"/>
+    </call-template>
+  </template>
+
+  <template
       match="yin:config|yin:default|yin:deviate|yin:error-app-tag
 	     |yin:fraction-digits|yin:key|yin:length|yin:mandatory
 	     |yin:max-elements|yin:min-elements|yin:ordered-by
 	     |yin:pattern|yin:position|yin:prefix
 	     |yin:presence|yin:range|yin:require-instance
 	     |yin:status|yin:value|yin:yang-version|yin:yin-element">
-    <xsl:call-template name="statement-dq">
-      <xsl:with-param name="arg" select="@value"/>
-    </xsl:call-template>
-  </xsl:template>
-
-  <xsl:template match="yin:path|yin:pattern">
-    <xsl:call-template name="keyword"/>
-    <xsl:apply-templates select="@value"/>
-    <xsl:call-template name="semi-or-sub"/>
-  </xsl:template>
-
-  <xsl:template match="@target-node|yin:path/@value">
-    <xsl:call-template name="chop-arg"/>
-  </xsl:template>
-
-  <xsl:template match="yin:pattern/@value">
-    <xsl:call-template name="chop-arg">
-      <xsl:with-param name="token-delim">|</xsl:with-param>
-    </xsl:call-template>
-  </xsl:template>
-
-  <xsl:template match="yin:error-message">
-    <xsl:call-template name="keyword"/>
-    <xsl:apply-templates select="yin:value"/>
-  </xsl:template>
-
-  <xsl:template match="yin:error-message/yin:value">
-    <xsl:call-template name="chop-arg">
-      <xsl:with-param name="token-delim" select="' '"/>
-    </xsl:call-template>
-    <xsl:text>;&#xA;</xsl:text>
-  </xsl:template>
-
-  <xsl:template match="yin:contact|yin:description
+    <call-template name="statement-dq">
+      <with-param name="arg" select="@value"/>
+    </call-template>
+  </template>
+
+  <template match="yin:path|yin:pattern">
+    <call-template name="keyword"/>
+    <apply-templates select="@value"/>
+    <call-template name="semi-or-sub"/>
+  </template>
+
+  <template match="@target-node|yin:path/@value">
+    <call-template name="chop-arg"/>
+  </template>
+
+  <template match="yin:pattern/@value">
+    <call-template name="chop-arg">
+      <with-param name="token-delim">|</with-param>
+    </call-template>
+  </template>
+
+  <template match="yin:error-message">
+    <call-template name="keyword"/>
+    <apply-templates select="yin:value"/>
+  </template>
+
+  <template match="yin:error-message/yin:value">
+    <call-template name="chop-arg">
+      <with-param name="token-delim" select="' '"/>
+    </call-template>
+    <text>;&#xA;</text>
+  </template>
+
+  <template match="yin:contact|yin:description
 		       |yin:organization|yin:reference">
-    <xsl:call-template name="keyword"/>
-    <xsl:apply-templates select="yin:text"/>
-  </xsl:template>
-
-  <xsl:template match="yin:input|yin:output">
-    <xsl:call-template name="keyword"/>
-    <xsl:call-template name="semi-or-sub"/>
-  </xsl:template>
-
-  <xsl:template match="yin:must|yin:when">
-    <xsl:call-template name="keyword"/>
-    <xsl:apply-templates select="@condition"/>
-    <xsl:call-template name="semi-or-sub"/>
-  </xsl:template>
-
-  <xsl:template match="@condition">
-    <xsl:call-template name="chop-arg">
-      <xsl:with-param name="token-delim">
-	<xsl:choose>
-	  <xsl:when test="contains(substring(.,0,$line-length),' ')">
-	    <xsl:text> </xsl:text>
-	  </xsl:when>
-	  <xsl:otherwise>/</xsl:otherwise>
-	</xsl:choose>
-      </xsl:with-param>
-    </xsl:call-template>
-  </xsl:template>
-
-  <xsl:template match="yin:namespace">
-    <xsl:call-template name="statement-dq">
-      <xsl:with-param name="arg" select="@uri"/>
-    </xsl:call-template>
-  </xsl:template>
-
-  <xsl:template match="yin:revision">
-    <xsl:call-template name="statement">
-      <xsl:with-param name="arg">
-	<xsl:choose>
-	  <xsl:when test="$date and not(preceding-sibling::yin:revision)">
-	    <xsl:value-of select="$date"/>
-	  </xsl:when>
-	  <xsl:otherwise>
-	    <xsl:value-of select="@date"/>
-	  </xsl:otherwise>
-	</xsl:choose>
-      </xsl:with-param>
-    </xsl:call-template>
-  </xsl:template>
-
-  <xsl:template match="yin:revision-date">
-    <xsl:call-template name="statement">
-      <xsl:with-param name="arg" select="@date"/>
-    </xsl:call-template>
-  </xsl:template>
-
-  <xsl:template match="yin:unique">
-    <xsl:call-template name="statement-dq">
-      <xsl:with-param name="arg" select="@tag"/>
-    </xsl:call-template>
-  </xsl:template>
-
-  <xsl:template match="yin:text">
-    <xsl:variable name="qchar">"</xsl:variable>
-    <xsl:text>&#xA;</xsl:text>
-    <xsl:variable name="prf">
-      <xsl:call-template name="indent"/>
-    </xsl:variable>
-    <xsl:value-of select="concat($prf,$qchar)"/>
-    <xsl:choose>
-      <xsl:when test="html:*">
-	<xsl:apply-templates select="html:p|html:ul|html:ol">
-	  <xsl:with-param name="prefix" select="concat($prf,' ')"/>
-	</xsl:apply-templates>
-      </xsl:when>
-      <xsl:otherwise>
-	<xsl:call-template name="fill-text">
-	  <xsl:with-param name="text">
-	    <xsl:call-template name="escape-text">
-	      <xsl:with-param
+    <call-template name="keyword"/>
+    <apply-templates select="yin:text"/>
+  </template>
+
+  <template match="yin:input|yin:output">
+    <call-template name="keyword"/>
+    <call-template name="semi-or-sub"/>
+  </template>
+
+  <template match="yin:must|yin:when">
+    <call-template name="keyword"/>
+    <apply-templates select="@condition"/>
+    <call-template name="semi-or-sub"/>
+  </template>
+
+  <template match="@condition">
+    <call-template name="chop-arg">
+      <with-param name="token-delim">
+	<choose>
+	  <when test="contains(substring(.,0,$line-length),' ')">
+	    <text> </text>
+	  </when>
+	  <otherwise>/</otherwise>
+	</choose>
+      </with-param>
+    </call-template>
+  </template>
+
+  <template match="yin:namespace">
+    <call-template name="statement-dq">
+      <with-param name="arg" select="@uri"/>
+    </call-template>
+  </template>
+
+  <template match="yin:revision">
+    <call-template name="statement">
+      <with-param name="arg">
+	<choose>
+	  <when test="$date and not(preceding-sibling::yin:revision)">
+	    <value-of select="$date"/>
+	  </when>
+	  <otherwise>
+	    <value-of select="@date"/>
+	  </otherwise>
+	</choose>
+      </with-param>
+    </call-template>
+  </template>
+
+  <template match="yin:revision-date">
+    <call-template name="statement">
+      <with-param name="arg" select="@date"/>
+    </call-template>
+  </template>
+
+  <template match="yin:unique">
+    <call-template name="statement-dq">
+      <with-param name="arg" select="@tag"/>
+    </call-template>
+  </template>
+
+  <template match="yin:text">
+    <variable name="qchar">"</variable>
+    <text>&#xA;</text>
+    <variable name="prf">
+      <call-template name="indent"/>
+    </variable>
+    <value-of select="concat($prf,$qchar)"/>
+    <choose>
+      <when test="html:*">
+	<apply-templates select="html:p|html:ul|html:ol">
+	  <with-param name="prefix" select="concat($prf,' ')"/>
+	</apply-templates>
+      </when>
+      <otherwise>
+	<call-template name="fill-text">
+	  <with-param name="text">
+	    <call-template name="escape-text">
+	      <with-param
 		  name="text"
 		  select="normalize-space(.)"/>
-	    </xsl:call-template>
-	    <xsl:value-of select="concat($qchar,';&#xA;')"/>
-	  </xsl:with-param>
-	  <xsl:with-param
+	    </call-template>
+	    <value-of select="concat($qchar,';&#xA;')"/>
+	  </with-param>
+	  <with-param
 	      name="length"
 	      select="$line-length - string-length($prf) - 1"/>
-	  <xsl:with-param name="prefix" select="concat($prf,' ')"/>
-	  <xsl:with-param name="at-start" select="true()"/>
-	</xsl:call-template>
-      </xsl:otherwise>
-    </xsl:choose>
-  </xsl:template>
-
-  <xsl:template match="html:ul">
-    <xsl:param name="prefix"/>
-    <xsl:if test="position()>1">
-      <xsl:value-of select="concat('&#xA;&#xA;',$prefix)"/>
-    </xsl:if>
-    <xsl:apply-templates select="html:li">
-      <xsl:with-param name="prefix" select="$prefix"/>
-      <xsl:with-param name="last" select="position()=last()"/>
-    </xsl:apply-templates>
-  </xsl:template>
-
-  <xsl:template match="html:ol">
-    <xsl:param name="prefix"/>
-    <xsl:if test="position()>1">
-      <xsl:value-of select="concat('&#xA;&#xA;',$prefix)"/>
-    </xsl:if>
-    <xsl:apply-templates select="html:li" mode="numbered">
-      <xsl:with-param name="prefix" select="$prefix"/>
-      <xsl:with-param name="last" select="position()=last()"/>
-    </xsl:apply-templates>
-  </xsl:template>
-
-  <xsl:template match="html:p">
-    <xsl:param name="prefix"/>
-    <xsl:if test="position()>1">
-      <xsl:value-of select="concat('&#xA;&#xA;',$prefix)"/>
-    </xsl:if>
-    <xsl:apply-templates select="text()|html:br" mode="fill">
-      <xsl:with-param name="prefix" select="$prefix"/>
-      <xsl:with-param name="last" select="position()=last()"/>
-    </xsl:apply-templates>
-  </xsl:template>
-
-  <xsl:template match="text()" mode="fill">
-    <xsl:param name="prefix"/>
-    <xsl:param name="last"/>
-    <xsl:call-template name="fill-text">
-      <xsl:with-param name="text">
-	<xsl:call-template name="escape-text">
-	  <xsl:with-param name="text" select="normalize-space(.)"/>
-	</xsl:call-template>
-	<xsl:if test="$last and position()=last()">";&#xA;</xsl:if>
-      </xsl:with-param>
-      <xsl:with-param
+	  <with-param name="prefix" select="concat($prf,' ')"/>
+	  <with-param name="at-start" select="true()"/>
+	</call-template>
+      </otherwise>
+    </choose>
+  </template>
+
+  <template match="html:ul">
+    <param name="prefix"/>
+    <if test="position()>1">
+      <value-of select="concat('&#xA;&#xA;',$prefix)"/>
+    </if>
+    <apply-templates select="html:li">
+      <with-param name="prefix" select="$prefix"/>
+      <with-param name="last" select="position()=last()"/>
+    </apply-templates>
+  </template>
+
+  <template match="html:ol">
+    <param name="prefix"/>
+    <if test="position()>1">
+      <value-of select="concat('&#xA;&#xA;',$prefix)"/>
+    </if>
+    <apply-templates select="html:li" mode="numbered">
+      <with-param name="prefix" select="$prefix"/>
+      <with-param name="last" select="position()=last()"/>
+    </apply-templates>
+  </template>
+
+  <template match="html:p">
+    <param name="prefix"/>
+    <if test="position()>1">
+      <value-of select="concat('&#xA;&#xA;',$prefix)"/>
+    </if>
+    <apply-templates select="text()|html:br" mode="fill">
+      <with-param name="prefix" select="$prefix"/>
+      <with-param name="last" select="position()=last()"/>
+    </apply-templates>
+  </template>
+
+  <template match="text()" mode="fill">
+    <param name="prefix"/>
+    <param name="last"/>
+    <call-template name="fill-text">
+      <with-param name="text">
+	<call-template name="escape-text">
+	  <with-param name="text" select="normalize-space(.)"/>
+	</call-template>
+	<if test="$last and position()=last()">";&#xA;</if>
+      </with-param>
+      <with-param
 	  name="length"
 	  select="$line-length - string-length($prefix)"/>
-      <xsl:with-param name="prefix" select="$prefix"/>
-      <xsl:with-param name="at-start" select="true()"/>
-    </xsl:call-template>
-  </xsl:template>
-
-  <xsl:template match="html:br" mode="fill">
-    <xsl:param name="prefix"/>
-    <xsl:param name="last"/>
-    <xsl:value-of select="concat('&#xA;',$prefix)"/>
-    <xsl:if test="$last and position()=last()">";&#xA;</xsl:if>
-  </xsl:template>
-
-  <xsl:template match="html:li">
-    <xsl:param name="prefix"/>
-    <xsl:param name="last"/>
-    <xsl:if test="position()>1">
-      <xsl:value-of select="concat('&#xA;&#xA;',$prefix)"/>
-    </xsl:if>
-    <xsl:value-of
+      <with-param name="prefix" select="$prefix"/>
+      <with-param name="at-start" select="true()"/>
+    </call-template>
+  </template>
+
+  <template match="html:br" mode="fill">
+    <param name="prefix"/>
+    <param name="last"/>
+    <value-of select="concat('&#xA;',$prefix)"/>
+    <if test="$last and position()=last()">";&#xA;</if>
+  </template>
+
+  <template match="html:li">
+    <param name="prefix"/>
+    <param name="last"/>
+    <if test="position()>1">
+      <value-of select="concat('&#xA;&#xA;',$prefix)"/>
+    </if>
+    <value-of
 	select="concat(substring($list-bullets,
 		count(ancestor::html:ul),1),' ')"/>
-    <xsl:call-template name="fill-text">
-      <xsl:with-param name="text">
-	<xsl:call-template name="escape-text">
-	  <xsl:with-param name="text" select="normalize-space(.)"/>
-	</xsl:call-template>
-	<xsl:if test="$last and position()=last()">";&#xA;</xsl:if>
-      </xsl:with-param>
-      <xsl:with-param
+    <call-template name="fill-text">
+      <with-param name="text">
+	<call-template name="escape-text">
+	  <with-param name="text" select="normalize-space(.)"/>
+	</call-template>
+	<if test="$last and position()=last()">";&#xA;</if>
+      </with-param>
+      <with-param
 	  name="length"
 	  select="$line-length - string-length($prefix) - 2"/>
-      <xsl:with-param name="prefix" select="concat($prefix,'  ')"/>
-      <xsl:with-param name="at-start" select="true()"/>
-    </xsl:call-template>
-  </xsl:template>
-
-  <xsl:template match="html:li" mode="numbered">
-    <xsl:param name="prefix"/>
-    <xsl:param name="last"/>
-    <xsl:if test="position()>1">
-      <xsl:value-of select="concat('&#xA;&#xA;',$prefix)"/>
-    </xsl:if>
-    <xsl:value-of
+      <with-param name="prefix" select="concat($prefix,'  ')"/>
+      <with-param name="at-start" select="true()"/>
+    </call-template>
+  </template>
+
+  <template match="html:li" mode="numbered">
+    <param name="prefix"/>
+    <param name="last"/>
+    <if test="position()>1">
+      <value-of select="concat('&#xA;&#xA;',$prefix)"/>
+    </if>
+    <value-of
 	select="concat(count(preceding-sibling::html:li) + 1,'. ')"/>
-    <xsl:call-template name="fill-text">
-      <xsl:with-param name="text">
-	<xsl:call-template name="escape-text">
-	  <xsl:with-param name="text" select="normalize-space(.)"/>
-	</xsl:call-template>
-	<xsl:if test="$last and position()=last()">";&#xA;</xsl:if>
-      </xsl:with-param>
-      <xsl:with-param
+    <call-template name="fill-text">
+      <with-param name="text">
+	<call-template name="escape-text">
+	  <with-param name="text" select="normalize-space(.)"/>
+	</call-template>
+	<if test="$last and position()=last()">";&#xA;</if>
+      </with-param>
+      <with-param
 	  name="length"
 	  select="$line-length - string-length($prefix) - 3"/>
-      <xsl:with-param name="prefix" select="concat($prefix,'   ')"/>
-      <xsl:with-param name="at-start" select="true()"/>
-    </xsl:call-template>
-  </xsl:template>
-
-  <xsl:template match="comment()">
-    <xsl:if test="count(ancestor::yin:*)=1">
-      <xsl:text>&#xA;</xsl:text>
-    </xsl:if>
-    <xsl:call-template name="indent"/>
-    <xsl:text>/*</xsl:text>
-    <xsl:value-of select="."/>
-    <xsl:text>*/&#xA;</xsl:text>
-  </xsl:template>
+      <with-param name="prefix" select="concat($prefix,'   ')"/>
+      <with-param name="at-start" select="true()"/>
+    </call-template>
+  </template>
+
+  <template match="comment()">
+    <if test="count(ancestor::yin:*)=1">
+      <text>&#xA;</text>
+    </if>
+    <call-template name="indent"/>
+    <text>/*</text>
+    <value-of select="."/>
+    <text>*/&#xA;</text>
+  </template>
 
   <!-- Extension -->
-  <xsl:template match="*">
-    <xsl:if test="count(ancestor::*)=1">
-      <xsl:text>&#xA;</xsl:text>
-    </xsl:if>
-    <xsl:call-template name="indent"/>
-    <xsl:value-of select="name(.)"/>
-    <xsl:text> "</xsl:text>
-    <xsl:call-template name="escape-text">
-      <xsl:with-param name="text" select="@*"/>
-    </xsl:call-template>
-    <xsl:text>"</xsl:text>
-    <xsl:call-template name="semi-or-sub"/>
-  </xsl:template>
-
-</xsl:stylesheet>
+  <template match="*">
+    <if test="count(ancestor::*)=1">
+      <text>&#xA;</text>
+    </if>
+    <call-template name="indent"/>
+    <value-of select="name(.)"/>
+    <text> "</text>
+    <call-template name="escape-text">
+      <with-param name="text" select="@*"/>
+    </call-template>
+    <text>"</text>
+    <call-template name="semi-or-sub"/>
+  </template>
+
+</stylesheet>
-- 
GitLab