Update of /cvsroot/wpdev/xmlscripts/python-lib/xml/dom
In directory sc8-pr-cvs1:/tmp/cvs-serv5168/xml/dom
Modified Files:
__init__.py domreg.py minidom.py pulldom.py
Log Message:
Updated to Python 2.3.2
Index: __init__.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/python-lib/xml/dom/__init__.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** __init__.py 1 Jul 2002 02:00:11 -0000 1.1.1.1
--- __init__.py 10 Nov 2003 12:44:16 -0000 1.2
***************
*** 56,59 ****
--- 56,60 ----
NAMESPACE_ERR = 14
INVALID_ACCESS_ERR = 15
+ VALIDATION_ERR = 16
***************
*** 66,70 ****
raise RuntimeError(
"DOMException should not be instantiated directly")
! apply(Exception.__init__, (self,) + args, kw)
def _get_code(self):
--- 67,71 ----
raise RuntimeError(
"DOMException should not be instantiated directly")
! Exception.__init__(self, *args, **kw)
def _get_code(self):
***************
*** 117,120 ****
--- 118,133 ----
code = INVALID_ACCESS_ERR
+ class ValidationErr(DOMException):
+ code = VALIDATION_ERR
+
+ class UserDataHandler:
+ """Class giving the operation constants for UserDataHandler.handle()."""
+
+ # Based on DOM Level 3 (WD 9 April 2002)
+
+ NODE_CLONED = 1
+ NODE_IMPORTED = 2
+ NODE_DELETED = 3
+ NODE_RENAMED = 4
XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace"
***************
*** 122,125 ****
--- 135,139 ----
XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml"
EMPTY_NAMESPACE = None
+ EMPTY_PREFIX = None
from domreg import getDOMImplementation,registerDOMImplementation
Index: domreg.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/python-lib/xml/dom/domreg.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** domreg.py 1 Jul 2002 02:00:10 -0000 1.1.1.1
--- domreg.py 10 Nov 2003 12:44:16 -0000 1.2
***************
*** 3,6 ****
--- 3,8 ----
registerDOMImplementation should be imported from xml.dom."""
+ from xml.dom.minicompat import * # isinstance, StringTypes
+
# This is a list of well-known implementations. Well-known names
# should be published by posting to xm...@py..., and are
***************
*** 25,29 ****
or a new one (e.g. if that implementation supports some
customization)."""
!
registered[name] = factory
--- 27,31 ----
or a new one (e.g. if that implementation supports some
customization)."""
!
registered[name] = factory
***************
*** 47,51 ****
be found, raise an ImportError. The features list must be a sequence
of (feature, version) pairs which are passed to hasFeature."""
!
import os
creator = None
--- 49,53 ----
be found, raise an ImportError. The features list must be a sequence
of (feature, version) pairs which are passed to hasFeature."""
!
import os
creator = None
***************
*** 61,64 ****
--- 63,68 ----
# User did not specify a name, try implementations in arbitrary
# order, returning the one that has the required features
+ if isinstance(features, StringTypes):
+ features = _parse_feature_string(features)
for creator in registered.values():
dom = creator()
***************
*** 75,76 ****
--- 79,99 ----
raise ImportError,"no suitable DOM implementation found"
+
+ def _parse_feature_string(s):
+ features = []
+ parts = s.split()
+ i = 0
+ length = len(parts)
+ while i < length:
+ feature = parts[i]
+ if feature[0] in "0123456789":
+ raise ValueError, "bad feature name: " + `feature`
+ i = i + 1
+ version = None
+ if i < length:
+ v = parts[i]
+ if v[0] in "0123456789":
+ i = i + 1
+ version = v
+ features.append((feature, version))
+ return tuple(features)
Index: minidom.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/python-lib/xml/dom/minidom.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** minidom.py 21 Dec 2002 14:52:55 -0000 1.2
--- minidom.py 10 Nov 2003 12:44:16 -0000 1.3
***************
*** 15,90 ****
"""
- import string
- _string = string
- del string
-
- from xml.dom import HierarchyRequestErr, EMPTY_NAMESPACE
-
- # localize the types, and allow support for Unicode values if available:
- import types
[...2467 lines suppressed...]
! {'parser': parser, 'bufsize': bufsize})
! def parseString(string, parser=None):
"""Parse a file into a DOM from a string."""
! if parser is None:
! from xml.dom import expatbuilder
! return expatbuilder.parseString(string)
! else:
! from xml.dom import pulldom
! return _do_pulldom_parse(pulldom.parseString, (string,),
! {'parser': parser})
! def getDOMImplementation(features=None):
! if features:
! if isinstance(features, StringTypes):
! features = domreg._parse_feature_string(features)
! for f, v in features:
! if not Document.implementation.hasFeature(f, v):
! return None
return Document.implementation
Index: pulldom.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/python-lib/xml/dom/pulldom.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** pulldom.py 1 Jul 2002 02:00:11 -0000 1.1.1.1
--- pulldom.py 10 Nov 2003 12:44:16 -0000 1.2
***************
*** 22,25 ****
--- 22,26 ----
def __init__(self, documentFactory=None):
+ from xml.dom import XML_NAMESPACE
self.documentFactory = documentFactory
self.firstEvent = [None, None]
***************
*** 32,36 ****
# use class' pop instead
pass
! self._ns_contexts = [{}] # contains uri -> prefix dicts
self._current_context = self._ns_contexts[-1]
self.pending_events = []
--- 33,37 ----
# use class' pop instead
pass
! self._ns_contexts = [{XML_NAMESPACE:'xml'}] # contains uri -> prefix dicts
self._current_context = self._ns_contexts[-1]
self.pending_events = []
***************
*** 227,230 ****
--- 228,240 ----
return rc
raise IndexError
+
+ def next(self):
+ rc = self.getEvent()
+ if rc:
+ return rc
+ raise StopIteration
+
+ def __iter__(self):
+ return self
def expandNode(self, node):
|