xsl:comment

  1. comment_1-input.xml

  2. <?xml version="1.0"?>
  3. <products>
  4.   <product id="p1" stock="4"/>
  5. </products>
  1. comment_1-stylesheet.xsl

  2. <?xml version="1.0"?>
  3. <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4.   <xsl:variable name="x" select="products/product"/>
  5.   <xsl:output indent="yes"/>
  6.   <xsl:template match="/">
  7.   <xsl:comment>Transformation: <xsl:value-of select="current-dateTime()"/></xsl:comment>
  8.     <Products>
  9.     <xsl:comment>English version starts here</xsl:comment>
  10.       <Product>
  11.         <xsl:attribute name="id" select="$x/@id"/>
  12.         <xsl:attribute name="stock" select="$x/@stock"/>
  13.       </Product>
  14.     </Products>
  15.   </xsl:template>
  16. </xsl:stylesheet>
  1. comment_1-output.xml

  2. <?xml version="1.0" encoding="UTF-8"?>
  3. <!--Transformation: 2009-02-17T11:22:18+01:00-->
  4. <Products>
  5.   <!--English version starts here-->
  6.   <Product id="p1" stock="4"/>
  7. </Products>

Comment

Note that current-dateTime() function is new in XSLT 2.0. In XSLT 2.0 xsl:comment is allowed to use select attribute like: <xsl:comment select="concat('Transformation: ', current-dateTime())"/>.

Updated 2009-03-19