Commit Graph

363 Commits

Author SHA1 Message Date
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
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
Lars Gustäbel 3a361f4f8b Fixed another bug. 2000-09-24 20:55:01 +00:00
Lars Gustäbel bb757136b2 Improvements to doco strings.
Tiny bug fix to expatreader.py (endDocument was only called after errors).
2000-09-24 20:38:18 +00:00
Lars Gustäbel e292a24589 Added EntityResolver and DTDHandler (patch 101631) with test cases. 2000-09-24 20:19:45 +00:00
Lars Gustäbel 523b0a6ec8 Added back the InputSource class (patch 101630). 2000-09-24 18:54:49 +00:00
Lars Gustäbel 32bf12eb8a Updated to final Attributes interface (patch 101632). 2000-09-24 18:39:23 +00:00
Lars Gustäbel e84bf751bb Updated to new SAX method signatures (*NS, patch 101573). 2000-09-24 18:31:37 +00:00
Lars Gustäbel f43cf31f4a Updated to new *NS signatures (patch 101573). 2000-09-24 18:29:24 +00:00
Lars Gustäbel 358f4da29c Added back missing argument to ignorableWhitespace signature. 2000-09-24 11:06:27 +00:00
Lars Gustäbel fc643c339d Bug fix to namespace handling in XMLGenerator (now adds declarations).
Bug fixes to XMLFilterBase (wrong ignorableWhitespace signature and
did not inherit set*Handler methods from XMLReader.)
2000-09-24 10:53:31 +00:00
Fred Drake 1f54902e05 Conform to the Python style guide. 2000-09-24 05:21:58 +00:00
Fred Drake ddb486745b Conform more closely with the Python style guide. 2000-09-23 05:32:26 +00:00
Fred Drake 96ea196ea8 Use the public name for the Expat parser; "pyexpat" is deprecated. 2000-09-23 04:49:30 +00:00
Fred Drake 003b9250e3 Add a wrapper around the pyexpat module, making the "public" name of
the module "xml.parsers.expat".
2000-09-23 04:44:43 +00:00
Guido van Rossum 7fa7da861a More whitespace cleanup, to satisfy tabnanny.py. Don't trust -tt! 2000-09-22 09:30:29 +00:00
Fred Drake 7422b6b6a2 White space cleanup, including one item that was an error under -tt. 2000-09-22 05:07:56 +00:00
Fred Drake 07cbc4e5bd Paul Prescod <paul@prescod.net>:
Add support for parsing already-opened files.  Make sure the parse()
method closes exactly those files that it opens.

Modified by FLD for better conformance to the Python style guide.

This closes SourceForge patch #101512.
2000-09-21 17:43:48 +00:00
Fred Drake 44627016da SAXException.__getitem__(): Raise AttributeError instead of NameError. 2000-09-21 16:32:28 +00:00
Jeremy Hylton d34580cb87 fix bogus references to imp; makes test_minidom succeed 2000-09-21 14:46:56 +00:00
Lars Gustäbel b798c0109f Now uses make_parser to create its parser (patch 101573). 2000-09-21 08:38:46 +00:00
Lars Gustäbel ae43e5205d Added the make_parser function (patch 101571). 2000-09-21 08:34:04 +00:00
Lars Gustäbel c5cec51b95 Updated XMLGenerator to new DocumentHandler interface (patch 101572). 2000-09-21 08:25:28 +00:00
Lars Gustäbel b4d6bb0987 Updated to correct DocumentHandler signatures. (patch 101570) 2000-09-21 08:18:55 +00:00
Fred Drake a12adfe485 Reduce the number of imports needed.
Make the code conform better to the Python style guide.
2000-09-18 17:40:22 +00:00
Fred Drake 6f6d51d050 Remove two unnecessary imports.
Update the module docstring to reflect the actual list of modules in the
xml.sax package.

Make the code better conform to the Python style guide.
2000-09-18 16:31:08 +00:00
Fred Drake c40cdf7238 Once we're done with the sys module, remove it from the namespace so
this module is "import *" safe.
2000-09-18 16:22:30 +00:00
Paul Prescod 5c6bd31319 Fixed some typos. Removed one obsolete comment. 2000-09-15 18:38:47 +00:00
Paul Prescod ce88db0230 Fixed bug that disallowed processing instructions before and after
document element.
2000-09-15 17:09:19 +00:00
Fred Drake 5750017563 Remove the outer test for __name__; not necessary. 2000-08-04 03:14:55 +00:00
Fred Drake 327e1878ac Add magic to replace the xml package with _xmlplus at import time.
Update docstring to reflect change of name for the parsers subpackage.
2000-08-01 00:05:16 +00:00
Fred Drake ede77bfda4 Rename the "parser" package to "parsers" to be compatible with the PyXML
project.
2000-07-31 23:59:54 +00:00
Paul Prescod 623511b7df Added a few docstrings 2000-07-21 22:05:49 +00:00
Thomas Wouters 7e47402264 Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
comments, docstrings or error messages. I fixed two minor things in
test_winreg.py ("didn't" -> "Didn't" and "Didnt" -> "Didn't").

There is a minor style issue involved: Guido seems to have preferred English
grammar (behaviour, honour) in a couple places. This patch changes that to
American, which is the more prominent style in the source. I prefer English
myself, so if English is preferred, I'd be happy to supply a patch myself ;)
2000-07-16 12:04:32 +00:00
Jeremy Hylton 04f39aa859 fix inconsistent use of tabs and spaces 2000-07-07 21:02:00 +00:00
Skip Montanaro f9059ebede fixed indentation in several places 2000-07-06 03:01:40 +00:00
Skip Montanaro 26a7983f08 fix indentation in one docstring 2000-07-06 02:56:36 +00:00
Skip Montanaro a2dccfbc09 fix indentation in three docstrings 2000-07-06 02:55:41 +00:00
Paul Prescod 6c4753f925 Used original SAX handling form. 2000-07-04 03:39:33 +00:00
Fred Drake b19948b7fb Typo (mine): Garsholm --> Garshol
Noted by Rob Hooft <rob@hooft.net>.
2000-07-02 13:52:21 +00:00
Paul Prescod 1e68827c8f Misc fixes and improvements. 2000-07-01 19:21:47 +00:00
Paul Prescod bd8c2ae758 Removed unncessary dependency. 2000-07-01 19:19:32 +00:00
Paul Prescod b58e6b10b6 Tightened xml.sax.__init__.py 2000-07-01 13:44:04 +00:00
Paul Prescod 73678dac48 Reference cycle fixes 2000-07-01 04:58:47 +00:00
Fred Drake c6e72e0b45 Typo. 2000-06-29 20:02:38 +00:00
Fred Drake 55c3819e6a Paul Prescod <paul@prescod.net>:
W3C DOM implementation for Python.
2000-06-29 19:39:57 +00:00
Fred Drake 3f6a7b5efb Package docstring. 2000-06-29 19:36:27 +00:00
Fred Drake 45cd9de2bb Paul Prescod <paul@prescod.net>:
SAX interfaces for Python.
2000-06-29 19:34:54 +00:00
Fred Drake 0d800e1481 Package docstring and initialization. 2000-06-29 19:33:43 +00:00
Fred Drake e85c350600 Package docstring. 2000-06-29 19:28:01 +00:00