[xml-bindings] XPointer & string-range with libxml2-python
- From: Hanh-Missi Tran <tran grappa univ-lille3 fr>
- To: xml-bindings gnome org
- Subject: [xml-bindings] XPointer & string-range with libxml2-python
- Date: Mon, 02 May 2005 13:38:55 +0200
Hi
I want to evaluate XPointer expressions with libxml2-python. It works 
well when a XPointer selects one or several nodes. However I do not 
succeed in evaluating XPointer that uses the function string-range.
For example, here is my xml file:
<?xml version = "1.0"?>
<ADDRBOOK>
       <ENTRY ID="pa">
               <NAME>Pieter</NAME>
       </ENTRY>
       <ENTRY ID="en">
               <NAME>Emeka</NAME>
       </ENTRY>
</ADDRBOOK>
And here is my code:
import libxml2
doc=libxml2.parseFile("addrbook.xml")
root=doc.children
ctx=root.xpointerNewContext(doc,None)
ctx.xpointerEval('xpointer(string-range(ADDRBOOK/ENTRY[1]/NAME[1],"Pieter"))')
It does not work and it gives me the following error:
Unable to convert XPath object type 7
Traceback (most recent call last):
 File "<stdin>", line 1, in ?
 File "/usr/lib/python2.3/site-packages/libxml2.py", line 6443, in 
xpointerEval
   if ret is None:raise treeError('xmlXPtrEval() failed')
libxml2.treeError: xmlXPtrEval() failed
Is there something wrong in my code or in my XPointer ? Does the 
evaluation of that XPointer work if I use libxml2 directly ?
Moreover several xpointer-functions of xmlNode 
(xpointerNewCollapsedRange ...) do not work.
I have tried with an old version (python2.3.4 and libxml2-2.6.13) and 
with the latest(python2.4.1 and libxml2-2.6.19) but there have not been 
any improvements.
[Date Prev][
Date Next]   [Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]