<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:dyn="http://exslt.org/dynamic"
>
  <xsl:output omit-xml-declaration="yes"/>

  <xsl:param name="xpathpar" select="'//*'" />


  <xsl:template match="/">
    <xsl:for-each select="dyn:evaluate($xpathpar)">
      <xsl:call-template name="doOutput"/>
    </xsl:for-each>
  </xsl:template>


  <xsl:template name="doOutput">
    <xsl:text>
-------------------------------------------------------------------------------
</xsl:text>
    <xsl:choose>
      <xsl:when 
        test="self::comment() | 
              self::processing-instruction() | 
              self::text()">
        <xsl:copy-of select="."/>
      </xsl:when>
      <xsl:when 
        test="count(. | ../attribute::* | ../namespace::*) !=
              count(../attribute::* | ../namespace::*)">
        <xsl:copy-of select="."/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:if test="count(. | ../namespace::*) = count(../namespace::*)">
          <xsl:text>xmlns</xsl:text>
          <xsl:if test="name()">:</xsl:if>
        </xsl:if>
        <xsl:value-of select="name()"/>
        <xsl:text>="</xsl:text>
        <xsl:value-of select="string()"/>
        <xsl:text>"</xsl:text>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>

