[XML-SIG] Re: Mr. Nitpicker looks at saxlib

Lars Marius Garshol larsga@ifi.uio.no
29 May 1998 11:50:30 +0200


* Jack Jansen
| 
| However: isn't it possible to be intelligent about the slicing,
| i.e. only do the slice if necessary?

This is how the characters mehtod is handled in saxlib at the moment:

 1) Driver receives data from parser. This is passed on to the
    application in one of two ways:

      a) xmlproc: receives string and offsets, passes them on
      b) the rest: receives string, passes on 0,len(string) offsets

 2) Application receives string and offsets. To get at the string it
    must slice, unless the offsets are 0,len(string).

The only way to avoid slicing is for the application to check the
offsets it receives (which may or may not require slicing). Since this
happens on the application side the solution is a bit difficult to
generalize.

One way to do it might be to have a document handler base class that
implemented the characters method by passing the data on to a
simple_chars(self,data) method, performing slicing only for those
offsets for which this is necessary. In fact, this can be optimized by
checking which parser is used and choosing the right one of two
slicing and non-slicing implementations of characters.

If people want it such a document handler base class can be made part
of saxexts.

-- 
"These are, as I began, cumbersome ways / to kill a man. Simpler, direct, 
and much more neat / is to see that he is living somewhere in the middle /
of the twentieth century, and leave him there."     -- Edwin Brock

 http://www.stud.ifi.uio.no/~larsga/      http://birk105.studby.uio.no/