Commit Graph

225 Commits

Author SHA1 Message Date
Martin v. Löwis 456ab1d271 Swap public and system ID in start_doctype_decl. Fixes #780300. 2004-05-06 01:54:36 +00:00
Fred Drake 6fd0b0d5ba commit the portion of PyXML patch #919008 that is relevant to the
standard library:
str() of xml.sax.SAXParseException should not fail if the line and/or
column number returned by the locator are None
(tests added)
2004-03-20 08:15:30 +00:00
Walter Dörwald 70a6b49821 Replace backticks with repr() or "%r"
From SF patch #852334.
2004-02-12 17:35:32 +00:00
Neal Norwitz bc05fc5d2b Add missing self. before curNode. This may need to be committed
to PyXML, I'm not sure of the procedure.
2003-06-29 04:50:34 +00:00
Tim Peters 0eadaac7dc Whitespace normalization. 2003-04-24 16:02:54 +00:00
Raymond Hettinger ff41c48a77 SF patch #701494: more apply removals 2003-04-06 09:01:11 +00:00
Guido van Rossum 68468eba63 Get rid of many apply() calls. 2003-02-27 20:14:51 +00:00
Raymond Hettinger 0e449234bf SF patch 672098: Three __contains__ implementations
Contributed by Jp Calderone.
2003-01-30 00:56:33 +00:00
Martin v. Löwis afef4eefa8 Require PyXML 0.8.2. 2003-01-26 10:36:33 +00:00
Martin v. Löwis f8de21c51b Merge with PyXML 1.3:
Add support for the DOM Level 3 (draft) DOMImplementationSource interface
to the xml.dom and xml.dom.minidom modules.  Note API issue: the draft spec
says to return null when there is no suitable implementation, while the
Python getDOMImplementation() function raises ImportError (minor).
2003-01-26 09:04:35 +00:00
Martin v. Löwis 041411a1c7 Merge with PyXML 1.34: Correct typo. Fixes #674700. 2003-01-26 09:01:30 +00:00
Martin v. Löwis 995359cbe8 Merge with PyXML 1.82:
Correct various typos. Fixes #674700.
Set newly created attribute via setNamedItem.
2003-01-26 08:59:32 +00:00
Martin v. Löwis 7c3c4669b7 Import UserDataHandler from PyXML. 2003-01-25 17:11:07 +00:00
Martin v. Löwis b5698faa9d Import NodeFilter from DOM2 Traversal/Range. 2003-01-25 17:07:03 +00:00
Martin v. Löwis 3f1b5288e5 Merge with PyXML 1.28:
Wrap a lot of long lines.
Clean up a handler for expat.error.

If a lexical handler is set, make sure we call the startDTD() and
endDTD().  If the lexical handler is unset (by setting it to None),
remove the handlers from the underlying pyexpat parser object.
Closes SF bug #485584.

In namespaces mode, make sure we set up the qnames dictionary
correctly for the AttributesNSImpl instance passed to the
start-element-handler.
Closes SF bug #563399.

Support skippedEntity. Fixes #665486.
2003-01-25 16:51:50 +00:00
Martin v. Löwis 9ea67889dc Import from PyXML 1.10. 2003-01-25 15:29:56 +00:00
Martin v. Löwis 787354c3b9 Merge with PyXML 1.80:
Basic minidom changes to support the new higher-performance builder, as
described: http://mail.python.org/pipermail/xml-sig/2002-February/007217.html

Use True/False where appropriate.

isSupported():  Implemented from DOM Level 2.

Support a variety of things from the DOM Level 3 draft, integrate with
the xml.dom.xmlbuilder module for the new Document and
DOMImplementation methods.

Support the NODE_CLONED callback for the UserDataHandler set using
setUserData().

Add Entity and Notation nodes to minidom.
Add __getitem__() to ReadOnlySequentialNamedNodeMap to match NamedNodeMap.
TupleType was used without being defined; rename to _TupleType and define.

Add magic so that instances of the NamedNodeMap (and its read-only cousin)
take a bit less memory in the new-style world of Python 2.2/2.3.  Now, the
assignments to __slots__ actually work.  ;-)

Add support for the Text.wholeText attribute.
Document.createCDATASection():  Do not pass unsupported arg to CDATASection
constructor.

Implemented Text.replaceWholeText().

Updated minidom interfaces to work better with current 4Suite XPath and Xslt.
* Added childNodes to class Attr
* Added localName and prefix to all Nodes
* Added specified on class Attr
* Changed DOMImplementation.createDocument to all creating a document with no document element and
a
Null doctype
* Changed CharacterData__setattr__ to keep nodeValue and data in synch
* fixed typo of ownerDoc in createDocumentFragment
* Changed Comment to inherit from CharacterData
* Allowed mutation of name on PIs
* Added importNode and rewrote cloneNode so both use same code base
* Changed EmptyNodeList to be a list not a tuple

Use a table-driven DOMImplementation.hasFeature().
Shorten lines longer than 80 characters.

Rename CloneNode to _clone_node (better naming consistency within the
module).

When defining localName as a property, the defproperty() call is
needed for each class that defined _get_localName(), otherwise only
the first version is used for Python 2.2 and newer.

Node.insertBefore():  When the reference node is not found, raise the
    exception defined by the DOM specification.

Attr._set_value():  Added setter that does the right thing.

Childless.removeChild():  Raise the exception defined by the
    specification, even though it seem less than intuitive.

_clone_node():  Access nodeType constants so we actually find them.
    Add support for document fragments.

Node.removeChild(), .replaceChild():
    Fix exception raised when a reference node is not found.

CharacterData._set_data():  Update the nodeValue attribute as well as
    the data attribute.

Entity.attributes, .childNodes:  Added these attributes.

Document.removeChild():  Raise the right exception when the node being
    removed is not a child of this node.

Element.removeAttributeNode():  Raise the right exception when the
    node isn't present on this element.  Don't unlink the node unless
    it is present.

Added support for the following methods and accessors:
    Node._get_childNodes(), Attr._get_specified(), Attr._set_prefix(),
    NamedNodeMap.has_key(), .getNamedItem(), .getNamedItemNS(),
    .removeNamedItem(), .removeNamedItemNS(),
    ProcessingInstruction._get_data(), ._get_target(), ._set_data(),
    ._set_target(), CharacterData.__len__(),
    Document.getElementById().

Add many more of the _get_*() accessors.

Convert internal helpers to use a more consistent naming convention.

Remove unused definition of _nssplit(); there can be only one!

Move the Identified mixin up so it can be used by one more class.

Remove comment about NamedNodeMap.__getitem__(); the API won't be
changing now!  Way too late for that.

Preliminary support for getElementById() for DOMs built with
xml.dom.expatbuilder.
Not necessarily very efficient, but it works, and is still fast for Document
instances that do not have the ID information.

DOMImplementation.createDocument():  Don't forget to add the
    DocumentType node to the tree.  This appearantly was lost in the
    previous release.

DocumentType.writexml():  New function.

Implement the final determination on the behaviors of importNode() and
cloneNode() with regard to Document and DocumentType nodes.

When cloning and importing, call the UserDataHandler with the right
operation, not just blindly use NODE_CLONED.

parse(), parseString():  When called with parser=None, use
xml.dom.expatbuilder instead of xml.dom.pulldom, to get a performance
boost (the main point of expatbuilder).

Fix for calling parse / parseString with a given parser instance;
the else-paths were ignored when refactoring the function signatures;
pychecker found that error instantly, BTW (hint, hint)

Added pickle support for NamedNodeMap, ReadOnlySequentialNamedNodeMap,
and ElementInfo. Closes SF bug #609641.

In _clone_node for elements, fixed arguments for getAttributeNodeNS

At least make sure the DOM API won't allow you to modify the child
node list of an entity node (since entity ndoes are supposed to be
readonly).

Add support for the DOM Level 3 (draft) DOMImplementationSource interface
to the xml.dom and xml.dom.minidom modules.  Note API issue: the draft spec
says to return null when there is no suitable implementation, while the
Python getDOMImplementation() function raises ImportError (minor).

Implement the DOM Level 3 Attr.isId property.
Refactor the lookup of the ElementInfo objects.

Implement the schemaType attribute for Element and Attr nodes.
Defined by the (draft) DOM Level 3 specification.

getElementById():  Support caching of IDs found.  This implementation is
    sufficient for DOM Level 2 compliance, but additional changes will be
    needed to support the setIdAttribute() and setIdAttributeNS() methods
    in DOM Level 3.

Add support for Text.isWhitespaceInElementContent (draft Level 3).

NamedNodeMap.removeNamedItem(), .removeNamedItemNS():
    Pass the new tests:  Return the removed node, or raise NotFoundErr
    if there was no matching node.

When changing attributes via a NamedNodeMap, update the ID-cache
appropriately.

Added support for the DOM Level 3 (draft) Element.setIdAttribute*() methods.

setAttributeNode():  Be more careful about not calling
    removeAttributeNode() twice for a single node.

Do more to avoid creating new Attr nodes, so that attributes do not lose
their ID-ness when set using setIdAttribute*().

Work harder to avoid calls to Attr.__setattr__() and
CharacterData.__setattr__().

Attr.unlink():
    Implement everything directly instead of calling to the base
    class, which does several things that aren't needed for Attr
    nodes.

Change some remaining assignments that caused __setattr__() to be
called when it can be avoided.  expatbuilder can now perform DOM
construction without __setattr__() interferance in common cases.

Remove unused _make_parent_nodes logic.
2003-01-25 15:28:29 +00:00
Martin v. Löwis fc5fec7735 Import expatbuilder, minicompat from PyXML. 2003-01-25 15:11:07 +00:00
Fred Drake 6d8905012c Minor simplification. 2002-10-28 18:09:41 +00:00
Fred Drake 407fea5197 Really do replacement of & last to avoid bad interactions between &
replacement and replacements based on the entities parameter.
2002-10-28 17:46:59 +00:00
Fred Drake f55222d98f Avoid calling __dict_replace() if we don't need to -- the call is much
more expensive than just doing to work needed, and these things seem
to always turn into a bottleneck eventually.
2002-10-28 17:29:01 +00:00
Martin v. Löwis 74b51ac1e5 Patch #613256: Add nescape method to xml.sax.saxutils. 2002-10-26 14:50:45 +00:00
Fred Drake a350270302 New entries to track the DOM API growth. These match names exposed in
PyXML 0.8.
2002-08-09 14:57:55 +00:00
Fred Drake 8e8dc419d0 Remove bogus assignment to self.length in NamedNodeMap.__delitem__(). 2002-07-02 17:27:06 +00:00
Martin v. Löwis adfa7409f8 Bump required PyXML version to 0.6.5. 2002-06-30 15:08:22 +00:00
Martin v. Löwis 7d650ca83b Implement the encoding argument for toxml and toprettyxml.
Document toprettyxml.
2002-06-30 15:05:00 +00:00
Martin v. Löwis 2ebfd09e58 Merge from PyXML:
[1.3] Added documentation of the namespace URI for elements with no namespace.
[1.4] New property http://www.python.org/sax/properties/encoding.
[1.5] Support optional string interning in pyexpat.
2002-06-30 07:38:50 +00:00
Martin v. Löwis 0e2d881406 Add xml namespace initially (PyXML 1.19). 2002-06-30 07:32:56 +00:00
Martin v. Löwis d1b516c274 Fix spacing. 2002-06-30 07:27:30 +00:00
Martin v. Löwis 18476a3740 Merge changes from PyXML:
[1.15]
Added understanding of the feature_validation, feature_external_pes,
and feature_string_interning features.
Added support for the feature_external_ges feature.
Added support for the property_xml_string property.
[1.16]
Made it recognize the namespace prefixes feature.
[1.17]
removed erroneous first line
[1.19]
Support optional string interning in pyexpat.
[1.21]
Restore compatibility with versions of Python that did not support weak
references.  These do not get the cyclic reference fix, but they will
continue to work as they did before.
[1.22]
Activate entity processing unless standalone.
2002-06-30 07:21:24 +00:00
Neal Norwitz ab19962290 Use more string methods, remove import string 2002-05-31 20:46:39 +00:00
Fred Drake da204daeaa Not sure why the regression test missed this, but the PyXML tests caught it.
We should get attributes from the right object.
2002-04-04 19:12:31 +00:00
Fred Drake 012c81fc97 Avoid creating circular references between the ExpatParser and the
ContentHandler.  While GC will eventually clean up, it can take longer than
normal for applications that create a lot of strings (or other immutables)
rather without creating many containers.
This closes SF bug #535474.
2002-04-04 17:57:08 +00:00
Andrew M. Kuchling bdf1f19fee [Apply patch #500457 from the PyXML tracker]
Add iterator support to pulldom.DOMEventStream

New feature, so not a bugfix candidate (though it should be safe for inclusion)
2002-03-20 23:56:34 +00:00
Fred Drake 15b6893d95 Wrap a couple of long lines. 2002-03-15 14:37:23 +00:00
Martin v. Löwis 95700f7cde Patch #527427: minidom fails to use NodeList sometimes. 2002-03-15 13:51:59 +00:00
Fred Drake 2998a55f2d Attribute nodes did not always get their ownerDocument and ownerElement
properly set.  This fixes that.
2001-12-06 18:27:48 +00:00
Fred Drake e50959a58e Fix appendChild() and insertBefore() (and replaceChild() indirectly) when
the node being added is a fragment node.
This closes SF bug #487929.
2001-12-06 04:32:18 +00:00
Fred Drake 7fd173bfc4 Synchronize with pulldom from PyXML (revision 1.18). 2001-11-30 22:22:26 +00:00
Fred Drake 49a5d03ab4 Synchronize with minidom from PyXML (revision 1.35). 2001-11-30 22:21:58 +00:00
Fred Drake bd34b6bc3d Added the convenience constants that are present in PyXML to make these
more similar.
2001-11-30 15:37:33 +00:00
Tim Peters 6006629c3c Remove obsolete __dynamic__ distinction. 2001-10-15 22:53:29 +00:00
Fred Drake d157237d51 For Python 2.2, do not use __getattr__(), only use computed properties.
This is probably a little bit faster, but mostly is just cleaner code.
The old-style support is still used for Python versions < 2.2 so this
source file can be shared with PyXML.
2001-09-29 04:58:32 +00:00
Fred Drake 575712eaca Tighten up the new NodeList implementation.
Clean up a little; do not create an alias that is only used once, or store
attributes with constant values in an instance.
2001-09-28 20:25:45 +00:00
Fred Drake 3ac6a09eed For Python 2.2 and newer, actually support the full NodeList interface by
subclassing list to add the length and item() attributes.
2001-09-28 04:33:06 +00:00
Guido van Rossum 5b5e0b9bf9 Keep tabnanny happy. 2001-09-19 13:28:25 +00:00
Martin v. Löwis 5485404293 Patch to bug #461754: CDATA should not undergo entity subst. 2001-09-19 09:08:19 +00:00
Fred Drake dad91dd1e9 Make sure XMLGenerator uses quoteattr() instead of escape() to quote
attribute values.  Just using escape() can (and always has) led to broken
XML being generated.  This makes sure it always produces the right thing.

This actually closes SF bug #440351.
2001-08-07 19:14:46 +00:00
Martin v. Löwis 6cd441d129 Add dead imports of modules that are "magically" imported. 2001-07-31 08:54:55 +00:00
Fred Drake c974bf4dc2 Get the whitespace right! 2001-07-30 22:41:23 +00:00
Jeremy Hylton e3c37d660f Ugly fix used when pyexpat is not available.
If pyexpat is not available and more than one attempt is made to load
an expat-based xml parser, an empty xml.parser.expat module will be
created.  This empty module will confuse xml.sax.expatreader into
thinking that pyexpat is available.

The ugly fix is to verify that the expat module actually defines the
names that are imported from pyexpat.
2001-07-30 21:49:22 +00:00
Fred Drake acd32d3be5 Added function xml.sax.saxutils.quoteattr().
This closes SF bug #440351.  It should not be moved to Python 2.1.1.
2001-07-19 16:10:15 +00:00
Martin v. Löwis 984158d25b Patch #432117: Record namespaces in the DOM tree using the DOM xmlns prefix. 2001-07-18 15:30:25 +00:00
Fred Drake fbe7b4fc8c Make the implementations of getElementsByTagName() and
getElementsByTagNameNS() consistent in form as well as functionality
(cosmetic).
2001-07-04 06:25:53 +00:00
Martin v. Löwis fb73bb129b Synchronize with 1.13 of PyXML:
Allow application to set a new content handler and lex_prop handler during
parsing. Closes bug #433761.
Small hack to make expat be ignored in Jython.
2001-06-17 07:05:43 +00:00
Martin v. Löwis 2c07195574 Previous check-in was by mistake, undo it. 2001-06-07 05:52:17 +00:00
Martin v. Löwis 22adac50cb Patch #416220: Fix misplaced paren. 2001-06-07 05:49:05 +00:00
Martin v. Löwis ed525fb0df Fix getElementsByTagNameNS:
- actually return a result
  - Compare with tag.localName in getElementsByTagNameNSHelper
2001-06-03 14:06:42 +00:00
Fred Drake dc806704b5 Corrected default value of the DocumentType.internalSubset attribute based
on a clarification sent to the www-dom list.
2001-04-05 14:41:30 +00:00
Fred Drake 33d2b84b2c CharacterData methods: Update self.length on changes instead of extended
the __getattr__() handler.

Text.splitText():  Update the length and nodeValue attributes.
2001-04-04 15:15:18 +00:00
Fred Drake 87432f42f9 Add support for the CharacterData methods, CDATASection. 2001-04-04 14:09:46 +00:00
Martin v. Löwis cb67ea1d6e Initialize Attr.value with empty string in createAttribute*, as per DOM
spec. Closes bug #412036.
Also reindent toprettyxml.
2001-03-31 16:30:40 +00:00
Martin v. Löwis 764dad5b13 Arghh. Fix typo. 2001-03-27 21:38:15 +00:00
Martin v. Löwis c9494ac0ff Use Guido's trick for always extracting the version number from a
CVS Revision string correctly, even under -kv.
2001-03-27 08:42:12 +00:00
Fred Drake 6526bf863e When creating an attribute node using createAttribute() or
createAttributeNS(), use the parallel setAttributeNode() or
setAttributeNodeNS() to add the node to the document -- do not assume
that setAttributeNode() will operate properly for both.
2001-03-23 04:39:24 +00:00
Martin v. Löwis b374dd3a81 Synchronize with 1.6 of PyXML:
Retrieve relevant information at construction time, as it may be lost
when the exception is printed.
2001-03-22 15:34:02 +00:00
Fred Drake 904f2fcbd7 Import the exceptions that this module can raise. 2001-03-14 22:43:47 +00:00
Martin v. Löwis 126f2f62db Patch #407965: Improve Level 2 conformance of minidom
- addition of a DocumentFragment implementation and createDocumentFragment method
- proper setting of ownerDocument for all nodes
- setting of namespaceURI to None in Element as a class attribute
- addition of setAttributeNodeNS and removeAttributeNodeNS as aliases
  for setAttributeNode and removeAttributeNode
- support for inheriting from DOMImplementation to extend it with
  additional features (to override the Document class)
in pulldom:
- support for nodes (comment and PI) that occur before he document element;
  that became necessary as pulldom now delays creation of the document
  until it has the document element.
2001-03-13 10:50:13 +00:00
Martin v. Löwis 7edbd4ffb4 Patch #103885: Add dynamic registration and lookup of DOM implementations. 2001-02-22 14:05:50 +00:00
Andrew M. Kuchling bc8f72cccc Patch #103854: raises an exception if a non-Attr node is passed to
NamedNodeMap.setNamedItem().  Martin, should I sync the PyXML tree, too,
 or do you want to do it?  (I don't know if you're wrapping the 0.6.4
 release right now.)
2001-02-21 01:30:26 +00:00
Fred Drake b6a4425392 DOMException._get_code():
New method; this is the "alternate" access to the exception code.
    (Useful for Python DOM implementations that support the accessor
    method approach to retrieving attribute values.)
2001-02-19 14:57:02 +00:00
Eric S. Raymond 83ff749827 String method conversion. 2001-02-09 12:03:45 +00:00
Martin v. Löwis b417be2ad9 Do not allow empty qualifiedName in createDocument.
Rearrange pulldom to create documents with root element.
Provide clear methods so that the ContentHandler releases its hold on the
document.
2001-02-06 01:16:06 +00:00
Martin v. Löwis 46fa39ab1d Add toprettyxml method into minidom, closes patch #103471. 2001-02-06 00:14:08 +00:00
Guido van Rossum 9e1fe1ec67 A couple of changes to make this more conformant. MvL and Uche agree.
This will make it incompatible with the version found in Python 2.0.
Does this need to be done to PyXML too?

Changes that might break existing code are marked with (!) below.

- Formatting nit: no spaces inside parentheses: foo( a ) -> foo(a).

- Break long lines.

- (!) Fix getAttribute() and getAttributeNS() to return "" instead of
  raising KeyError when the attribute is not found.

- (!) Fix getAttributeNodeNS() to return None instead of raising
  KeyError.  (Curiously, getAttributeNode() already did this.)

- Added hasAttributes(), which returns true iff the node has any
  attributes.  )This is DOM level 3.)

- (!) In createDocument(), if the qualified name is not empty,
  actually create and insert the first element with that name (this
  will become doc.documentElement).  MvL believes that it should be an
  error to specify an empty qualified name; I'm not going there today,
  since it would require making a matching change to pulldom.  Maybe
  MvL will do this.

- In Document.writexml(), insert an xml declaration at the top.  (This
  doesn't include the encoding since there's no way to specify the
  encoding.  If that's preferred, all writexml() methods should be
  fixed to support an optional encoding argument that they pass to
  each other -- and they should use it to encode all text they write,
  too.  Later.)
2001-02-05 19:17:50 +00:00
Guido van Rossum 795ad56b31 Don't get fooled by an empty prefix with a valid namespaceURI -- in
this case, the code used to generate invalid tags and attribute names
with a leading colon, e.g. <:tag> or <tag :attr="foo">.
2001-02-05 18:50:15 +00:00
Fred Drake 2523977fb2 Added Node.isSameNode() support. 2001-02-02 19:40:19 +00:00
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