Re: [xslt] document(filename, nodeset) supported?
- From: Thomas Broyer <tbroyer ltgt net>
- To: xslt gnome org
- Subject: Re: [xslt] document(filename, nodeset) supported?
- Date: Thu, 14 Jun 2001 01:52:31 +0200
Le 14/06/01 00:40:52, Liam Quin a écrit :
> The following template fragment gives me an error (and the message is
> not printed)... here's the message:
> Error xpath.c:6686: Invalid expression
> document($remotexmldoc, /)
Running testXPath with expressions document($remotexmldoc, /) and
document($remotexmldoc, /blah), it appears to be a bug in / parsing. AFAIK,
this is a long-time bug.
It can be raised with the minimal expression (/)
ptittom:~/gnome-xml$ ./testXPath --expr '(/)'
Error xpath.c:6807: Invalid expression
(/)
^
Object is a Node Set :
Set contains 1 nodes:
1 /
ptittom:~/gnome-xml$
I'm not sure about the way to fix it, so I prefer this to be discussed here
before.
The error is raised in xmlXPathCompNodeTest (I have a heavily modified
xpath.c -- though not for the expression parsing, computing and evaluation
-- so forget the line number in the above test). Between this function call
and the function parsing the root / (xmlXPathCompLocationPath), the
following functions are called: xmlXPathCompRelativeLocationPath and
xmlXPathCompStep.
The fix seems to be quite trivial: check whether the first non-blank
character following the root / is a Letter, '_' , '@', '.' or '*' (since
XPath is namespace aware, names cannot begin with a colon). If it is,
continue parsing a location path, otherwise return without an error (if
there is one, it should be detected further I guess).
My view is to catch it in xmlXPathCompLocationPath, changing the test from
(CUR != 0) to something like ((CUR != 0 ) && (IS_LETTER(CUR) || (CUR ==
'_') || (CUR == '.') || (CUR == '@') || (CUR == '*')))
This seems to do the trick though I didn't tested it much (however, it
doesn't break regression tests).
Also, I don't understand the while (CUR == '/') loop in
xmlXPathCompLocationPath, since all '/' should be eatten in
CompRelativeLocationPath. CompLocationPath should just parse absolute
location paths and/or rely on RelativeLocationPath.
Such a change doesn't affect regression tests so I think it is justified.
As my xpath.c is, as I said, heavily modified, I can't easily make a patch,
but as it is a very small fix, it shouldn't be a problem...
Tom.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]