Re: An Invalid xpath expression xsl:template/@match node is ignored
Nicolas Delaby <[email protected]> Tue, 31 Jul 2012 20:28:59 +0200
| Newsgroups | gmane.comp.gnome.lib.xslt |
|---|---|
| Message-ID | <[email protected]> |
On 07/31/2012 07:28 PM, Nick Wellnhofer wrote:
> On 31/07/2012 17:46, Nicolas Delaby wrote:
>>
>> Dear libxslt maintainers,
>> I discover that performing a transformation with a invalid xpath
>> expression in a template match attribute doesn't prevent the
>> transformation to perform and lead to compromise the transformation
>> logic.
>> Instead, I would expect to have a proper failure like `could not compile
>> match expression`
>
> The way I read it, this behavior doesn't violate the specification.
> Section 17 "Conformance" says:
>
> "A conforming XSLT processor must signal any errors except for those
> that this document specifically allows an XSLT processor not to signal.
> A conforming XSLT processor may but need not recover from any errors
> that it signals."
>
> libxslt does signal the error and tries to recover by ignoring the
> template.
>
Hi Nick,
Thanks for your answer
I see the point.
But if I change a bit my stylesheet to put the invalid xpath expression
in a xsl:apply-templates/@select , it does try to continue the
transformation.
[...]
<xsl:apply-templates select="sub_node1||sub_node2" />
[...]
$ xsltproc xpath-typo.xsl document.xml
XPath error : Invalid expression
sub_node1||sub_node2
^
compilation error: file xpath-typo.xsl line 6 element apply-templates
XSLT-apply-templates: could not compile select expression
'sub_node1||sub_node2'
error: file xpath-typo.xsl line 10 element template
xsltCompilePattern : NULL pattern
Why it stops here ?
I guess the compiler can not recover from this error, so it doesn't have
other choice than stopping. But may be there is another explanation ?
IMHO, I do not like this strategy to recover from errors automatically.
Apart from my personal opinion :), the only way to know if something
goes wrong is to read stderr right ? Or is there is something more
explicit ?
Thanks again,
Nicolas
--
Nicolas Delaby | IT Developer | IT Department
Delivery Hero Holding GmbH
Mohrenstraße 60, 10117 Berlin
Office: +49 30 / 22 01 36 26
Fax: +49 30 / 22 01 36 28
Geschäftsführer / Managing Directors: Niklas Östberg, Fabian Siegel,
Markus Fuhrmann | Internet www.deliveryhero.com | Sitz / registered
office Berlin | Amtsgericht / District Court Charlottenburg,
Handelsregister / Commercial Register HRB 135090 B