[ZPT] CVS: Packages/TAL - XMLParser.py:1.5

guido@digicool.com guido@digicool.com
Mon, 26 Mar 2001 17:05:46 -0500 (EST)


Update of /cvs-repository/Packages/TAL
In directory korak:/tmp/cvs-serv2588

Modified Files:
	XMLParser.py 
Log Message:
Add new API: parseFragment(s, end=0) -- parses a fragment of source
code.

Add the exception raised by Expat to the module, under the name
XMLParseError (which was the name used by the test suite).



--- Updated File XMLParser.py in package Packages/TAL --
--- XMLParser.py	2001/03/16 15:51:18	1.4
+++ XMLParser.py	2001/03/26 22:05:46	1.5
@@ -132,11 +132,14 @@
                     sys.stderr.write("Can't set expat handler %s\n" % name)
 
     def createParser(self, encoding=None):
+        global XMLParseError
         try:
             from Products.ParsedXML.Expat import pyexpat
+            XMLParseError = pyexpat.ExpatError
             return pyexpat.ParserCreate(encoding, ' ')
         except ImportError:
             from xml.parsers import expat
+            XMLParseError = expat.ExpatError
             return expat.ParserCreate(encoding, ' ')
 
     def parseFile(self, filename):
@@ -151,3 +154,6 @@
 
     def parseStream(self, stream):
         self.parser.ParseFile(stream)
+
+    def parseFragment(self, s, end=0):
+        self.parser.Parse(s, end)