Re: [xml] XPath with no XML Doc

On Wed, Mar 20, 2002 at 03:16:53PM -0000, Cyberthymia wrote:


One of the test documents I'm using to test my integration of libxml into
our program consists of XPath statements with no associated XML Document.
The purpose of this test is to check the format of the results from XPath
statements and to act as a regression test against out old hand-coded XML /
XPath implementation.

[Sidetrack: In effect our test doc fires XPath statements like
"string(0123.4560)" or "substring-after('13/10/2000','/')" or "1 div
round(-0.49)" into the XPath processor (either libxml or our original one),
and check the values are the same / correct. We have a different doc to test
the node set functions, with an associated XML doc.]

Anyway, what I wanted to check was is there any way to get XPath to work
without creating a dummy XML document for the statements to work against?
If I create an XPath context with a NULL document and try using it, I get
the following error:
C:\src\xml\libxml\xpath.c:9855 Internal error: no document
I noticed that the testxpath prog always parses the built in XML document
and uses that if one isn't specified.

  Hum, right it is a bit extreme :-)

In theory, there isn't any need for the Internal error to be generated
unless the XPath statement requires access to an XML document (e.g. for node
set functions), and it seems unnecessary to create an empty dummy document
just to use a few simple XPath statements.

  Well in theory, XPath wasn't supposed to be used standalone :-)
But I agree with your point, I just never considered that XPath would
seriously be used without a context document.

Have I missed anything obvious, or should I start tweaking the XPath code?

  I take patches, the hardest is to actually make sure the document is 
really present when needed and that this won't create a relibility 
problem to remove the test from the context creation.


Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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