how to handle xsl:message terminate=yes
Added by Anonymous almost 17 years ago
Legacy ID: #4693390 Legacy Poster: Michael Holodnak (mholodnak)
Any time I specify terminate="yes" in <xsl:message> I want an exception to be thrown. My problem is that I need to validate the input parameters to the stylesheet, so I can't use schema or DTD validation. I know I can probably create my own tag and put it inside the <xsl:message> tag, but I was wondering if overriding the functionality in Saxon might be simpler, as I always want an exception to be thrown in this particular application whenever terminate="yes". Any suggestions would be appreciated.
Replies (2)
RE: how to handle xsl:message terminate=yes - Added by Anonymous almost 17 years ago
Legacy ID: #4693564 Legacy Poster: Michael Kay (mhkay)
When a stylesheet does xsl:message terminate="yes", the message will be notified to the MessageReceiver, and an exception will then be thrown exactly as if a dynamic error occurred. It will be an XPathException, which you can catch in the calling application, and you can distinguish it from other run-time errors by calling getErrorCode() - it has a distinctive error code.
RE: how to handle xsl:message terminate=yes - Added by Anonymous almost 17 years ago
Legacy ID: #4700009 Legacy Poster: Michael Holodnak (mholodnak)
My code was catching TransformerExceptions, which is why I didn't notice it at first, but I was unable to figure out how to send the message text content to the user. However, I was able to use the fn:error() function in XPath 2.0 successfully in conjunction with <xsl:message terminate="yes"> in order to pass a message to the user without additional Java code. Thanks for your help.
Please register to reply