Re: [xml] Using Xpath with default namespace and null prefix




Le 8 févr. 10 à 18:32, Martin (gzlist) a écrit :

On 08/02/2010, François Delyon <f delyon satimage fr> wrote:

By the way (prefix and namespace), I have a request about exslt.
Some useful functions like exsltStrXpathCtxtRegister have been added.
But they require a non-null prefix, which is not convenient in my case.

Can you explain exaclty how you'd use this from within a program? Are
you wanting to register the extension functions without their
namespaces?

  /* invalid example */
  exsltStrXpathCtxtRegister(ctxt, NULL);
  xmlXPathEval((const xmlChar *)"concat(n)", ctxt);

Now, what function is that calling?
<http://www.w3.org/TR/xpath/#function-concat>
<http://www.exslt.org/str/functions/concat/index.html>

Of course, <http://www.w3.org/TR/xpath/#function-concat>


Martin

  /* valid example */
  exsltStrXpathCtxtRegister(ctxt, NULL);
        ...
        
xmlXPathRegisterNs(ctxt, "str", "http://exslt.org/strings";);
xmlXPathEval((const xmlChar *)"str:concat(n)", ctxt);

Now calls <http://www.exslt.org/str/functions/concat/index.html>.

exsltStrXpathCtxtRegister(ctxt, NULL) must occur once when I create the context. But the NSregistrations and the Xpath evaluations are up to the users of my application.

I am not a user of xmlint, but I suppose that the same problem occurs.
If I what to use some exslt functions in xmlint, it is easy to slightly modify the source code in order to call exsltStrXpathCtxtRegister for any new xmlXPathContextPtr. But at this step, I can't guess the prefix for the namespace "http://exslt.org/strings ". This prefix will be defined in the future by the user of xmlint.

François.




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