Re: Catching message from xsl:message terminate=yes in function
Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected]>
| Newsgroups | gmane.text.xml.saxon.help |
|---|---|
| Message-ID | <[email protected]> |
I'm not sure why you expect the output you do. Firstly, xsl:message with terminate=yes does two things: (a) it outputs a message [more strictly, it instantiates a message emitter and passes the message to it], and (b) it throws an error which normally causes termination. Catching the error can prevent the termination, but it does not prevent the output of the message. Your example shows that the exception has been successfully caught, and the xsl:catch is doing what I would expect it to do. Secondly, you are expecting the message to be output in the form of a serialized processing instruction. Saxon does insert this processing instruction into the document passed to a user-supplied message emitter; but the default message emitter ignores it. This mechanism was introduced as a way of supplying the error code to user-defined message emitters that need to know, without changing the default way that messages were output in previous releases. Michael Kay Saxonica > On 29 Jun 2020, at 07:46, AirQuick <[email protected]> wrote: > > I expected Saxon 10.1 and 9.9.1.7 with the stylesheet below to output > > <value><?error-code Q{http://www.w3.org/2005/xqt-errors}XTMM9000?>my error message</value> > > but the actual output is > > $ java -jar SaxonHE10-1J/saxon-he-10.1.jar -it -xsl:test.xsl > my error message > <?xml version="1.0" encoding="UTF-8"?> > <err> > <code>err:XTMM9000</code> > <description>Processing terminated by xsl:message at line 28 in test.xsl. Found while atomizing the result of a call to my:test#0</description> > <value/> > </err> > > > Stylesheet: > > <?xml version="1.0" encoding="UTF-8"?> > <xsl:stylesheet exclude-result-prefixes="#all" version="3.0" > xmlns:err="http://www.w3.org/2005/xqt-errors" xmlns:my="my" > xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > > <xsl:output indent="yes" /> > > <xsl:template name="xsl:initial-template"> > <xsl:try> > <xsl:sequence select="my:test()" /> > <xsl:catch> > <err> > <code> > <xsl:value-of select="$err:code" /> > </code> > <description> > <xsl:value-of select="$err:description" /> > </description> > <value> > <xsl:sequence select="$err:value" /> > </value> > </err> > </xsl:catch> > </xsl:try> > </xsl:template> > > <xsl:function as="xs:integer" name="my:test"> > <xsl:message select="'my error message'" terminate="yes" /> > <xsl:sequence select="1" /> > </xsl:function> > > </xsl:stylesheet> > > > _______________________________________________ > saxon-help mailing list archived at http://saxon.markmail.org/ > [email protected] > https://lists.sourceforge.net/lists/listinfo/saxon-help _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ [email protected] https://lists.sourceforge.net/lists/listinfo/saxon-help