blob: ef2a26d970c27bee2f5f3c4cab69299db2c41e82 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>ASF: &lt;xsl:comment&gt; / &lt;xsl:message&gt;</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link rel="stylesheet" type="text/css" href="resources/apache-xalan.css" />
</head>
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<body>
<div id="title">
<table class="HdrTitle">
<tbody>
<tr>
<th rowspan="2">
<a href="../index.html">
<img alt="Trademark Logo" src="resources/XalanJ-Logo-tm.png" width="190" height="90" />
</a>
</th>
<th text-align="center" width="75%">
<a href="index.html">XSLTC Design</a>
</th>
</tr>
<tr>
<td valign="middle">&lt;xsl:comment&gt; / &lt;xsl:message&gt;</td>
</tr>
</tbody>
</table>
<table class="HdrButtons" align="center" border="1">
<tbody>
<tr>
<td>
<a href="http://www.apache.org">Apache Foundation</a>
</td>
<td>
<a href="http://xalan.apache.org">Xalan Project</a>
</td>
<td>
<a href="http://xerces.apache.org">Xerces Project</a>
</td>
<td>
<a href="http://www.w3.org/TR">Web Consortium</a>
</td>
<td>
<a href="http://www.oasis-open.org/standards">Oasis Open</a>
</td>
</tr>
</tbody>
</table>
</div>
<div id="navLeft">
<ul>
<li>
<a href="index.html">Overview</a>
</li></ul><hr /><ul>
<li>
<a href="xsltc_compiler.html">Compiler design</a>
</li></ul><hr /><ul>
<li>
<a href="xsl_whitespace_design.html">Whitespace</a>
</li>
<li>
<a href="xsl_sort_design.html">xsl:sort</a>
</li>
<li>
<a href="xsl_key_design.html">Keys</a>
</li>
<li>Comment design<br />
</li></ul><hr /><ul>
<li>
<a href="xsl_lang_design.html">lang()</a>
</li>
<li>
<a href="xsl_unparsed_design.html">Unparsed entities</a>
</li></ul><hr /><ul>
<li>
<a href="xsl_if_design.html">If design</a>
</li>
<li>
<a href="xsl_choose_design.html">Choose|When|Otherwise design</a>
</li>
<li>
<a href="xsl_include_design.html">Include|Import design</a>
</li>
<li>
<a href="xsl_variable_design.html">Variable|Param design</a>
</li></ul><hr /><ul>
<li>
<a href="xsltc_runtime.html">Runtime</a>
</li></ul><hr /><ul>
<li>
<a href="xsltc_dom.html">Internal DOM</a>
</li>
<li>
<a href="xsltc_namespace.html">Namespaces</a>
</li></ul><hr /><ul>
<li>
<a href="xsltc_trax.html">Translet &amp; TrAX</a>
</li>
<li>
<a href="xsltc_predicates.html">XPath Predicates</a>
</li>
<li>
<a href="xsltc_iterators.html">Xsltc Iterators</a>
</li>
<li>
<a href="xsltc_native_api.html">Xsltc Native API</a>
</li>
<li>
<a href="xsltc_trax_api.html">Xsltc TrAX API</a>
</li>
<li>
<a href="xsltc_performance.html">Performance Hints</a>
</li>
</ul>
</div>
<div id="content">
<h2>&lt;xsl:comment&gt; / &lt;xsl:message&gt;</h2>
<ul>
<li>
<a href="#functionality">Functionality</a>
</li>
<li>
<a href="#implementation">Implementation</a>
</li>
</ul>
<a name="functionality"></a>
<p align="right" size="2">
<a href="#content">(top)</a>
</p>
<h3>Functionality</h3>
<p>The <code>&lt;xsl:comment&gt;</code> element is used to insert XML comments
into the result document. The comment is inserted as follows in the XSL
stylesheet:</p>
<blockquote class="source">
<pre> &lt;element&gt;
&lt;xsl:comment&gt;This is a comment!&lt;/xsl:comment&gt;
&lt;/element&gt;</pre>
</blockquote>
<p>and it will be output in the result document as follows:</p>
<blockquote class="source">
<pre> &lt;element&gt;
&lt;!-- This is a comment! --&gt;
&lt;/element&gt;</pre>
</blockquote>
<p>The <code>&lt;xsl:message&gt;</code> 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 <code>&lt;xsl:message&gt;</code> element
is used in the same way as the <code>&lt;xsl:comment&gt;</code> element,
however the message is <b>not</b> output in the result document.</p>
<p>The <code>&lt;xsl:message&gt;</code> element has an attribute
<code>"terminate"</code> 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.</p>
<a name="implementation"></a>
<p align="right" size="2">
<a href="#content">(top)</a>
</p>
<h3>Implementation</h3>
<p>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.</p>
<p>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.</p>
<p>
<code>&lt;xsl:message&gt;</code> elements that use the <code>"terminate"</code>
attribute to abort transformations cause an exception to be thrown. A
RuntimeException is used for this, and the exception text is:</p>
<p>
<code>Termination forced by an xsl:message instruction</code>
</p>
<p align="right" size="2">
<a href="#content">(top)</a>
</p>
</div>
<div id="footer">Copyright © 1999-2014 The Apache Software Foundation<br />Apache, Xalan, and the Feather logo are trademarks of The Apache Software Foundation<div class="small">Web Page created on - Thu 2014-05-15</div>
</div>
</body>
</html>