Re: [xslt] An Invalid xpath expression xsl:template/@match node is ignored



On 31/07/2012 20:28, Nicolas Delaby wrote:
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 ?

Yes, in this case the invalid expression is actually evaluated.

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 ?

I agree that it would be more user-friendly to abort the transformation if an invalid expression is encountered anywhere in the stylesheet. But this is more of a wishlist item than a real bug. Feel free to file a report on bugzilla.gnome.org.

Nick



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]