message
The message statement outputs a text message to the
console that is running the XSLT. It also allows termination of the stylesheet — useful when debugging.
Syntax
<message> ::= “message” “terminate”?
( <quote> <xpath> <quote> | “{” ( <block template> )+ “}” )
Options
terminate
|
should the stylesheet stop processing the input when option is present (optional). |
message
|
the actual message to be output as a simple string. Should not be used if block is present. |
Elements
A set of block statements returning a string value to be output, should not be mixed with thw using option
Examples
For example, a case where there are two messages of different kinds.
stylesheet {
version "1.0"
match using ”/" {
message "A simple message"
message terminate {
text "A block message that will terminate"
}
message "Another simple message"
}
}
This compiles to
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:message>
<xsl:text>A simple message</xsl:text>
</xsl:message>
<xsl:message terminate="yes">
<xsl:text>A block message that will terminate</xsl:text>
</xsl:message>
<xsl:message>
<xsl:text>Another simple message</xsl:text>
</xsl:message>
</xsl:template>
</xsl:stylesheet>
When this is run the console will display (dependent on the XSLT runtime application).
A simple message
A block message that will terminate
Showing that the final message is not output.
Errors
Simple text and block together.
stylesheet {
version "1.0"
match using ”/" {
message "Oops" {
text "A block message"
}
}
}
will give (this is an error derived from the variable, etc. syntax).
**** (128) A variable/parameter cannot have default and enclosed templates in line 5
Remove either default/select or enclosed templates.
Copyright 2024 Hugh Field-Richards. All Rights Reserved.