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="";>

has been changed to

<giml xmlns="";>

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)
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)

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 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
===-=-=--=---=---------------------------------- - - -  -    -

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