http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Overview

Compiler design

Whitespace
xsl:sort
Keys
Comment design

lang()
Unparsed entities

If design
Choose|When|Otherwise design
Include|Import design
Variable|Param design

Runtime

Internal DOM
Namespaces

Translet & TrAX
XPath Predicates
Xsltc Iterators
Xsltc Native API
Xsltc TrAX API
Performance Hints

Credits

Functionality
 

The <xsl:comment> element is used to insert XML comments into the result document. The comment is inserted as follows in the XSL stylesheet:

    <element>
      <xsl:comment>This is a comment!</xsl:comment>
    </element>

and it will be output in the result document as follows:

    <element>
      <!-- This is a comment! -->
    </element>

The <xsl:message> element is used to send messages to who/whatever is performing the transformation. The message can be displayed in a terminal, a dialog box, etc. The <xsl:message> element is used in the same way as the <xsl:comment> element, however the message is not output in the result document.

The <xsl:message> element has an attribute "terminate" which can be used to terminate the transformation at any given stage. This is useful when using message to give information about illegal values in the input document.


Implementation
 

The output handler class has a method for outputting comments in the output document and messages to the operator. The code compiled for a comment gathers all text that goes into the comment in a StringValueHandler object, retrieves the full text string from this handler, and then finally sends it to the output handler. Similarly the code compiled for a message will simply send the message to the output handler in use.

Messages will be output to the terminal (stdout) when a transformation is run in a terminal. The message will be output before the beginning of the output document. Messages will be shown in a dialog box if a transformation is run in an applet.

<xsl:message> elements that use the "terminate" attribute to abort transformations cause an exception to be thrown. A RuntimeException is used for this, and the exception text is:

Termination forced by an xsl:message instruction



Copyright © 2003 The Apache Software Foundation. All Rights Reserved.