Sign In/My Account | View Cart  
advertisement

Article:
 Using SAX for Proper XML Output
Subject: Listing 1 Problems
Date: 2003-11-13 09:44:08
From: J Chik

Hi there!
Just starting to learn XML (with Python) and I ran into problems running listing 1. I get the following error
<?xml version="1.0" encoding="utf-8"?>
<log> File "./SAX-output-test.py", line 62, in ?
xl.write_entry(2, u"Vanilla log entry")
File "./SAX-output-test.py", line 45, in write_entry
self._logger.startElementNS((None, u'entry'), u'entry', attrs)
File "/usr/lib/python2.2/xml/sax/saxutils.py", line 103, in startElementNS
name = self._current_context[name[0]] + ":" + name[1]
KeyError


I am currently using Mandrake 8.2 which has Python 2.2 installed. Enjoy your column alot!


John


Previous Message Previous Message   Next Message No Next Message


Titles Only Titles Only Newest First
  • Listing 1 Problems
    2003-11-14 06:50:35 Uche Ogbuji [Reply]

    In the next article in this column:


    http://www.xml.com/pub/a/2003/04/09/py-xml.html


    I cover this unfortunate problem:


    """
    Important note on the last article. I must have made an error in testing the code in my last article to be sure it works without PyXML installed. It turns out that because of at least one rather glaring bug in the Python 2.2 SAX library, you cannot run the example without installing PyXML 0.8.2 or more recent. I shall try to see that the XML modules in Python 2.3 are updated from the PyXML project so that the new version is not similarly limited. I apologize for any inconvenience. Once you have PyXML installed all the code in the article will work just fine.
    """


    I've also covered a lot of IMHO better ways to output XML in future articles. A good place to read for links and tools is:


    http://www.xml.com/pub/a/2003/10/15/py-xml.html


    Good luck.


    --Uche


    • Listing 1 Problems
      2003-11-15 06:15:14 J Chik [Reply]

      Thanks for the information! Fortunately I was just starting out. I just switched to using XMLWriter!


      John

      • Listing 1 Problems
        2003-11-28 09:42:13 J Chik [Reply]

        One more thing, I am wondering what "copyright" is on XMLWriter. I am interested in using it in some GPL stuff I am working on. Thanks again!


        John


Sponsored By: