[xml] PATCH: XPOINTER and friends



Daniel and all:

I'm writing on behalf of Brian West, Stefan Anca and myself.  By merging
all our brains, we've come up with a candidate implementation of python
wrapper code for returning XPATH_POINT, XPATH_RANGE, XPATH_LOCATIONSET.
We've choosen to represent a POINT as a tuple of a node and an integer
offset into the content of the node. A RANGE then is a list of POINTs,
and a LOCATIONSET is a list of RANGEs.

I've attached a diff against CVS head (from repository at
anoncvs.gnome.org:/cvs/gnome/libxml2 ), with new files as separate
attachements.

There's a bit of impedance mis-match between xpointer's 1 based offsets
to points between characters, and python 0 based indexes into character
array-like strings. We chose not to attempt to adjust those.

The final hurdle was to fixup xpathObjectRet() to not assume any list
was a list of nodes (since we've got ints in there as well). This did
cause one change in the API from the python side: previously, tuples of 
nodes were returned as a list. We preserve the tupleness of those now.
Looks like all other uses of python tuples are in error handlers or as
arguments to PyEval: none were passed to xpathObjectRet.

A student working with us even coded up some tests, which I've attached
as well: they need to be dropped in python/tests. They may need fixing
up to match your test machinery. Right now, they're a bit chatty.

Ross
-- 
Ross Reedstrom, Ph.D.                                 reedstrm rice 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

Attachment: xpointer-n-friends.diff
Description: Text document

Attachment: m10035.cnxml
Description: Text document

Attachment: tstXpointers
Description: Text document

Attachment: tstxpointer.py
Description: Text Data



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