Commit Graph

98 Commits

Author SHA1 Message Date
Martin v. Löwis 70d39a60a8 Re-indent. 2001-01-27 09:01:20 +00:00
Martin v. Löwis 711a5bdc44 Synchronize with PyXML 1.5. 2001-01-27 08:56:24 +00:00
Martin v. Löwis 0591725bc5 Synchronize with PyXML 1.10
Break cycle involving expat parser in close().
Add lex handler support to SAX2 pyexpat
2001-01-27 08:56:24 +00:00
Martin v. Löwis 52ce0d0837 Re-indent. 2001-01-27 08:47:37 +00:00
Martin v. Löwis d5fb58f1e3 Merge changes of PyXML 1.13:
Use nodeName, not tagName in attributes.
Provide get method for dictionary-like objects.
Use DOM exceptions instead of standard exceptions.
2001-01-27 08:38:34 +00:00
Martin v. Löwis e3fc722628 Synchronize with 1.10 of PyXML: Close parser when done. 2001-01-27 08:34:21 +00:00
Martin v. Löwis 04a1a542cb Patch #103052: Restore non-cyclic operation of pulldom.PullDOM 2001-01-26 18:53:42 +00:00
Fred Drake daa823ad9a Text.__init__(): Make sure the data parameter is a string (8-bit or
Unicode); raise TypeError if not.

This closes SF bug #126866.
2001-01-08 04:04:34 +00:00
Andrew M. Kuchling 291ed4fb3f Patch #102485 ] Check for legal children when adding children to a DOM node 2000-12-31 03:50:23 +00:00
Martin v. Löwis 011ea47577 Merge with 1.8 of pulldom.py:
Use types.UnicodeType if available, not type(u"").
2000-12-28 18:43:02 +00:00
Martin v. Löwis 156c337f66 Merge changes up to 1.10 from PyXML:
- implement hasAttribute and hasAttributeNS (1.7)
- Node.replaceChild():  Update the sibling nodes to point to newChild.  Set
  the .nextSibling attribute on oldChild instead of adding a .newChild
  attribute (1.9).
2000-12-28 18:40:56 +00:00
Andrew M. Kuchling 04a45e9bb1 Patch #102492, fixing bug #116677:
give minidom.py behaviour that complies with the DOM Level 1 REC,
    which says that when a node newChild is added to the tree, "if the
    newChild is already in the tree, it is first removed."

    pulldom.py is patched to use the public minidom interface instead
    of setting .parentNode itself.  Possibly this reduces pulldom's
    efficiency; someone else will have to pronounce on that.
2000-12-20 14:47:24 +00:00
Fred Drake 95b4ec5fbe Do not assume that types.UnicodeType exists; we might be running in an old
version of Python.  ;-(
2000-12-16 01:45:11 +00:00
Fred Drake 1402ab2cb9 Use the string module instead of string methods; this should still work
with Python 1.5.2 for now.
2000-12-16 01:43:40 +00:00
Fred Drake f16527c863 Typo caught by /F -- thanks! 2000-12-15 23:56:43 +00:00
Fred Drake 279aa6cabc DOMException.__init__(): Remember to pass self to Exception.__init__(). 2000-12-15 21:07:59 +00:00
Fred Drake f7cf40d331 Lots of small bug fixes and DOM API conformance improvements:
Make Node inherit from xml.dom.Node to pick up the NodeType values
defined by the W3C recommendation.

When raising AttributeError, be sure to provide the name of the attribute
that does not exist.

Node.normalize():  Make sure we do not allow an empty text node to survive
                   as the first child; update the sibling links properly.

_getElementsByTagNameNSHelper():  Make recursive calls using the right
                                  number of parameters.

Attr.__setattr__():  Be sure to update name and nodeName at the same time
                     since they are synonyms for this node type.

AttributeList:  Renamed to NamedNodeMap (AttributeList maintained as an
                alias).  Compute the length attribute dynamically to allow
                the underlying structures to mutate.

AttributeList.item():  Call .keys() on the dictionary rather than using
                       self.keys() for performance.

AttributeList.setNamedItem(), .setNamedItemNS():
        Added methods.

Text.splitText():
        Added method.

DocumentType:
        Added implementation class.

DOMImplementation:
        Added implementation class.

Document.appendChild():  Do not allow a second document element to be added.

Document.documentElement:  Find this dynamically, so that one can be
        removed and another added.

Document.unlink():  Clear the doctype attribute.

_get_StringIO():  Only use the StringIO module; cStringIO does not support
                  Unicode.
2000-12-14 18:16:11 +00:00
Fred Drake c16adce273 Adjust PullDOM to use a DOMImplementation instance to create new Document
objects; uses minidom if one is not provided to the constructor.

parse():  Pick up the default_bufsize default value dynamically so that
          the value in the module may be (meaningfully) changed at runtime.

This (partially) closes patch #102477.
2000-12-14 18:00:18 +00:00
Fred Drake ec126dab9c When raising KeyError, provide the key value that failed. 2000-12-13 20:48:29 +00:00
Fred Drake 5d1b5eaf55 Add code to DOMException to ensure it cannot be instantiated directly,
since the API documentation will state specifically that the specializations
must be used by the DOM implementations.
2000-12-13 16:35:53 +00:00
Martin v. Löwis 64acf1db22 Add standard DOM exception hierarchy. 2000-12-13 14:21:07 +00:00
Fred Drake 6bcf4c2a0b Update the docstring.
Add a Node class that defines the NodeType constants, based on discussion
in the XML-SIG.
2000-12-11 22:29:23 +00:00
Fred Drake 4ccf4a1e8a Reduce the visibility of imported modules for cleaner "from ... import *"
behavior.

Added support for the Attr.ownerElement attribute.

Everywhere:  Define constant object attributes in the classes rather than
on the instances during object construction.  This reduces the amount of
work needed for object construction and destruction; these need to be
lightweight operations on a DOM.

Node._get_firstChild(),
Node._get_lastChild():  Return None if there are no children (required for
        compliance with DOM level 1).

Node.insertBefore():  If refChild is None, append the new node instead of
        failing (required for compliance).  Also, update the sibling
        relationships.  Return the inserted node (required for compliance).

Node.appendChild():  Update the parent of the appended node.

Node.replaceChild():  Actually replace the old child!  Update the parent
        and sibling relationships of both the old and new children.  Return
        the replaced child (required for compliance).

Node.normalize():  Implemented the normalize() method.  Required for
        compliance, but missing from the release.  Useful for joining
        adjacent Text nodes into a single node for easier processing.

Node.cloneNode():  Actually make this work.  Don't let the new node share
        the instance __dict__ with the original.  Do proper recursion if
        doing a "deep" clone.  Move the attribute cloning out of the base
        class, since only Element is supposed to have attributes.

Node.unlink():  Simplify handling of child nodes for efficiency, and
        remove the attribute handling since only Element nodes support
        attributes.

Attr.cloneNode():  Extend this to clear the ownerElement attribute in
        the clone.

AttributeList.items(),
AttributeList.itemsNS():  Slight performance improvement (avoid lambda).

Element.cloneNode():  Extend Node.cloneNode() with support for the
        attributes.  Clone the Attr objects after creating the underlying
        clone.

Element.unlink():  Clean out the attributes here instead of in the base
        class, since this is the only class that will have them.

Element.toxml():  Adjust to create only one AttributeList instance; minor
        efficiency improvement.

_nssplit():  No need to re-import string.

Document.__init__():  No longer needed once constant attributes are
        initialized in the class itself.

Document.createElementNS(),
Document.createAttributeNS():  Use the defined constructors rather than
        directly access the classes.

_get_StringIO():  New function.  Create an output StringIO using the most
        efficient available flavor.

parse(),
parseString():  Import pulldom here instead of in the public namespace of
        the module.
2000-11-21 22:02:22 +00:00
Lars Gustäbel 4ced5e7675 Fix bug in prepare_input_source (patched by Paul P., sourceforge.net down
now, so can't find number).
2000-10-24 15:53:12 +00:00
Fred Drake 16f6329e61 Make reindent.py happy (lots of trailing whitespace removed). 2000-10-23 18:09:50 +00:00
Lars Gustäbel d2f5a9ac4b Fixed a bug that caused namespace names to be reported as lists rather
than tuples.
2000-10-19 07:36:29 +00:00
Lars Gustäbel 55b4efd034 Fixed minor problem with reset(). 2000-10-14 10:28:01 +00:00
Lars Gustäbel ec964d5b21 Moved appendChild calls back to DOMEventStream.
Added SAX2DOM class.
2000-10-13 20:53:27 +00:00
Paul Prescod 4221ff0ee1 Clear siblings, now that they are being set. 2000-10-13 20:11:42 +00:00
Lars Gustäbel bc1b5c81a5 Added parent attribute with getters and setters on XMLFilterBase. 2000-10-11 22:35:00 +00:00
Lars Gustäbel d178ba666b Added non-ns start and end element methods.
Moved appendChild calls from DOMEventStream to PullDOM (parser indep).
Removed duplicated sibling pointer setting (duplicated in appendChild).
2000-10-11 22:34:04 +00:00
Fred Drake 13a3069c2b Paul Prescod <paul@prescod.net>:
Correct the chaining between siblings.
2000-10-09 20:04:16 +00:00
Martin v. Löwis 04f4943d13 _exceptions: Format a missing system id as <unknown>.
expatreader: Use the error handler instead of raising exception directly.
2000-10-09 16:45:54 +00:00
Martin v. Löwis 830b37bd74 Don't use string methods to allow sharing this code with PyXML. 2000-10-07 19:03:20 +00:00
Martin v. Löwis a2fda0dfab Record bugs found when comparing the module with DOM Core Level 2. 2000-10-07 12:10:28 +00:00
Martin v. Löwis 2c8a89cc3f minidom: access attribute value before printing it
correct order of constructor args in createAttributeNS
pulldom: use symbolic names for uri and localnames
         correct usage of createAttribute and setAttributeNode signatures.
2000-10-06 22:36:03 +00:00
Martin v. Löwis 31b485ffb0 In an incremental parser, close the parser after feeding everything. 2000-10-06 21:12:12 +00:00
Martin v. Löwis 5fece7fc1b Don't use a file object as system id; try to propagate the file name to
the InputSource.
2000-10-06 21:11:20 +00:00
Martin v. Löwis 2aa93efda0 Don't report a final chunk for an external entity parser. 2000-10-06 21:10:34 +00:00
Martin v. Löwis ee1dc157d7 Move translation from expat.error to SAXParseException into feed, so that
callers of feed will get a SAXException.
In close, feed the last chunk first before calling endDocument, so that
the parser may report errors before the end of the document. Don't do
anything in a nested parser.
Don't call endDocument in parse; that will be called in close.
Use self._source for finding the SystemID; XML_GetBase will be cleared in
case of an error.
2000-10-06 21:08:59 +00:00
Martin v. Löwis 962c9e7f91 Add SAXReaderNotAvailable, and use it to distinguish between an
ImportError, and a missing driver.
2000-10-06 17:41:52 +00:00
Martin v. Löwis cf0a1cc417 Support non-namespace elements in *ElementNS of XMLGenerator. 2000-10-03 22:35:29 +00:00
Martin v. Löwis 3f0969f100 Use string functions instead of methods to allow sharing this module with PyXML 2000-09-29 19:00:40 +00:00
Martin v. Löwis 491ded78cc Remove dependency from saxutils when loading xmlreader 2000-09-29 18:59:50 +00:00
Fred Drake 0872e05851 Fix handling of file inputs on Windows; passing them to urllib.urlopen()
caused the drive letter to cause urlopen() to think it was an unrecognized
URL scheme.  This only passes system ids to urlopen() if the file does not
exist.  It works on Windows & Unix.

It should work everywhere else as well.
2000-09-26 17:23:09 +00:00
Fred Drake af57431701 Include the version-detecting code to allow PyXML to override the "standard"
xml package.  Require at least PyXML 0.6.1.
2000-09-25 17:30:17 +00:00
Thomas Wouters 84da8aa7e2 Fix inconsistent use of space/tabs. 2000-09-25 00:11:37 +00:00
Martin v. Löwis a13a9dcb9c Use SAX2 namespace support. 2000-09-24 21:54:14 +00:00
Martin v. Löwis 58af43fd76 [Patch 101634]
xml.sax: Fix parse and parseString not to rely on ExpatParser
         Greatly simplify import logic by using __import__
saxutils: Support Unicode strings and files as parameters to
          prepare_input_source
2000-09-24 21:31:06 +00:00
Martin v. Löwis 2066fa023c Find feature names in handler. 2000-09-24 21:17:39 +00:00