[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/common/src GParser.py
From: |
Jason Cater |
Subject: |
gnue/common/src GParser.py |
Date: |
Fri, 22 Mar 2002 03:08:06 -0500 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Jason Cater <address@hidden> 02/03/22 03:08:06
Modified files:
common/src : GParser.py
Log message:
sax parser now operates in namespace-compat mode (does not affect tools
not using namespace features)
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/common/src/GParser.py.diff?cvsroot=OldCVS&tr1=1.29&tr2=1.30&r1=text&r2=text
Patches:
Index: gnue/common/src/GParser.py
diff -c gnue/common/src/GParser.py:1.29 gnue/common/src/GParser.py:1.30
*** gnue/common/src/GParser.py:1.29 Fri Mar 22 02:38:35 2002
--- gnue/common/src/GParser.py Fri Mar 22 03:08:06 2002
***************
*** 76,86 ****
#
#######################################################
! def loadXMLObject(buffer, handler, rootType, xmlFileType,
initialize=1, attributes={}, initParameters={}):
# Create a parser
parser = xml.sax.make_parser()
# Create a stack for the parsing routine
object = None
--- 76,89 ----
#
#######################################################
! def loadXMLObject(stream, handler, rootType, xmlFileType,
initialize=1, attributes={}, initParameters={}):
# Create a parser
parser = xml.sax.make_parser()
+ # Set up some namespace-related stuff for the parsers
+ parser.setFeature(xml.sax.handler.feature_namespaces, 1)
+
# Create a stack for the parsing routine
object = None
***************
*** 89,95 ****
# Tell the parser to use our handler
parser.setContentHandler(dh)
! parser.parse(buffer)
object = dh.getRoot()
--- 92,98 ----
# Tell the parser to use our handler
parser.setContentHandler(dh)
! parser.parse(stream)
object = dh.getRoot()
***************
*** 190,196 ****
# Called by the internal SAX parser whenever
# a starting XML element/tag is encountered.
#
! def startElement(self, name, saxattrs):
GDebug.printMesg(50, "<%s>" % name)
--- 193,200 ----
# Called by the internal SAX parser whenever
# a starting XML element/tag is encountered.
#
! def startElementNS(self, qtag, qname, saxattrs):
! ns, name = qtag
GDebug.printMesg(50, "<%s>" % name)
***************
*** 202,208 ****
attrs = {}
loadedxmlattrs = {}
! for attr in saxattrs.keys():
# Make sure the attribute we are looking at is a valid attribute
if not baseAttrs.has_key(attr):
--- 206,213 ----
attrs = {}
loadedxmlattrs = {}
! for qattr in saxattrs.keys():
! attrns, attr = qattr
# Make sure the attribute we are looking at is a valid attribute
if not baseAttrs.has_key(attr):
***************
*** 210,224 ****
# Typecasting, anyone? If attribute should be int, make it an int
try:
! attrs[attr] = default(baseAttrs[attr],'Typecast',char)(saxattrs[attr])
loadedxmlattrs[attr] = attrs[attr]
except:
! raise MarkupError, 'Error processing <%s> tag [invalid type for "%s"
attribute; value is "%s"]' % (name, attr, saxattrs[attr])
# If this attribute must be unique, check for duplicates
if default (baseAttrs[attr],'Unique',0):
! if self.uniqueIDs.has_key('%s' % (saxattrs[attr])):
! raise MarkupError, 'Error processing <%s> tag ["%s" attribute
should be unique; duplicate value is "%s"]' % (name, attr, saxattrs[attr])
for attr in baseAttrs.keys():
if not attrs.has_key(attr):
--- 215,229 ----
# Typecasting, anyone? If attribute should be int, make it an int
try:
! attrs[attr] =
default(baseAttrs[attr],'Typecast',char)(saxattrs[qattr])
loadedxmlattrs[attr] = attrs[attr]
except:
! raise MarkupError, 'Error processing <%s> tag [invalid type for "%s"
attribute; value is "%s"]' % (name, attr, saxattrs[qattr])
# If this attribute must be unique, check for duplicates
if default (baseAttrs[attr],'Unique',0):
! if self.uniqueIDs.has_key('%s' % (saxattrs[qattr])):
! raise MarkupError, 'Error processing <%s> tag ["%s" attribute
should be unique; duplicate value is "%s"]' % (name, attr, saxattrs[qattr])
for attr in baseAttrs.keys():
if not attrs.has_key(attr):
***************
*** 280,286 ****
# Called by the internal SAX parser whenever
# an ending XML tag/element is encountered.
#
! def endElement(self, name):
self.nameStack.pop(0)
child = self.xmlStack.pop(0)
inits = child._buildObject()
--- 285,292 ----
# Called by the internal SAX parser whenever
# an ending XML tag/element is encountered.
#
! def endElementNS(self, qtag, qname):
! ns, name = qtag
self.nameStack.pop(0)
child = self.xmlStack.pop(0)
inits = child._buildObject()