Re: [libxml++] Node::find( nonexistent_xpath )



Hi Andy,

as the code you are stumbling over is mine, I'd like
to respond, even if I'm not involved in libxml++ development.

andy glew amd com wrote:
Q: what should Node::find( nonexistent_xpath )
return if it is called with an xpath that does not exist?

Well, the short answer is it should return an (empty)
nodeset. The long answer is that xpath can look up more than
nodes, so the 'find' should return something that wraps among
others a nodeset. Further, the way libxml2 is written means
that 'namespace nodes' are created temporarily in the context
of an xpath lookup (try '*/namespace-uri(.)'], and as soon as
the 'xpath object' is deleted, these nodes are gone.
That implies that the xpath object has to either outlive the
nodeset (for the nodeset to contain valid references), or that
we have to copy the namespace nodes, instead of referencing them.

In my own libxml2 wrapper I thus use a wrapper object 'XPathResult'
that is a logical union of the possible return types of an xpath
search.

Anyways, just some thoughts in case someone wants to work on
libxml++...

Regards,
		Stefan






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