<?xml version="1.0"?> 
<!-- tracexsl1.xsl: Adds trace-comment generation to other stylesheets.
     Basic version, minimal information and not very safe.

     Illustration from article "STYLING STYLESHEETS TO EXTEND XSLT"
     as published on developerWorks. Copyright 2003 by Joseph Kesselman.
     Permission is granted to use, distribute, and adapt this stylesheet.
-->
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
	xmlns:tracexsl="http://www.ibm.com/xsl-example/tracexsl">

  <xsl:namespace-alias stylesheet-prefix="tracexsl" result-prefix="xsl"/>

  <xsl:template match="@*|node()" priority="-1">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="xsl:template">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates select="xsl:param"/>
      <tracexsl:text xml:space="preserve">&#10;</tracexsl:text>
      <tracexsl:comment>
         <xsl:text>[TraceXSL Begin] match="</xsl:text>
         <xsl:value-of select="@match"/>
         <xsl:text>"</xsl:text>
      </tracexsl:comment>
      <tracexsl:text xml:space="preserve">&#10;</tracexsl:text>

      <xsl:apply-templates select="node()[not(name()='xsl:param')]"/>

      <tracexsl:text xml:space="preserve">&#10;</tracexsl:text>
      <tracexsl:comment>
         <xsl:text>[TraceXSL END] match="</xsl:text>
         <xsl:value-of select="@match"/>
         <xsl:text>"</xsl:text>
      </tracexsl:comment>
      <tracexsl:text xml:space="preserve">&#10;</tracexsl:text>
    </xsl:copy>
  </xsl:template>  

</xsl:stylesheet>
