summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2005-12-14 06:20:35 (GMT)
committerFred Drake <fdrake@acm.org>2005-12-14 06:20:35 (GMT)
commitc6730e1772f52b99feaffb95cdb7774905340d52 (patch)
tree0f125cf464348edd71c41f35c4ecbff8f8fe6114
parentcc117dbb9d925ade41ae3e43ff2292b83b5d9b32 (diff)
downloadcpython-c6730e1772f52b99feaffb95cdb7774905340d52.zip
cpython-c6730e1772f52b99feaffb95cdb7774905340d52.tar.gz
cpython-c6730e1772f52b99feaffb95cdb7774905340d52.tar.bz2
move the xml package implementation to xmlcore, and adjust the tests to
test that package, not the xmlcore/PyXML switcheroo fiasco in the xml module/package
-rw-r--r--Lib/test/test_minidom.py92
-rw-r--r--Lib/test/test_sax.py26
-rw-r--r--Lib/test/test_xml_etree.py20
-rw-r--r--Lib/xml.py (renamed from Lib/xml/__init__.py)8
-rw-r--r--Lib/xmlcore/dom/NodeFilter.py (renamed from Lib/xml/dom/NodeFilter.py)0
-rw-r--r--Lib/xmlcore/dom/__init__.py (renamed from Lib/xml/dom/__init__.py)0
-rw-r--r--Lib/xmlcore/dom/domreg.py (renamed from Lib/xml/dom/domreg.py)2
-rw-r--r--Lib/xmlcore/dom/expatbuilder.py (renamed from Lib/xml/dom/expatbuilder.py)12
-rw-r--r--Lib/xmlcore/dom/minicompat.py (renamed from Lib/xml/dom/minicompat.py)8
-rw-r--r--Lib/xmlcore/dom/minidom.py (renamed from Lib/xml/dom/minidom.py)146
-rw-r--r--Lib/xmlcore/dom/pulldom.py (renamed from Lib/xml/dom/pulldom.py)18
-rw-r--r--Lib/xmlcore/dom/xmlbuilder.py (renamed from Lib/xml/dom/xmlbuilder.py)24
-rw-r--r--Lib/xmlcore/etree/ElementInclude.py (renamed from Lib/xml/etree/ElementInclude.py)0
-rw-r--r--Lib/xmlcore/etree/ElementPath.py (renamed from Lib/xml/etree/ElementPath.py)0
-rw-r--r--Lib/xmlcore/etree/ElementTree.py (renamed from Lib/xml/etree/ElementTree.py)4
-rw-r--r--Lib/xmlcore/etree/__init__.py (renamed from Lib/xml/etree/__init__.py)0
-rw-r--r--Lib/xmlcore/parsers/__init__.py (renamed from Lib/xml/parsers/__init__.py)0
-rw-r--r--Lib/xmlcore/parsers/expat.py (renamed from Lib/xml/parsers/expat.py)0
-rw-r--r--Lib/xmlcore/sax/__init__.py (renamed from Lib/xml/sax/__init__.py)4
-rw-r--r--Lib/xmlcore/sax/_exceptions.py (renamed from Lib/xml/sax/_exceptions.py)0
-rw-r--r--Lib/xmlcore/sax/expatreader.py (renamed from Lib/xml/sax/expatreader.py)26
-rw-r--r--Lib/xmlcore/sax/handler.py (renamed from Lib/xml/sax/handler.py)0
-rw-r--r--Lib/xmlcore/sax/saxutils.py (renamed from Lib/xml/sax/saxutils.py)0
-rw-r--r--Lib/xmlcore/sax/xmlreader.py (renamed from Lib/xml/sax/xmlreader.py)0
24 files changed, 196 insertions, 194 deletions
diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
index 68aac0f..2510a41 100644
--- a/Lib/test/test_minidom.py
+++ b/Lib/test/test_minidom.py
@@ -1,4 +1,4 @@
-# test for xml.dom.minidom
+# test for xmlcore.dom.minidom
import os
import sys
@@ -7,12 +7,12 @@ import traceback
from StringIO import StringIO
from test.test_support import verbose
-import xml.dom
-import xml.dom.minidom
-import xml.parsers.expat
+import xmlcore.dom
+import xmlcore.dom.minidom
+import xmlcore.parsers.expat
-from xml.dom.minidom import parse, Node, Document, parseString
-from xml.dom.minidom import getDOMImplementation
+from xmlcore.dom.minidom import parse, Node, Document, parseString
+from xmlcore.dom.minidom import getDOMImplementation
if __name__ == "__main__":
@@ -138,29 +138,29 @@ def testLegalChildren():
text = dom.createTextNode('text')
try: dom.appendChild(text)
- except xml.dom.HierarchyRequestErr: pass
+ except xmlcore.dom.HierarchyRequestErr: pass
else:
print "dom.appendChild didn't raise HierarchyRequestErr"
dom.appendChild(elem)
try: dom.insertBefore(text, elem)
- except xml.dom.HierarchyRequestErr: pass
+ except xmlcore.dom.HierarchyRequestErr: pass
else:
print "dom.appendChild didn't raise HierarchyRequestErr"
try: dom.replaceChild(text, elem)
- except xml.dom.HierarchyRequestErr: pass
+ except xmlcore.dom.HierarchyRequestErr: pass
else:
print "dom.appendChild didn't raise HierarchyRequestErr"
nodemap = elem.attributes
try: nodemap.setNamedItem(text)
- except xml.dom.HierarchyRequestErr: pass
+ except xmlcore.dom.HierarchyRequestErr: pass
else:
print "NamedNodeMap.setNamedItem didn't raise HierarchyRequestErr"
try: nodemap.setNamedItemNS(text)
- except xml.dom.HierarchyRequestErr: pass
+ except xmlcore.dom.HierarchyRequestErr: pass
else:
print "NamedNodeMap.setNamedItemNS didn't raise HierarchyRequestErr"
@@ -439,7 +439,7 @@ def testProcessingInstruction():
and pi.firstChild is None
and pi.lastChild is None
and pi.localName is None
- and pi.namespaceURI == xml.dom.EMPTY_NAMESPACE)
+ and pi.namespaceURI == xmlcore.dom.EMPTY_NAMESPACE)
def testProcessingInstructionRepr(): pass
@@ -454,7 +454,7 @@ def testTooManyDocumentElements():
elem = doc.createElement("extra")
try:
doc.appendChild(elem)
- except xml.dom.HierarchyRequestErr:
+ except xmlcore.dom.HierarchyRequestErr:
pass
else:
print "Failed to catch expected exception when" \
@@ -491,7 +491,7 @@ def testRemoveNamedItem():
confirm(a1.isSameNode(a2))
try:
attrs.removeNamedItem("a")
- except xml.dom.NotFoundErr:
+ except xmlcore.dom.NotFoundErr:
pass
def testRemoveNamedItemNS():
@@ -503,7 +503,7 @@ def testRemoveNamedItemNS():
confirm(a1.isSameNode(a2))
try:
attrs.removeNamedItemNS("http://xml.python.org/", "b")
- except xml.dom.NotFoundErr:
+ except xmlcore.dom.NotFoundErr:
pass
def testAttrListValues(): pass
@@ -682,7 +682,7 @@ def check_import_document(deep, testName):
doc2 = parseString("<doc/>")
try:
doc1.importNode(doc2, deep)
- except xml.dom.NotSupportedErr:
+ except xmlcore.dom.NotSupportedErr:
pass
else:
raise Exception(testName +
@@ -705,12 +705,14 @@ def create_nonempty_doctype():
doctype = getDOMImplementation().createDocumentType("doc", None, None)
doctype.entities._seq = []
doctype.notations._seq = []
- notation = xml.dom.minidom.Notation("my-notation", None,
- "http://xml.python.org/notations/my")
+ notation = xmlcore.dom.minidom.Notation(
+ "my-notation", None,
+ "http://xml.python.org/notations/my")
doctype.notations._seq.append(notation)
- entity = xml.dom.minidom.Entity("my-entity", None,
- "http://xml.python.org/entities/my",
- "my-notation")
+ entity = xmlcore.dom.minidom.Entity(
+ "my-entity", None,
+ "http://xml.python.org/entities/my",
+ "my-notation")
entity.version = "1.0"
entity.encoding = "utf-8"
entity.actualEncoding = "us-ascii"
@@ -729,7 +731,7 @@ def testImportDocumentTypeShallow():
target = create_doc_without_doctype()
try:
imported = target.importNode(src.doctype, 0)
- except xml.dom.NotSupportedErr:
+ except xmlcore.dom.NotSupportedErr:
pass
else:
raise Exception(
@@ -740,7 +742,7 @@ def testImportDocumentTypeDeep():
target = create_doc_without_doctype()
try:
imported = target.importNode(src.doctype, 1)
- except xml.dom.NotSupportedErr:
+ except xmlcore.dom.NotSupportedErr:
pass
else:
raise Exception(
@@ -848,7 +850,7 @@ def testNodeListItem():
doc.unlink()
def testSAX2DOM():
- from xml.dom import pulldom
+ from xmlcore.dom import pulldom
sax2dom = pulldom.SAX2DOM()
sax2dom.startDocument()
@@ -938,11 +940,11 @@ def testRenameAttribute():
attr = elem.attributes['a']
# Simple renaming
- attr = doc.renameNode(attr, xml.dom.EMPTY_NAMESPACE, "b")
+ attr = doc.renameNode(attr, xmlcore.dom.EMPTY_NAMESPACE, "b")
confirm(attr.name == "b"
and attr.nodeName == "b"
and attr.localName is None
- and attr.namespaceURI == xml.dom.EMPTY_NAMESPACE
+ and attr.namespaceURI == xmlcore.dom.EMPTY_NAMESPACE
and attr.prefix is None
and attr.value == "v"
and elem.getAttributeNode("a") is None
@@ -987,11 +989,11 @@ def testRenameAttribute():
and attrmap[("http://xml.python.org/ns2", "d")].isSameNode(attr))
# Rename back to a simple non-NS node
- attr = doc.renameNode(attr, xml.dom.EMPTY_NAMESPACE, "e")
+ attr = doc.renameNode(attr, xmlcore.dom.EMPTY_NAMESPACE, "e")
confirm(attr.name == "e"
and attr.nodeName == "e"
and attr.localName is None
- and attr.namespaceURI == xml.dom.EMPTY_NAMESPACE
+ and attr.namespaceURI == xmlcore.dom.EMPTY_NAMESPACE
and attr.prefix is None
and attr.value == "v"
and elem.getAttributeNode("a") is None
@@ -1005,7 +1007,7 @@ def testRenameAttribute():
try:
doc.renameNode(attr, "http://xml.python.org/ns", "xmlns")
- except xml.dom.NamespaceErr:
+ except xmlcore.dom.NamespaceErr:
pass
else:
print "expected NamespaceErr"
@@ -1018,11 +1020,11 @@ def testRenameElement():
elem = doc.documentElement
# Simple renaming
- elem = doc.renameNode(elem, xml.dom.EMPTY_NAMESPACE, "a")
+ elem = doc.renameNode(elem, xmlcore.dom.EMPTY_NAMESPACE, "a")
confirm(elem.tagName == "a"
and elem.nodeName == "a"
and elem.localName is None
- and elem.namespaceURI == xml.dom.EMPTY_NAMESPACE
+ and elem.namespaceURI == xmlcore.dom.EMPTY_NAMESPACE
and elem.prefix is None
and elem.ownerDocument.isSameNode(doc))
@@ -1045,11 +1047,11 @@ def testRenameElement():
and elem.ownerDocument.isSameNode(doc))
# Rename back to a simple non-NS node
- elem = doc.renameNode(elem, xml.dom.EMPTY_NAMESPACE, "d")
+ elem = doc.renameNode(elem, xmlcore.dom.EMPTY_NAMESPACE, "d")
confirm(elem.tagName == "d"
and elem.nodeName == "d"
and elem.localName is None
- and elem.namespaceURI == xml.dom.EMPTY_NAMESPACE
+ and elem.namespaceURI == xmlcore.dom.EMPTY_NAMESPACE
and elem.prefix is None
and elem.ownerDocument.isSameNode(doc))
@@ -1060,15 +1062,15 @@ def checkRenameNodeSharedConstraints(doc, node):
# Make sure illegal NS usage is detected:
try:
doc.renameNode(node, "http://xml.python.org/ns", "xmlns:foo")
- except xml.dom.NamespaceErr:
+ except xmlcore.dom.NamespaceErr:
pass
else:
print "expected NamespaceErr"
doc2 = parseString("<doc/>")
try:
- doc2.renameNode(node, xml.dom.EMPTY_NAMESPACE, "foo")
- except xml.dom.WrongDocumentErr:
+ doc2.renameNode(node, xmlcore.dom.EMPTY_NAMESPACE, "foo")
+ except xmlcore.dom.WrongDocumentErr:
pass
else:
print "expected WrongDocumentErr"
@@ -1076,12 +1078,12 @@ def checkRenameNodeSharedConstraints(doc, node):
def testRenameOther():
# We have to create a comment node explicitly since not all DOM
# builders used with minidom add comments to the DOM.
- doc = xml.dom.minidom.getDOMImplementation().createDocument(
- xml.dom.EMPTY_NAMESPACE, "e", None)
+ doc = xmlcore.dom.minidom.getDOMImplementation().createDocument(
+ xmlcore.dom.EMPTY_NAMESPACE, "e", None)
node = doc.createComment("comment")
try:
- doc.renameNode(node, xml.dom.EMPTY_NAMESPACE, "foo")
- except xml.dom.NotSupportedErr:
+ doc.renameNode(node, xmlcore.dom.EMPTY_NAMESPACE, "foo")
+ except xmlcore.dom.NotSupportedErr:
pass
else:
print "expected NotSupportedErr when renaming comment node"
@@ -1192,13 +1194,13 @@ def testSchemaType():
# since each supports a different level of DTD information.
t = elem.schemaType
confirm(t.name is None
- and t.namespace == xml.dom.EMPTY_NAMESPACE)
+ and t.namespace == xmlcore.dom.EMPTY_NAMESPACE)
names = "id notid text enum ref refs ent ents nm nms".split()
for name in names:
a = elem.getAttributeNode(name)
t = a.schemaType
confirm(hasattr(t, "name")
- and t.namespace == xml.dom.EMPTY_NAMESPACE)
+ and t.namespace == xmlcore.dom.EMPTY_NAMESPACE)
def testSetIdAttribute():
doc = parseString("<doc a1='v' a2='w'/>")
@@ -1227,7 +1229,7 @@ def testSetIdAttribute():
and a2.isId
and not a3.isId)
# renaming an attribute should not affect its ID-ness:
- doc.renameNode(a2, xml.dom.EMPTY_NAMESPACE, "an")
+ doc.renameNode(a2, xmlcore.dom.EMPTY_NAMESPACE, "an")
confirm(e.isSameNode(doc.getElementById("w"))
and a2.isId)
@@ -1263,7 +1265,7 @@ def testSetIdAttributeNS():
confirm(not a3.isId)
confirm(doc.getElementById("v") is None)
# renaming an attribute should not affect its ID-ness:
- doc.renameNode(a2, xml.dom.EMPTY_NAMESPACE, "an")
+ doc.renameNode(a2, xmlcore.dom.EMPTY_NAMESPACE, "an")
confirm(e.isSameNode(doc.getElementById("w"))
and a2.isId)
@@ -1299,7 +1301,7 @@ def testSetIdAttributeNode():
confirm(not a3.isId)
confirm(doc.getElementById("v") is None)
# renaming an attribute should not affect its ID-ness:
- doc.renameNode(a2, xml.dom.EMPTY_NAMESPACE, "an")
+ doc.renameNode(a2, xmlcore.dom.EMPTY_NAMESPACE, "an")
confirm(e.isSameNode(doc.getElementById("w"))
and a2.isId)
diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py
index 210ca19..ded81fb 100644
--- a/Lib/test/test_sax.py
+++ b/Lib/test/test_sax.py
@@ -1,17 +1,17 @@
# regression test for SAX 2.0 -*- coding: iso-8859-1 -*-
# $Id$
-from xml.sax import make_parser, ContentHandler, \
- SAXException, SAXReaderNotAvailable, SAXParseException
+from xmlcore.sax import make_parser, ContentHandler, \
+ SAXException, SAXReaderNotAvailable, SAXParseException
try:
make_parser()
except SAXReaderNotAvailable:
# don't try to test this module if we cannot create a parser
raise ImportError("no XML parsers available")
-from xml.sax.saxutils import XMLGenerator, escape, unescape, quoteattr, \
- XMLFilterBase
-from xml.sax.expatreader import create_parser
-from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl
+from xmlcore.sax.saxutils import XMLGenerator, escape, unescape, quoteattr, \
+ XMLFilterBase
+from xmlcore.sax.expatreader import create_parser
+from xmlcore.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl
from cStringIO import StringIO
from test.test_support import verify, verbose, TestFailed, findfile
import os
@@ -36,17 +36,17 @@ def test_make_parser2():
# Creating parsers several times in a row should succeed.
# Testing this because there have been failures of this kind
# before.
- from xml.sax import make_parser
+ from xmlcore.sax import make_parser
p = make_parser()
- from xml.sax import make_parser
+ from xmlcore.sax import make_parser
p = make_parser()
- from xml.sax import make_parser
+ from xmlcore.sax import make_parser
p = make_parser()
- from xml.sax import make_parser
+ from xmlcore.sax import make_parser
p = make_parser()
- from xml.sax import make_parser
+ from xmlcore.sax import make_parser
p = make_parser()
- from xml.sax import make_parser
+ from xmlcore.sax import make_parser
p = make_parser()
except:
return 0
@@ -108,7 +108,7 @@ def test_make_parser():
try:
# Creating a parser should succeed - it should fall back
# to the expatreader
- p = make_parser(['xml.parsers.no_such_parser'])
+ p = make_parser(['xmlcore.parsers.no_such_parser'])
except:
return 0
else:
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index 1ceb5f1..94f6b31 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -1,4 +1,4 @@
-# xml.etree test. This file contains enough tests to make sure that
+# xmlcore.etree test. This file contains enough tests to make sure that
# all included components work as they should. For a more extensive
# test suite, see the selftest script in the ElementTree distribution.
@@ -30,9 +30,9 @@ def sanity():
"""
Import sanity.
- >>> from xml.etree import ElementTree
- >>> from xml.etree import ElementInclude
- >>> from xml.etree import ElementPath
+ >>> from xmlcore.etree import ElementTree
+ >>> from xmlcore.etree import ElementInclude
+ >>> from xmlcore.etree import ElementPath
"""
def check_method(method):
@@ -59,7 +59,7 @@ def interface():
"""
Test element tree interface.
- >>> from xml.etree import ElementTree as ET
+ >>> from xmlcore.etree import ElementTree as ET
>>> element = ET.Element("tag", key="value")
>>> tree = ET.ElementTree(element)
@@ -108,7 +108,7 @@ def find():
"""
Test find methods (including xpath syntax).
- >>> from xml.etree import ElementTree as ET
+ >>> from xmlcore.etree import ElementTree as ET
>>> elem = ET.XML(SAMPLE_XML)
>>> elem.find("tag").tag
@@ -176,7 +176,7 @@ def find():
def parseliteral():
r"""
- >>> from xml.etree import ElementTree as ET
+ >>> from xmlcore.etree import ElementTree as ET
>>> element = ET.XML("<html><body>text</body></html>")
>>> ET.ElementTree(element).write(sys.stdout)
@@ -273,7 +273,7 @@ def xinclude_loader(href, parse="xml", encoding=None):
except KeyError:
raise IOError("resource not found")
if parse == "xml":
- from xml.etree.ElementTree import XML
+ from xmlcore.etree.ElementTree import XML
return XML(data)
return data
@@ -281,8 +281,8 @@ def xinclude():
r"""
Basic inclusion example (XInclude C.1)
- >>> from xml.etree import ElementTree as ET
- >>> from xml.etree import ElementInclude
+ >>> from xmlcore.etree import ElementTree as ET
+ >>> from xmlcore.etree import ElementInclude
>>> document = xinclude_loader("C1.xml")
>>> ElementInclude.include(document, xinclude_loader)
diff --git a/Lib/xml/__init__.py b/Lib/xml.py
index fa5e8cd..7393c66 100644
--- a/Lib/xml/__init__.py
+++ b/Lib/xml.py
@@ -16,6 +16,8 @@ etree -- The ElementTree XML library. This is a subset of the full
"""
+import sys
+import xmlcore
__all__ = ["dom", "parsers", "sax", "etree"]
@@ -27,11 +29,10 @@ __version__ = "$Revision$".split()[-2:][0]
_MINIMUM_XMLPLUS_VERSION = (0, 8, 4)
-
try:
import _xmlplus
except ImportError:
- pass
+ sys.modules[__name__] = xmlcore
else:
try:
v = _xmlplus.version_info
@@ -40,8 +41,7 @@ else:
pass
else:
if v >= _MINIMUM_XMLPLUS_VERSION:
- import sys
- _xmlplus.__path__.extend(__path__)
+ _xmlplus.__path__.extend(xmlcore.__path__)
sys.modules[__name__] = _xmlplus
else:
del v
diff --git a/Lib/xml/dom/NodeFilter.py b/Lib/xmlcore/dom/NodeFilter.py
index fc05245..fc05245 100644
--- a/Lib/xml/dom/NodeFilter.py
+++ b/Lib/xmlcore/dom/NodeFilter.py
diff --git a/Lib/xml/dom/__init__.py b/Lib/xmlcore/dom/__init__.py
index 6363d00..6363d00 100644
--- a/Lib/xml/dom/__init__.py
+++ b/Lib/xmlcore/dom/__init__.py
diff --git a/Lib/xml/dom/domreg.py b/Lib/xmlcore/dom/domreg.py
index 684c436..d60ed64 100644
--- a/Lib/xml/dom/domreg.py
+++ b/Lib/xmlcore/dom/domreg.py
@@ -2,7 +2,7 @@
directly. Instead, the functions getDOMImplementation and
registerDOMImplementation should be imported from xml.dom."""
-from xml.dom.minicompat import * # isinstance, StringTypes
+from xmlcore.dom.minicompat import * # isinstance, StringTypes
# This is a list of well-known implementations. Well-known names
# should be published by posting to xml-sig@python.org, and are
diff --git a/Lib/xml/dom/expatbuilder.py b/Lib/xmlcore/dom/expatbuilder.py
index 47d81fb..81d9c2b 100644
--- a/Lib/xml/dom/expatbuilder.py
+++ b/Lib/xmlcore/dom/expatbuilder.py
@@ -27,13 +27,13 @@ This avoids all the overhead of SAX and pulldom to gain performance.
# calling any methods on the node object if it exists. (A rather
# nice speedup is achieved this way as well!)
-from xml.dom import xmlbuilder, minidom, Node
-from xml.dom import EMPTY_NAMESPACE, EMPTY_PREFIX, XMLNS_NAMESPACE
-from xml.parsers import expat
-from xml.dom.minidom import _append_child, _set_attribute_node
-from xml.dom.NodeFilter import NodeFilter
+from xmlcore.dom import xmlbuilder, minidom, Node
+from xmlcore.dom import EMPTY_NAMESPACE, EMPTY_PREFIX, XMLNS_NAMESPACE
+from xmlcore.parsers import expat
+from xmlcore.dom.minidom import _append_child, _set_attribute_node
+from xmlcore.dom.NodeFilter import NodeFilter
-from xml.dom.minicompat import *
+from xmlcore.dom.minicompat import *
TEXT_NODE = Node.TEXT_NODE
CDATA_SECTION_NODE = Node.CDATA_SECTION_NODE
diff --git a/Lib/xml/dom/minicompat.py b/Lib/xmlcore/dom/minicompat.py
index 9f2f8f7..364ca45 100644
--- a/Lib/xml/dom/minicompat.py
+++ b/Lib/xmlcore/dom/minicompat.py
@@ -50,7 +50,7 @@
__all__ = ["NodeList", "EmptyNodeList", "NewStyle",
"StringTypes", "defproperty", "GetattrMagic"]
-import xml.dom
+import xmlcore.dom
try:
unicode
@@ -100,7 +100,7 @@ if list is type([]):
return len(self)
def _set_length(self, value):
- raise xml.dom.NoModificationAllowedErr(
+ raise xmlcore.dom.NoModificationAllowedErr(
"attempt to modify read-only attribute 'length'")
length = property(_get_length, _set_length,
@@ -132,7 +132,7 @@ if list is type([]):
return 0
def _set_length(self, value):
- raise xml.dom.NoModificationAllowedErr(
+ raise xmlcore.dom.NoModificationAllowedErr(
"attempt to modify read-only attribute 'length'")
length = property(_get_length, _set_length,
@@ -171,7 +171,7 @@ else:
def defproperty(klass, name, doc):
get = getattr(klass, ("_get_" + name)).im_func
def set(self, value, name=name):
- raise xml.dom.NoModificationAllowedErr(
+ raise xmlcore.dom.NoModificationAllowedErr(
"attempt to modify read-only attribute " + repr(name))
assert not hasattr(klass, "_set_" + name), \
"expected not to find _set_" + name
diff --git a/Lib/xml/dom/minidom.py b/Lib/xmlcore/dom/minidom.py
index 84be99b..54620e1 100644
--- a/Lib/xml/dom/minidom.py
+++ b/Lib/xmlcore/dom/minidom.py
@@ -14,11 +14,11 @@ Todo:
* SAX 2 namespaces
"""
-import xml.dom
+import xmlcore.dom
-from xml.dom import EMPTY_NAMESPACE, EMPTY_PREFIX, XMLNS_NAMESPACE, domreg
-from xml.dom.minicompat import *
-from xml.dom.xmlbuilder import DOMImplementationLS, DocumentLS
+from xmlcore.dom import EMPTY_NAMESPACE, EMPTY_PREFIX, XMLNS_NAMESPACE, domreg
+from xmlcore.dom.minicompat import *
+from xmlcore.dom.xmlbuilder import DOMImplementationLS, DocumentLS
_TupleType = type(())
@@ -27,11 +27,11 @@ _TupleType = type(())
# DOCUMENT_NODE or DOCUMENT_FRAGMENT_NODE. (The node being checked is
# the node being added or removed, not the node being modified.)
#
-_nodeTypes_with_children = (xml.dom.Node.ELEMENT_NODE,
- xml.dom.Node.ENTITY_REFERENCE_NODE)
+_nodeTypes_with_children = (xmlcore.dom.Node.ELEMENT_NODE,
+ xmlcore.dom.Node.ENTITY_REFERENCE_NODE)
-class Node(xml.dom.Node, GetattrMagic):
+class Node(xmlcore.dom.Node, GetattrMagic):
namespaceURI = None # this is non-null only for elements and attributes
parentNode = None
ownerDocument = None
@@ -85,7 +85,7 @@ class Node(xml.dom.Node, GetattrMagic):
### The DOM does not clearly specify what to return in this case
return newChild
if newChild.nodeType not in self._child_node_types:
- raise xml.dom.HierarchyRequestErr(
+ raise xmlcore.dom.HierarchyRequestErr(
"%s cannot be child of %s" % (repr(newChild), repr(self)))
if newChild.parentNode is not None:
newChild.parentNode.removeChild(newChild)
@@ -95,7 +95,7 @@ class Node(xml.dom.Node, GetattrMagic):
try:
index = self.childNodes.index(refChild)
except ValueError:
- raise xml.dom.NotFoundErr()
+ raise xmlcore.dom.NotFoundErr()
if newChild.nodeType in _nodeTypes_with_children:
_clear_id_cache(self)
self.childNodes.insert(index, newChild)
@@ -117,7 +117,7 @@ class Node(xml.dom.Node, GetattrMagic):
### The DOM does not clearly specify what to return in this case
return node
if node.nodeType not in self._child_node_types:
- raise xml.dom.HierarchyRequestErr(
+ raise xmlcore.dom.HierarchyRequestErr(
"%s cannot be child of %s" % (repr(node), repr(self)))
elif node.nodeType in _nodeTypes_with_children:
_clear_id_cache(self)
@@ -133,7 +133,7 @@ class Node(xml.dom.Node, GetattrMagic):
self.removeChild(oldChild)
return self.insertBefore(newChild, refChild)
if newChild.nodeType not in self._child_node_types:
- raise xml.dom.HierarchyRequestErr(
+ raise xmlcore.dom.HierarchyRequestErr(
"%s cannot be child of %s" % (repr(newChild), repr(self)))
if newChild is oldChild:
return
@@ -142,7 +142,7 @@ class Node(xml.dom.Node, GetattrMagic):
try:
index = self.childNodes.index(oldChild)
except ValueError:
- raise xml.dom.NotFoundErr()
+ raise xmlcore.dom.NotFoundErr()
self.childNodes[index] = newChild
newChild.parentNode = self
oldChild.parentNode = None
@@ -163,7 +163,7 @@ class Node(xml.dom.Node, GetattrMagic):
try:
self.childNodes.remove(oldChild)
except ValueError:
- raise xml.dom.NotFoundErr()
+ raise xmlcore.dom.NotFoundErr()
if oldChild.nextSibling is not None:
oldChild.nextSibling.previousSibling = oldChild.previousSibling
if oldChild.previousSibling is not None:
@@ -388,7 +388,7 @@ class Attr(Node):
nsuri = self.namespaceURI
if prefix == "xmlns":
if nsuri and nsuri != XMLNS_NAMESPACE:
- raise xml.dom.NamespaceErr(
+ raise xmlcore.dom.NamespaceErr(
"illegal use of 'xmlns' prefix for the wrong namespace")
d = self.__dict__
d['prefix'] = prefix
@@ -566,7 +566,7 @@ class NamedNodeMap(NewStyle, GetattrMagic):
n.__dict__['ownerElement'] = None
return n
else:
- raise xml.dom.NotFoundErr()
+ raise xmlcore.dom.NotFoundErr()
def removeNamedItemNS(self, namespaceURI, localName):
n = self.getNamedItemNS(namespaceURI, localName)
@@ -578,11 +578,11 @@ class NamedNodeMap(NewStyle, GetattrMagic):
n.__dict__['ownerElement'] = None
return n
else:
- raise xml.dom.NotFoundErr()
+ raise xmlcore.dom.NotFoundErr()
def setNamedItem(self, node):
if not isinstance(node, Attr):
- raise xml.dom.HierarchyRequestErr(
+ raise xmlcore.dom.HierarchyRequestErr(
"%s cannot be child of %s" % (repr(node), repr(self)))
old = self._attrs.get(node.name)
if old:
@@ -733,7 +733,7 @@ class Element(Node):
def setAttributeNode(self, attr):
if attr.ownerElement not in (None, self):
- raise xml.dom.InuseAttributeErr("attribute node already owned")
+ raise xmlcore.dom.InuseAttributeErr("attribute node already owned")
old1 = self._attrs.get(attr.name, None)
if old1 is not None:
self.removeAttributeNode(old1)
@@ -755,23 +755,23 @@ class Element(Node):
try:
attr = self._attrs[name]
except KeyError:
- raise xml.dom.NotFoundErr()
+ raise xmlcore.dom.NotFoundErr()
self.removeAttributeNode(attr)
def removeAttributeNS(self, namespaceURI, localName):
try:
attr = self._attrsNS[(namespaceURI, localName)]
except KeyError:
- raise xml.dom.NotFoundErr()
+ raise xmlcore.dom.NotFoundErr()
self.removeAttributeNode(attr)
def removeAttributeNode(self, node):
if node is None:
- raise xml.dom.NotFoundErr()
+ raise xmlcore.dom.NotFoundErr()
try:
self._attrs[node.name]
except KeyError:
- raise xml.dom.NotFoundErr()
+ raise xmlcore.dom.NotFoundErr()
_clear_id_cache(self)
node.unlink()
# Restore this since the node is still useful and otherwise
@@ -839,9 +839,9 @@ class Element(Node):
def setIdAttributeNode(self, idAttr):
if idAttr is None or not self.isSameNode(idAttr.ownerElement):
- raise xml.dom.NotFoundErr()
+ raise xmlcore.dom.NotFoundErr()
if _get_containing_entref(self) is not None:
- raise xml.dom.NoModificationAllowedErr()
+ raise xmlcore.dom.NoModificationAllowedErr()
if not idAttr._is_id:
idAttr.__dict__['_is_id'] = True
self._magic_id_nodes += 1
@@ -882,22 +882,22 @@ class Childless:
return None
def appendChild(self, node):
- raise xml.dom.HierarchyRequestErr(
+ raise xmlcore.dom.HierarchyRequestErr(
self.nodeName + " nodes cannot have children")
def hasChildNodes(self):
return False
def insertBefore(self, newChild, refChild):
- raise xml.dom.HierarchyRequestErr(
+ raise xmlcore.dom.HierarchyRequestErr(
self.nodeName + " nodes do not have children")
def removeChild(self, oldChild):
- raise xml.dom.NotFoundErr(
+ raise xmlcore.dom.NotFoundErr(
self.nodeName + " nodes do not have children")
def replaceChild(self, newChild, oldChild):
- raise xml.dom.HierarchyRequestErr(
+ raise xmlcore.dom.HierarchyRequestErr(
self.nodeName + " nodes do not have children")
@@ -963,11 +963,11 @@ class CharacterData(Childless, Node):
def substringData(self, offset, count):
if offset < 0:
- raise xml.dom.IndexSizeErr("offset cannot be negative")
+ raise xmlcore.dom.IndexSizeErr("offset cannot be negative")
if offset >= len(self.data):
- raise xml.dom.IndexSizeErr("offset cannot be beyond end of data")
+ raise xmlcore.dom.IndexSizeErr("offset cannot be beyond end of data")
if count < 0:
- raise xml.dom.IndexSizeErr("count cannot be negative")
+ raise xmlcore.dom.IndexSizeErr("count cannot be negative")
return self.data[offset:offset+count]
def appendData(self, arg):
@@ -975,30 +975,30 @@ class CharacterData(Childless, Node):
def insertData(self, offset, arg):
if offset < 0:
- raise xml.dom.IndexSizeErr("offset cannot be negative")
+ raise xmlcore.dom.IndexSizeErr("offset cannot be negative")
if offset >= len(self.data):
- raise xml.dom.IndexSizeErr("offset cannot be beyond end of data")
+ raise xmlcore.dom.IndexSizeErr("offset cannot be beyond end of data")
if arg:
self.data = "%s%s%s" % (
self.data[:offset], arg, self.data[offset:])
def deleteData(self, offset, count):
if offset < 0:
- raise xml.dom.IndexSizeErr("offset cannot be negative")
+ raise xmlcore.dom.IndexSizeErr("offset cannot be negative")
if offset >= len(self.data):
- raise xml.dom.IndexSizeErr("offset cannot be beyond end of data")
+ raise xmlcore.dom.IndexSizeErr("offset cannot be beyond end of data")
if count < 0:
- raise xml.dom.IndexSizeErr("count cannot be negative")
+ raise xmlcore.dom.IndexSizeErr("count cannot be negative")
if count:
self.data = self.data[:offset] + self.data[offset+count:]
def replaceData(self, offset, count, arg):
if offset < 0:
- raise xml.dom.IndexSizeErr("offset cannot be negative")
+ raise xmlcore.dom.IndexSizeErr("offset cannot be negative")
if offset >= len(self.data):
- raise xml.dom.IndexSizeErr("offset cannot be beyond end of data")
+ raise xmlcore.dom.IndexSizeErr("offset cannot be beyond end of data")
if count < 0:
- raise xml.dom.IndexSizeErr("count cannot be negative")
+ raise xmlcore.dom.IndexSizeErr("count cannot be negative")
if count:
self.data = "%s%s%s" % (
self.data[:offset], arg, self.data[offset+count:])
@@ -1018,7 +1018,7 @@ class Text(CharacterData):
def splitText(self, offset):
if offset < 0 or offset > len(self.data):
- raise xml.dom.IndexSizeErr("illegal offset value")
+ raise xmlcore.dom.IndexSizeErr("illegal offset value")
newText = self.__class__()
newText.data = self.data[offset:]
newText.ownerDocument = self.ownerDocument
@@ -1187,19 +1187,19 @@ class ReadOnlySequentialNamedNodeMap(NewStyle, GetattrMagic):
return None
def removeNamedItem(self, name):
- raise xml.dom.NoModificationAllowedErr(
+ raise xmlcore.dom.NoModificationAllowedErr(
"NamedNodeMap instance is read-only")
def removeNamedItemNS(self, namespaceURI, localName):
- raise xml.dom.NoModificationAllowedErr(
+ raise xmlcore.dom.NoModificationAllowedErr(
"NamedNodeMap instance is read-only")
def setNamedItem(self, node):
- raise xml.dom.NoModificationAllowedErr(
+ raise xmlcore.dom.NoModificationAllowedErr(
"NamedNodeMap instance is read-only")
def setNamedItemNS(self, node):
- raise xml.dom.NoModificationAllowedErr(
+ raise xmlcore.dom.NoModificationAllowedErr(
"NamedNodeMap instance is read-only")
def __getstate__(self):
@@ -1253,7 +1253,7 @@ class DocumentType(Identified, Childless, Node):
clone = DocumentType(None)
clone.name = self.name
clone.nodeName = self.name
- operation = xml.dom.UserDataHandler.NODE_CLONED
+ operation = xmlcore.dom.UserDataHandler.NODE_CLONED
if deep:
clone.entities._seq = []
clone.notations._seq = []
@@ -1313,19 +1313,19 @@ class Entity(Identified, Node):
return self.version
def appendChild(self, newChild):
- raise xml.dom.HierarchyRequestErr(
+ raise xmlcore.dom.HierarchyRequestErr(
"cannot append children to an entity node")
def insertBefore(self, newChild, refChild):
- raise xml.dom.HierarchyRequestErr(
+ raise xmlcore.dom.HierarchyRequestErr(
"cannot insert children below an entity node")
def removeChild(self, oldChild):
- raise xml.dom.HierarchyRequestErr(
+ raise xmlcore.dom.HierarchyRequestErr(
"cannot remove children from an entity node")
def replaceChild(self, newChild, oldChild):
- raise xml.dom.HierarchyRequestErr(
+ raise xmlcore.dom.HierarchyRequestErr(
"cannot replace children of an entity node")
class Notation(Identified, Childless, Node):
@@ -1357,7 +1357,7 @@ class DOMImplementation(DOMImplementationLS):
def createDocument(self, namespaceURI, qualifiedName, doctype):
if doctype and doctype.parentNode is not None:
- raise xml.dom.WrongDocumentErr(
+ raise xmlcore.dom.WrongDocumentErr(
"doctype object owned by another DOM tree")
doc = self._create_document()
@@ -1378,15 +1378,15 @@ class DOMImplementation(DOMImplementationLS):
# Null the document is returned without a document element
# Otherwise if doctype or namespaceURI are not None
# Then we go back to the above problem
- raise xml.dom.InvalidCharacterErr("Element with no name")
+ raise xmlcore.dom.InvalidCharacterErr("Element with no name")
if add_root_element:
prefix, localname = _nssplit(qualifiedName)
if prefix == "xml" \
and namespaceURI != "http://www.w3.org/XML/1998/namespace":
- raise xml.dom.NamespaceErr("illegal use of 'xml' prefix")
+ raise xmlcore.dom.NamespaceErr("illegal use of 'xml' prefix")
if prefix and not namespaceURI:
- raise xml.dom.NamespaceErr(
+ raise xmlcore.dom.NamespaceErr(
"illegal use of prefix without namespaces")
element = doc.createElementNS(namespaceURI, qualifiedName)
if doctype:
@@ -1535,7 +1535,7 @@ class Document(Node, DocumentLS):
def appendChild(self, node):
if node.nodeType not in self._child_node_types:
- raise xml.dom.HierarchyRequestErr(
+ raise xmlcore.dom.HierarchyRequestErr(
"%s cannot be child of %s" % (repr(node), repr(self)))
if node.parentNode is not None:
# This needs to be done before the next test since this
@@ -1545,7 +1545,7 @@ class Document(Node, DocumentLS):
if node.nodeType == Node.ELEMENT_NODE \
and self._get_documentElement():
- raise xml.dom.HierarchyRequestErr(
+ raise xmlcore.dom.HierarchyRequestErr(
"two document elements disallowed")
return Node.appendChild(self, node)
@@ -1553,7 +1553,7 @@ class Document(Node, DocumentLS):
try:
self.childNodes.remove(oldChild)
except ValueError:
- raise xml.dom.NotFoundErr()
+ raise xmlcore.dom.NotFoundErr()
oldChild.nextSibling = oldChild.previousSibling = None
oldChild.parentNode = None
if self.documentElement is oldChild:
@@ -1589,7 +1589,7 @@ class Document(Node, DocumentLS):
assert clone.doctype is None
clone.doctype = childclone
childclone.parentNode = clone
- self._call_user_data_handler(xml.dom.UserDataHandler.NODE_CLONED,
+ self._call_user_data_handler(xmlcore.dom.UserDataHandler.NODE_CLONED,
self, clone)
return clone
@@ -1731,9 +1731,9 @@ class Document(Node, DocumentLS):
def importNode(self, node, deep):
if node.nodeType == Node.DOCUMENT_NODE:
- raise xml.dom.NotSupportedErr("cannot import document nodes")
+ raise xmlcore.dom.NotSupportedErr("cannot import document nodes")
elif node.nodeType == Node.DOCUMENT_TYPE_NODE:
- raise xml.dom.NotSupportedErr("cannot import document type nodes")
+ raise xmlcore.dom.NotSupportedErr("cannot import document type nodes")
return _clone_node(node, deep, self)
def writexml(self, writer, indent="", addindent="", newl="",
@@ -1749,24 +1749,24 @@ class Document(Node, DocumentLS):
def renameNode(self, n, namespaceURI, name):
if n.ownerDocument is not self:
- raise xml.dom.WrongDocumentErr(
+ raise xmlcore.dom.WrongDocumentErr(
"cannot rename nodes from other documents;\n"
"expected %s,\nfound %s" % (self, n.ownerDocument))
if n.nodeType not in (Node.ELEMENT_NODE, Node.ATTRIBUTE_NODE):
- raise xml.dom.NotSupportedErr(
+ raise xmlcore.dom.NotSupportedErr(
"renameNode() only applies to element and attribute nodes")
if namespaceURI != EMPTY_NAMESPACE:
if ':' in name:
prefix, localName = name.split(':', 1)
if ( prefix == "xmlns"
- and namespaceURI != xml.dom.XMLNS_NAMESPACE):
- raise xml.dom.NamespaceErr(
+ and namespaceURI != xmlcore.dom.XMLNS_NAMESPACE):
+ raise xmlcore.dom.NamespaceErr(
"illegal use of 'xmlns' prefix")
else:
if ( name == "xmlns"
- and namespaceURI != xml.dom.XMLNS_NAMESPACE
+ and namespaceURI != xmlcore.dom.XMLNS_NAMESPACE
and n.nodeType == Node.ATTRIBUTE_NODE):
- raise xml.dom.NamespaceErr(
+ raise xmlcore.dom.NamespaceErr(
"illegal use of the 'xmlns' attribute")
prefix = None
localName = name
@@ -1812,9 +1812,9 @@ def _clone_node(node, deep, newOwnerDocument):
Called by Node.cloneNode and Document.importNode
"""
if node.ownerDocument.isSameNode(newOwnerDocument):
- operation = xml.dom.UserDataHandler.NODE_CLONED
+ operation = xmlcore.dom.UserDataHandler.NODE_CLONED
else:
- operation = xml.dom.UserDataHandler.NODE_IMPORTED
+ operation = xmlcore.dom.UserDataHandler.NODE_IMPORTED
if node.nodeType == Node.ELEMENT_NODE:
clone = newOwnerDocument.createElementNS(node.namespaceURI,
node.nodeName)
@@ -1851,7 +1851,7 @@ def _clone_node(node, deep, newOwnerDocument):
clone.value = node.value
elif node.nodeType == Node.DOCUMENT_TYPE_NODE:
assert node.ownerDocument is not newOwnerDocument
- operation = xml.dom.UserDataHandler.NODE_IMPORTED
+ operation = xmlcore.dom.UserDataHandler.NODE_IMPORTED
clone = newOwnerDocument.implementation.createDocumentType(
node.name, node.publicId, node.systemId)
clone.ownerDocument = newOwnerDocument
@@ -1878,7 +1878,7 @@ def _clone_node(node, deep, newOwnerDocument):
# Note the cloning of Document and DocumentType nodes is
# implemenetation specific. minidom handles those cases
# directly in the cloneNode() methods.
- raise xml.dom.NotSupportedErr("Cannot clone node %s" % repr(node))
+ raise xmlcore.dom.NotSupportedErr("Cannot clone node %s" % repr(node))
# Check for _call_user_data_handler() since this could conceivably
# used with other DOM implementations (one of the FourThought
@@ -1911,20 +1911,20 @@ def _do_pulldom_parse(func, args, kwargs):
def parse(file, parser=None, bufsize=None):
"""Parse a file into a DOM by filename or file object."""
if parser is None and not bufsize:
- from xml.dom import expatbuilder
+ from xmlcore.dom import expatbuilder
return expatbuilder.parse(file)
else:
- from xml.dom import pulldom
+ from xmlcore.dom import pulldom
return _do_pulldom_parse(pulldom.parse, (file,),
{'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
+ from xmlcore.dom import expatbuilder
return expatbuilder.parseString(string)
else:
- from xml.dom import pulldom
+ from xmlcore.dom import pulldom
return _do_pulldom_parse(pulldom.parseString, (string,),
{'parser': parser})
diff --git a/Lib/xml/dom/pulldom.py b/Lib/xmlcore/dom/pulldom.py
index 18f49b5..dad3718 100644
--- a/Lib/xml/dom/pulldom.py
+++ b/Lib/xmlcore/dom/pulldom.py
@@ -1,5 +1,5 @@
-import xml.sax
-import xml.sax.handler
+import xmlcore.sax
+import xmlcore.sax.handler
import types
try:
@@ -16,12 +16,12 @@ PROCESSING_INSTRUCTION = "PROCESSING_INSTRUCTION"
IGNORABLE_WHITESPACE = "IGNORABLE_WHITESPACE"
CHARACTERS = "CHARACTERS"
-class PullDOM(xml.sax.ContentHandler):
+class PullDOM(xmlcore.sax.ContentHandler):
_locator = None
document = None
def __init__(self, documentFactory=None):
- from xml.dom import XML_NAMESPACE
+ from xmlcore.dom import XML_NAMESPACE
self.documentFactory = documentFactory
self.firstEvent = [None, None]
self.lastEvent = self.firstEvent
@@ -164,8 +164,8 @@ class PullDOM(xml.sax.ContentHandler):
def startDocument(self):
if self.documentFactory is None:
- import xml.dom.minidom
- self.documentFactory = xml.dom.minidom.Document.implementation
+ import xmlcore.dom.minidom
+ self.documentFactory = xmlcore.dom.minidom.Document.implementation
def buildDocument(self, uri, tagname):
# Can't do that in startDocument, since we need the tagname
@@ -219,7 +219,7 @@ class DOMEventStream:
def reset(self):
self.pulldom = PullDOM()
# This content handler relies on namespace support
- self.parser.setFeature(xml.sax.handler.feature_namespaces, 1)
+ self.parser.setFeature(xmlcore.sax.handler.feature_namespaces, 1)
self.parser.setContentHandler(self.pulldom)
def __getitem__(self, pos):
@@ -335,7 +335,7 @@ def parse(stream_or_string, parser=None, bufsize=None):
else:
stream = stream_or_string
if not parser:
- parser = xml.sax.make_parser()
+ parser = xmlcore.sax.make_parser()
return DOMEventStream(stream, parser, bufsize)
def parseString(string, parser=None):
@@ -347,5 +347,5 @@ def parseString(string, parser=None):
bufsize = len(string)
buf = StringIO(string)
if not parser:
- parser = xml.sax.make_parser()
+ parser = xmlcore.sax.make_parser()
return DOMEventStream(buf, parser, bufsize)
diff --git a/Lib/xml/dom/xmlbuilder.py b/Lib/xmlcore/dom/xmlbuilder.py
index 5c04412..d58c723 100644
--- a/Lib/xml/dom/xmlbuilder.py
+++ b/Lib/xmlcore/dom/xmlbuilder.py
@@ -1,11 +1,11 @@
"""Implementation of the DOM Level 3 'LS-Load' feature."""
import copy
-import xml.dom
+import xmlcore.dom
-from xml.dom.minicompat import *
+from xmlcore.dom.minicompat import *
-from xml.dom.NodeFilter import NodeFilter
+from xmlcore.dom.NodeFilter import NodeFilter
__all__ = ["DOMBuilder", "DOMEntityResolver", "DOMInputSource"]
@@ -80,13 +80,13 @@ class DOMBuilder:
try:
settings = self._settings[(_name_xform(name), state)]
except KeyError:
- raise xml.dom.NotSupportedErr(
+ raise xmlcore.dom.NotSupportedErr(
"unsupported feature: %r" % (name,))
else:
for name, value in settings:
setattr(self._options, name, value)
else:
- raise xml.dom.NotFoundErr("unknown feature: " + repr(name))
+ raise xmlcore.dom.NotFoundErr("unknown feature: " + repr(name))
def supportsFeature(self, name):
return hasattr(self._options, _name_xform(name))
@@ -177,7 +177,7 @@ class DOMBuilder:
or options.create_entity_ref_nodes
or options.entities
or options.cdata_sections))
- raise xml.dom.NotFoundErr("feature %s not known" % repr(name))
+ raise xmlcore.dom.NotFoundErr("feature %s not known" % repr(name))
def parseURI(self, uri):
if self.entityResolver:
@@ -202,8 +202,8 @@ class DOMBuilder:
raise NotImplementedError("Haven't written this yet...")
def _parse_bytestream(self, stream, options):
- import xml.dom.expatbuilder
- builder = xml.dom.expatbuilder.makeBuilder(options)
+ import xmlcore.dom.expatbuilder
+ builder = xmlcore.dom.expatbuilder.makeBuilder(options)
return builder.parseFile(stream)
@@ -342,7 +342,7 @@ class DocumentLS:
return False
def _set_async(self, async):
if async:
- raise xml.dom.NotSupportedErr(
+ raise xmlcore.dom.NotSupportedErr(
"asynchronous document loading is not supported")
def abort(self):
@@ -361,7 +361,7 @@ class DocumentLS:
if snode is None:
snode = self
elif snode.ownerDocument is not self:
- raise xml.dom.WrongDocumentErr()
+ raise xmlcore.dom.WrongDocumentErr()
return snode.toxml()
@@ -371,12 +371,12 @@ class DOMImplementationLS:
def createDOMBuilder(self, mode, schemaType):
if schemaType is not None:
- raise xml.dom.NotSupportedErr(
+ raise xmlcore.dom.NotSupportedErr(
"schemaType not yet supported")
if mode == self.MODE_SYNCHRONOUS:
return DOMBuilder()
if mode == self.MODE_ASYNCHRONOUS:
- raise xml.dom.NotSupportedErr(
+ raise xmlcore.dom.NotSupportedErr(
"asynchronous builders are not supported")
raise ValueError("unknown value for mode")
diff --git a/Lib/xml/etree/ElementInclude.py b/Lib/xmlcore/etree/ElementInclude.py
index 5ee199a..5ee199a 100644
--- a/Lib/xml/etree/ElementInclude.py
+++ b/Lib/xmlcore/etree/ElementInclude.py
diff --git a/Lib/xml/etree/ElementPath.py b/Lib/xmlcore/etree/ElementPath.py
index e8093c6..e8093c6 100644
--- a/Lib/xml/etree/ElementPath.py
+++ b/Lib/xmlcore/etree/ElementPath.py
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xmlcore/etree/ElementTree.py
index bd45251..c18f7ff 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xmlcore/etree/ElementTree.py
@@ -1109,7 +1109,7 @@ class XMLTreeBuilder:
def __init__(self, html=0, target=None):
try:
- from xml.parsers import expat
+ from xmlcore.parsers import expat
except ImportError:
raise ImportError(
"No module named expat; use SimpleXMLTreeBuilder instead"
@@ -1191,7 +1191,7 @@ class XMLTreeBuilder:
try:
self._target.data(self.entity[text[1:-1]])
except KeyError:
- from xml.parsers import expat
+ from xmlcore.parsers import expat
raise expat.error(
"undefined entity %s: line %d, column %d" %
(text, self._parser.ErrorLineNumber,
diff --git a/Lib/xml/etree/__init__.py b/Lib/xmlcore/etree/__init__.py
index ef8d14c..ef8d14c 100644
--- a/Lib/xml/etree/__init__.py
+++ b/Lib/xmlcore/etree/__init__.py
diff --git a/Lib/xml/parsers/__init__.py b/Lib/xmlcore/parsers/__init__.py
index eb314a3..eb314a3 100644
--- a/Lib/xml/parsers/__init__.py
+++ b/Lib/xmlcore/parsers/__init__.py
diff --git a/Lib/xml/parsers/expat.py b/Lib/xmlcore/parsers/expat.py
index 11359a0..11359a0 100644
--- a/Lib/xml/parsers/expat.py
+++ b/Lib/xmlcore/parsers/expat.py
diff --git a/Lib/xml/sax/__init__.py b/Lib/xmlcore/sax/__init__.py
index 6b1b1ba..f1e467c 100644
--- a/Lib/xml/sax/__init__.py
+++ b/Lib/xmlcore/sax/__init__.py
@@ -51,12 +51,12 @@ def parseString(string, handler, errorHandler=ErrorHandler()):
# this is the parser list used by the make_parser function if no
# alternatives are given as parameters to the function
-default_parser_list = ["xml.sax.expatreader"]
+default_parser_list = ["xmlcore.sax.expatreader"]
# tell modulefinder that importing sax potentially imports expatreader
_false = 0
if _false:
- import xml.sax.expatreader
+ import xmlcore.sax.expatreader
import os, sys
if os.environ.has_key("PY_SAX_PARSER"):
diff --git a/Lib/xml/sax/_exceptions.py b/Lib/xmlcore/sax/_exceptions.py
index fdd614a..fdd614a 100644
--- a/Lib/xml/sax/_exceptions.py
+++ b/Lib/xmlcore/sax/_exceptions.py
diff --git a/Lib/xml/sax/expatreader.py b/Lib/xmlcore/sax/expatreader.py
index bb9c294..6fbd22e 100644
--- a/Lib/xml/sax/expatreader.py
+++ b/Lib/xmlcore/sax/expatreader.py
@@ -5,27 +5,27 @@ pyexpat.__version__ == '2.22'.
version = "0.20"
-from xml.sax._exceptions import *
-from xml.sax.handler import feature_validation, feature_namespaces
-from xml.sax.handler import feature_namespace_prefixes
-from xml.sax.handler import feature_external_ges, feature_external_pes
-from xml.sax.handler import feature_string_interning
-from xml.sax.handler import property_xml_string, property_interning_dict
-
-# xml.parsers.expat does not raise ImportError in Jython
+from xmlcore.sax._exceptions import *
+from xmlcore.sax.handler import feature_validation, feature_namespaces
+from xmlcore.sax.handler import feature_namespace_prefixes
+from xmlcore.sax.handler import feature_external_ges, feature_external_pes
+from xmlcore.sax.handler import feature_string_interning
+from xmlcore.sax.handler import property_xml_string, property_interning_dict
+
+# xmlcore.parsers.expat does not raise ImportError in Jython
import sys
if sys.platform[:4] == "java":
raise SAXReaderNotAvailable("expat not available in Java", None)
del sys
try:
- from xml.parsers import expat
+ from xmlcore.parsers import expat
except ImportError:
raise SAXReaderNotAvailable("expat not supported", None)
else:
if not hasattr(expat, "ParserCreate"):
raise SAXReaderNotAvailable("expat not supported", None)
-from xml.sax import xmlreader, saxutils, handler
+from xmlcore.sax import xmlreader, saxutils, handler
AttributesImpl = xmlreader.AttributesImpl
AttributesNSImpl = xmlreader.AttributesNSImpl
@@ -407,8 +407,8 @@ def create_parser(*args, **kwargs):
# ---
if __name__ == "__main__":
- import xml.sax
+ import xmlcore.sax
p = create_parser()
- p.setContentHandler(xml.sax.XMLGenerator())
- p.setErrorHandler(xml.sax.ErrorHandler())
+ p.setContentHandler(xmlcore.sax.XMLGenerator())
+ p.setErrorHandler(xmlcore.sax.ErrorHandler())
p.parse("../../../hamlet.xml")
diff --git a/Lib/xml/sax/handler.py b/Lib/xmlcore/sax/handler.py
index f9e91b6..f9e91b6 100644
--- a/Lib/xml/sax/handler.py
+++ b/Lib/xmlcore/sax/handler.py
diff --git a/Lib/xml/sax/saxutils.py b/Lib/xmlcore/sax/saxutils.py
index 582b008..582b008 100644
--- a/Lib/xml/sax/saxutils.py
+++ b/Lib/xmlcore/sax/saxutils.py
diff --git a/Lib/xml/sax/xmlreader.py b/Lib/xmlcore/sax/xmlreader.py
index 9a2361e..9a2361e 100644
--- a/Lib/xml/sax/xmlreader.py
+++ b/Lib/xmlcore/sax/xmlreader.py