[gdome] Possible solution to default namespace problem


I sent a mail before asking how to solve the problem with:

<doc xmlns="/space"><a>t</a></doc>

not working with XPath: /doc/a.

After some reseach I found out that it's a problem with XPath specification, 
and that it's the correct behaviour 

As said in the thread, one must register a prefix to the default namespace by 
means of xmlXPathRegisterNs(), but I cannot do that in my own program because 
Gdome isolates it.

As xmlXPathRegisterNs() operates on a xmlXPathContext and it's created and 
destroyed on gdome_xpeval_evaluate() (or gdome_xpath_xpeval_evaluate()), I 
cannot operate on such thing.

I have some proposals to fix the problem, and require some feedback on Gdome 
core developers on what's the preferred:

 * add an extra field to GdomeXPathNSResolver with the xmlXPathContext, reuse 
this context later. Then add a GdomeXPathNSResolver function to bind prefixes 
to URIs. This is more general approach.

 * add another function gdome_xpeval_evaluateDefaultNS( ..., 
default_ns_prefix, default_ns_uri, ... ) or even avoid default_ns_uri, 
looking for NS with NULL prefix. This is more hack, but will work.

 * add another function gdome_xpeval_evaluateWithNSList( ..., nsList, ... ) 
that gets a list of pairs of prefix and uri to use.

I would go with the first solution, but if you have any better idea, tell me 
ASAP. I should have a patch to the first solution tomorrow.

Gustavo Sverzut Barbieri
Instituto Nokia de Tecnologia - INdT

Jabber: barbieri gmail com
   MSN: barbieri gmail com
  ICQ#: 17249123
 Skype: gsbarbieri
Mobile: +55 (81) 9927 0010
 Phone:  +1 (347) 624 6296; 08122692 sip stanaphone com
   GPG: 0xB640E1A2 @ wwwkeys.pgp.net

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