<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:n="http://www.oxygenxml.com/nvdl"
                version="2.0"
                exclude-result-prefixes="n">
   <xsl:output indent="yes"/>
   <xsl:template match="/">
      <n:dispatch>
         <xsl:variable name="content">
            <xsl:apply-templates mode="mode_init"/>
         </xsl:variable>
         <xsl:apply-templates mode="flatten" select="$content"/>
      </n:dispatch>
   </xsl:template>
    <xsl:template mode="mode_init" match="n:section[@ns='http://test']">
      <n:validate schema="test.sch">
         <xsl:apply-templates mode="mode_init"/>
      </n:validate>
      <xsl:apply-templates mode="mode_init_nsd1e7_attach_d1e11"/>
   </xsl:template>
    <xsl:template match="n:section" mode="mode_init">
      <n:reject>
         <xsl:apply-templates mode="mode_init"/>
      </n:reject>
   </xsl:template>
   <xsl:template match="*[namespace-uri()!='http://www.oxygenxml.com/nvdl']" mode="#all"
                 priority="-100">
      <xsl:copy>
         <xsl:apply-templates select="@*[namespace-uri()!='http://www.oxygenxml.com/nvdl']" mode="#current"/>
         <xsl:apply-templates select="@n:*" mode="#current"/>
         <xsl:apply-templates mode="#current"/>
      </xsl:copy>
   </xsl:template>
   <xsl:template match="@*[namespace-uri()!='http://www.oxygenxml.com/nvdl']" mode="#all"
                 priority="-100">
      <xsl:copy/>
   </xsl:template>
   <xsl:template match="@n:*" mode="#all" priority="-100"/>
   <xsl:template match="*" mode="flatten">
      <xsl:apply-templates select="//n:*" mode="flatten1"/>
   </xsl:template>
   <xsl:template match="n:*" mode="flatten1">
      <xsl:copy>
         <xsl:copy-of select="@*"/>
         <xsl:apply-templates select="text()|*[namespace-uri()!='http://www.oxygenxml.com/nvdl']"
                              mode="flatten2"/>
      </xsl:copy>
   </xsl:template>
   <xsl:template match="*[namespace-uri()!='http://www.oxygenxml.com/nvdl']" mode="flatten2">
      <xsl:copy>
         <xsl:copy-of select="@*[namespace-uri()!='http://www.oxygenxml.com/nvdl']"/>
         <xsl:apply-templates select="text()|*[namespace-uri()!='http://www.oxygenxml.com/nvdl']"
                              mode="flatten2"/>
      </xsl:copy>
   </xsl:template>
</xsl:stylesheet>