Lars Marius Garshol larsga@ifi.uio.no
27 May 1999 08:41:06 +0200

* Paul Chung Chee Soong
| Now, let's discuss my problem. I have difficulty understanding
| certain part of the document. For example, I can't execute the "from
| xml.sax import saxlib, saxexts" coz I don't have the xml.sax
| module. But anyway, i manage to download those components
| separately. The earlier code become "import saxlib, saxexts". Did I
| solve the problem? 

Probably not. :)

This is something that seems to confuse many newbies, so I'll try to
explain. If you do like this:

C:\Mine dokumenter>python
Python 1.5.2c1 (#0, Mar 12 1999, 10:55:39) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import sys
>>> print sys.path

Python will print a list of directories. This is the list of
directories in which it looks for modules you import. 

When you unzip the XML-SIG package (or the saxlib.zip file) somewhere
on your disk (let's say c:\foo) it creates an xml directory
(c:\foo\xml), below that a sax directory and below that again a
drivers directory.
What you need to do is to ensure that c:\foo is in the sys.path list.
If it isn't you'll need to either add c:\foo to the PYTHONPATH
environment variable or add it to the 
HKEY_LOCAL_MACHINE\Software\Python\1.5.2\PythonPath registry key.

I hope that explained it for you? (If it did I think I'll brush it up
a little and put it on the SAX pages as installation instructions.)

| Another problem that I came across is that in Section 3.1 Starting
| Out. I don't seem to run the example. This is what I do..
| import saxexts
| if __name__ = '__main__':
|  parser = saxexts.make_parser('drv_xmllib') # 1
|  dh = FindIssue ('Sandman', '62')           # 2
|  parser.setDocumentHandler(dh)              # 3
|  parser.parseFile('collection.xml')          # 4
| Now, in the # 1, I got error when I followed your example. 

This is very likely because the parser factory has a list of drivers
that looks like 'xml.sax.drivers.drv_xmllib'. So if you solve the
package problem above you shouldn't need to hard-code the driver
package name.

(Another thing is that other programs that use SAX won't work unless
they can find SAX where they expect it.)
| Next in # 4, I got problem again. In your example, your parameter is
| a file. What is the 'file' represents? I thought it was a xml file
| but it isn't right??

It's the name of an XML file. If you want to push an XML document as a
string ('<root><title>My title</title> ...</root>') you can use the
parser.reset(), parser.feed('...') and parser.close() methods.

(See <URL: http://www.stud.ifi.uio.no/~larsga/download/python/xml/saxexts-spec.html#ExtendedParser>)
I hope this helped,
--Lars M.