Re: [xml] xmllint and namespaces



Hi Daniel,

Hi Daniel,

Thanks for your help, but I am not over with the issue. I prefered not to pollute my files and so I got rid of the namespace prefix (as I will not mix my xml-data with other). So

<giml:giml xmlns:giml="http://gitk.sourceforge.net/";>
   <giml:context/>
</giml:giml>

has been changed to

<giml xmlns="http://gitk.sourceforge.net/";>
   <context/>
</giml>

I keep the default namespace. No all of my xpath queries are broken.


  Read the XPath spec. the "giml" XPath expression will only select
nodes of name "giml" but without namespace. You need to keep the namespace
in the XPath query to match those node.
  Sorry I can't debug the code. I assume the problem comes from what
I just said.

No problem with you not looking closer on my code, now I have a look at yours ;-). First I've upgraded to libxmls2-2.4.26.
Now I had a search where the error gets thrown and I noticed the following :

1.) in xpath.c:xmlXPathNodeCollectAndTest()
about line 8704 there is :
    if (prefix != NULL) {
        URI = xmlXPathNsLookup(ctxt->context, prefix);
        if (URI == NULL)
            XP_ERROR0(XPATH_UNDEF_PREFIX_ERROR);
    }
IMHO this error message (-> "Undefined namespace prefix")is wrong. The namespace-prefix is *not* undefined, the URI is.
Same is in
  xpath.c:xmlXPathNodeCollectAndTestNth() (around line 9121)

Shouldn't the code be
    if (prefix != NULL) {
        URI = xmlXPathNsLookup(ctxt->context, prefix);
        if (URI == NULL)
            XP_ERROR0(XPATH_UNDEF_URI_ERROR);
    }
    else XP_ERROR0(XPATH_UNDEF_PREFIX_ERROR);

of course XPATH_UNDEF_URI_ERROR need to be added into xpath.h and the message into xpath.c

BTW. I just had one xpath expression which escaped me when removing the ns-prefix from the expression (was totally dynamically constructed :-( ).

Stefan
--
      \|/            Stefan Kost
     <@ @>           private            business
+-oOO-(_)-OOo------------------------------------------------------ - - -  -   -
|       __  Address  Simildenstr. 5     HTWK Leipzig, Fb IMN, Postfach 300066
|      ///           04277 Leipzig      04277 Leipzig
| __  ///            Germany            Germany
| \\\///    Phone    +49341 2253538     +49341 30766101
|  \__/     EMail    st_kost gmx net    kost imn htwk-leipzig de
|           WWW      www.sonicpulse.de  www.imn.htwk-leipzig.de/~kost/about.html
===-=-=--=---=---------------------------------- - - -  -    -




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