File: README.pyexpat

package info (click to toggle)
python-xml 0.4.19981014-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 2,124 kB
  • ctags: 3,099
  • sloc: ansic: 9,075; python: 8,150; xml: 7,940; makefile: 84; sh: 41
file content (75 lines) | stat: -rw-r--r-- 2,803 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
Python Expat wrapper module, version of 19-May-98
=================================================

If you have downloaded the binary distribution for the macintosh you
can skip the "building" sections and go straight to the "using"
bit. If you are using a macintosh and do want to build from source you 
should get the pyexpat.tgz distribution (Stuffit Expander with
Expander Enhancer will know how to unpack a gzipped tar file).
	
Building the pyexpat module under unix
--------------------------------------

- Build libexpat.a in expat. This version is very slightly different 
  from the original by James Clark (the libexpat.a target was added,
  and a few C++ comments were replaced by C comments).
- Edit Makefile.pre.in and set your installdir
- make -f Makefile.pre.in VERSION=1.5.1 Makefile
- make sharedmods
- put the shared module somewhere in your sys.path

(if you want a static Python edit Setup.in, and replace the last line
with "make").

Building the pyexpat module on the macintosh
--------------------------------------------
- Unpack the various .hqx project files.
- All the projects are linked, so building pyexpat.prj should build
  everything. If this doesn't work you will find the library
  subprojects to build in the expat folder.
- Use EditPythonPrefs to add the current folder to sys.path.

Using the pyexpat module
-----------------------

The pyexpat module exports two functions:
ParserCreate(encoding) Creates a new parser object. The optional
	encoding arg (a string) specifies the encoding.
ErrorString(number) Return a string corresponding to the given error
	number.

Parser objects have one method:
Parse(data, isfinal) Parse some data. If the optional isfinal arg is 1 
	this is the last bit of data. Returns true if parsing
	succeeded (so far), otherwise the error attributes have
	information on the error.

Parser objects have the following attributes:

StartElementHandler, EndElementHandler, CharacterDataHandler,
ProcessingInstructionHandler - The Python handlers called for various
	events. See below for the signatures.
ErrorCode, ErrorLineNumber, ErrorColumnNumber, ErrorByteIndex -
	Readonly integers giving information on the current parse
	error.

Testing it
----------

There's a very minimal test script in expattest.py. It should be easy 
to adapt it to generate ESIS (but I'm not familiar enough with ESIS to 
do it). This module parsed Hamlet in 2 seconds on an 180 Mhz R5000 SGI 
O2.

Feedback
--------

This module currently lives at
ftp://ftp.cwi.nl/pub/jack/python/pyexpatsrc.tgz (source) and
ftp://ftp.cwi.nl/pub/jack/python/pyexpat.hqx (macintosh binary-only).

The author is Jack Jansen, jack@cwi.nl. The expat proper was written
by James Clark and can be found at http://www.jclark.com/xml/ .

	Jack Jansen, CWI, Amsterdam
	jack@cwi.nl