Re: [xml] Still some words about XPath



On Mon, May 14, 2001 at 07:55:33PM +0200, Thomas Broyer wrote:
 · xmlXPathNewNodeSet returns an "empty node-set" object when it is
   passed NULL, whereas xmlXPathNewNodeSetList returns NULL and
   xmlXPathWrapNodeSet returns an empty object (obj->nodesetval is
   NULL).
   xmlXPathNewNodeSet is consistant with xmlXPathNewString and
   xmlXPathNewCString.

Actually, xmlXPathNewCString returns en empty object (stringval is NULL) if
it is passed a NULL argument.

  Yes this makes sense, there is places where one want to create
the node set "before" for example before a loop without failing.

So what should the "normal" behaviour be?

  if the constructor usues a input pointer, well if the pointer is NULL
make a minimalist allocation. For example it will allocate an empty 
node set.

IMO the one of xmlXPathWrapNodeSet and xmlXPathNewCString to prevent
useless allocations. stringval == NULL and stringval == "" should be
considered equivalent (an empty string), idem for nodesetval == NULL and
nodesetval->nodeTab == NULL.

  nodesetval == NULL and nodesetval->nodeTab == NULL are already equivalent.

This is a trade off:
  - doing an extra allocation
  vs
  - making a more complex/larger code (including on the client code)

In some cases it makes sense (i think it is for nodesets).

I was thinking of xmlXPathConvertFunc, xmlXPathType, xmlXPathVariable,
xmlXPathAxisFunc and xmlXPathAxis.
There isn't any function using them, they are completely useless and
unusable.

  Hum, those can disapear right ... They may have to be redefined 
with XML Query or XML Schemas reuse in XSLT-2.0.

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/




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