Re: Xpath try catch not allowed in XSLT?
Ihe Onwuka <[email protected]> Sun, 13 Sep 2020 14:24:37 -0400
| Newsgroups | gmane.text.xml.saxon.help |
|---|---|
| Message-ID | <CALfs7+wCys6=09hFuyammC1fA0f5Fwo4SMJZUPfiXM2mgAf88w@mail.gmail.com> |
Ah hah. Cheers. The snippet won't work for me but there are other ways of doing what I need. On Sun, Sep 13, 2020 at 2:22 PM Martin Honnen <[email protected]> wrote: > On 13.09.2020 20:09, Ihe Onwuka wrote: > > Error near {... (try {key} at char 73 in xsl:element/@namespace on line > > 98 column 55 of translator.xsl: > > XPST0003 try/catch expressions are not allowed in XPath > > > > I am running Saxon 10.2 > > > > My use case was wanting to use the zero-or-one XPath function which does > > exactly what I want but returns an error where I want an empty () node > > returned. > > > > hence > > > > try {zero-or-one($someSequence)} > > catch * {()} > > XSLT and XQuery have try/catch, XPath not; XQuery has it as an > expression, XSLT as element instructions. I think you get that > particular error from Saxon as it supports try/catch expressions in > XQuery. In XSLT you need to use the xsl:try/xsl:catch element > instructions https://www.w3.org/TR/xslt-30/#try-catch e.g. > > <xsl:try select="zero-or-one($someSequence)"> > <xsl:catch errors="*" select="()"/> > </xsl:try> > > > _______________________________________________ > 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