List Info

Thread: string-range in xpointers from python?




string-range in xpointers from python?
user name
2006-08-17 21:48:11
Hey all - 
We're trying to use the libxml2 python bindings to play
some games with
'marking up' an xml document, based on xpointers coming
out of various
checkers and annotators. We need string-range for cases like
spell-check
or arbitrary annotation.

Is the string-range function just not implemented from the
python
bindings? I'm getting 'unregistered function':

>>>
ctx.xpointerEval('xpointer(string-range(/,"Geometric
"))')
xmlXPathCompOpEval: function string-range not found
Unregistered function
xmlXPtrEval: evaluation failed to return a node set
xmlXPtrEval: object(s) left on the eval stack
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File
"/usr/lib/python2.3/site-packages/libxml2.py",
line 6922, in
xpointerEval    if ret is None:raise
treeError('xmlXPtrEval() failed')
libxml2.treeError: xmlXPtrEval() failed
>>>

Ross
-- 
Ross Reedstrom, Ph.D.                                
reedstrmrice.edu
Research Scientist                                  phone:
713-348-6166
The Connexions Project      http://cnx.org            fax:
713-348-3665
Rice University MS-375, Houston, TX 77005
GPG Key fingerprint = F023 82C8 9B0E 2CC6 0D8E  F888 D3AE
810E 88F0 BEDE
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
string-range in xpointers from python?
user name
2006-08-18 05:53:42
On Thu, Aug 17, 2006 at 04:48:11PM -0500, Ross J. Reedstrom
wrote:
> Hey all - 
> We're trying to use the libxml2 python bindings to
play some games with
> 'marking up' an xml document, based on xpointers
coming out of various
> checkers and annotators. We need string-range for cases
like spell-check
> or arbitrary annotation.
> 
> Is the string-range function just not implemented from
the python
> bindings? I'm getting 'unregistered function':
> 
> >>>
ctx.xpointerEval('xpointer(string-range(/,"Geometric
"))')
> xmlXPathCompOpEval: function string-range not found
> Unregistered function
> xmlXPtrEval: evaluation failed to return a node set
> xmlXPtrEval: object(s) left on the eval stack
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File
"/usr/lib/python2.3/site-packages/libxml2.py",
line 6922, in
> xpointerEval    if ret is None:raise
treeError('xmlXPtrEval() failed')
> libxml2.treeError: xmlXPtrEval() failed
> >>>

  are you sure ctx is an XPointer context and not an XPath
context ?

Daniel

-- 
Red Hat Virtualization group http://redhat.com/v
irtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillardredhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ |
Rpmfind RPM search engine  http://rpmfind.net/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
string-range in xpointers from python?
user name
2006-08-18 15:09:26
On Fri, Aug 18, 2006 at 01:53:42AM -0400, Daniel Veillard
wrote:

> 
>   are you sure ctx is an XPointer context and not an
XPath context ?
> 

Actually, no, it's not. I just realized we're using an
XPathContext
derived from the document itself, rather than an
XPointerContext from
the root node. Sigh. Seems working examples of xpointer
usage are few
and far between. I'll take a look at that, and see what I
can make work.
I'll probably be back with more questions.

Ross
-- 
Ross Reedstrom, Ph.D.                                
reedstrmrice.edu
Research Scientist                                  phone:
713-348-6166
The Connexions Project      http://cnx.org            fax:
713-348-3665
Rice University MS-375, Houston, TX 77005
GPG Key fingerprint = F023 82C8 9B0E 2CC6 0D8E  F888 D3AE
810E 88F0 BEDE
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
string-range in xpointers from python?
user name
2006-08-18 15:44:30
O.k, so this is better, some:
>>> print
ctx.xpointerEval('xpointer(/cnx:document/cnx:content/cnx:pa
ra[1])')[0].content

      Geometric representation of signals can provide a
compact
      characterization of signals and can simplify analysis
of their
      performance as modulation signals.

>>>
ctx.xpointerEval('xpointer(string-range(/cnx:document/cnx:c
ontent/cnx:para[1],"Geometric"))')
Unable to convert XPath object type 7

I see this same error from a list posting a year ago, May.
I'm using
libxml2 2.6.26. Is there more complete support in CVS?
Should I be
getting my devel setup functional, and see about providing a
patch or
two?

Ross

-- 
Ross Reedstrom, Ph.D.                                
reedstrmrice.edu
Research Scientist                                  phone:
713-348-6166
The Connexions Project      http://cnx.org            fax:
713-348-3665
Rice University MS-375, Houston, TX 77005
GPG Key fingerprint = F023 82C8 9B0E 2CC6 0D8E  F888 D3AE
810E 88F0 BEDE
On Fri, Aug 18, 2006 at 10:09:26AM -0500, Ross J. Reedstrom
wrote:
> On Fri, Aug 18, 2006 at 01:53:42AM -0400, Daniel
Veillard wrote:
> 
> > 
> >   are you sure ctx is an XPointer context and not
an XPath context ?
> > 
> 
> Actually, no, it's not. I just realized we're using
an XPathContext
> derived from the document itself, rather than an
XPointerContext from
> the root node. Sigh. Seems working examples of xpointer
usage are few
> and far between. I'll take a look at that, and see
what I can make work.
> I'll probably be back with more questions.
> 
> Ross
> -- 
> Ross Reedstrom, Ph.D.                                
reedstrmrice.edu
> Research Scientist                                 
phone: 713-348-6166
> The Connexions Project      http://cnx.org            fax:
713-348-3665
> Rice University MS-375, Houston, TX 77005
> GPG Key fingerprint = F023 82C8 9B0E 2CC6 0D8E  F888
D3AE 810E 88F0 BEDE
> _______________________________________________
> xml mailing list, project page  http://xmlsoft.org/
> xmlgnome.org
> http://mai
l.gnome.org/mailman/listinfo/xml
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
string-range in xpointers from python?
user name
2006-08-18 16:08:27
On Fri, Aug 18, 2006 at 10:44:30AM -0500, Ross J. Reedstrom
wrote:
> O.k, so this is better, some:
> >>> print
ctx.xpointerEval('xpointer(/cnx:document/cnx:content/cnx:pa
ra[1])')[0].content
> 
>       Geometric representation of signals can provide a
compact
>       characterization of signals and can simplify
analysis of their
>       performance as modulation signals.
> 
> >>>
ctx.xpointerEval('xpointer(string-range(/cnx:document/cnx:c
ontent/cnx:para[1],"Geometric"))')
> Unable to convert XPath object type 7
> 
> I see this same error from a list posting a year ago,
May. I'm using
> libxml2 2.6.26. Is there more complete support in CVS?
Should I be
> getting my devel setup functional, and see about
providing a patch or
> two?

  Hum, yeah, that must be the binding missing support from
the extra
XPath types (XPATH_POINT, XPATH_RANGE and
XPATH_LOCATIONSET), I guess
nobody tried to really use them from Python, you're in
unknown land.
  Probably libxml_xmlXPathObjectPtrWrap() should be
augmented to 
handle them (python/types.c around line 397), and convert
them to Python
type. I don't know what would be the best way to represent
a point, 
maybe a tuple made of a node and an index.
  I would be glad to get patches and some example to run the
regression tests
from python/test/ !

  Thanks in advance 

Daniel

-- 
Red Hat Virtualization group http://redhat.com/v
irtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillardredhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ |
Rpmfind RPM search engine  http://rpmfind.net/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )