| 
									
										
										
										
											2000-06-29 19:28:01 +00:00
										 |  |  | """W3C Document Object Model implementation for Python.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-11 22:29:23 +00:00
										 |  |  | The Python mapping of the Document Object Model is documented in the | 
					
						
							|  |  |  | Python Library Reference in the section on the xml.dom package. | 
					
						
							| 
									
										
										
										
											2000-06-29 19:28:01 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | This package contains the following modules: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | minidom -- A simple implementation of the Level 1 DOM with namespace | 
					
						
							| 
									
										
										
										
											2000-12-11 22:29:23 +00:00
										 |  |  |            support added (based on the Level 2 specification) and other | 
					
						
							|  |  |  |            minor Level 2 functionality. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | pulldom -- DOM builder supporting on-demand tree-building for selected | 
					
						
							|  |  |  |            subtrees of the document. | 
					
						
							| 
									
										
										
										
											2000-06-29 19:28:01 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | """
 | 
					
						
							| 
									
										
										
										
											2000-12-11 22:29:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Node: | 
					
						
							|  |  |  |     """Class giving the NodeType constants.""" | 
					
						
							| 
									
										
										
										
											2012-03-05 12:37:02 +01:00
										 |  |  |     __slots__ = () | 
					
						
							| 
									
										
										
										
											2000-12-11 22:29:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # DOM implementations may use this as a base class for their own | 
					
						
							|  |  |  |     # Node implementations.  If they don't, the constants defined here | 
					
						
							|  |  |  |     # should still be used as the canonical definitions as they match | 
					
						
							|  |  |  |     # the values given in the W3C recommendation.  Client code can | 
					
						
							|  |  |  |     # safely refer to these values in all tests of Node.nodeType | 
					
						
							|  |  |  |     # values. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ELEMENT_NODE                = 1 | 
					
						
							|  |  |  |     ATTRIBUTE_NODE              = 2 | 
					
						
							|  |  |  |     TEXT_NODE                   = 3 | 
					
						
							|  |  |  |     CDATA_SECTION_NODE          = 4 | 
					
						
							|  |  |  |     ENTITY_REFERENCE_NODE       = 5 | 
					
						
							|  |  |  |     ENTITY_NODE                 = 6 | 
					
						
							|  |  |  |     PROCESSING_INSTRUCTION_NODE = 7 | 
					
						
							|  |  |  |     COMMENT_NODE                = 8 | 
					
						
							|  |  |  |     DOCUMENT_NODE               = 9 | 
					
						
							|  |  |  |     DOCUMENT_TYPE_NODE          = 10 | 
					
						
							|  |  |  |     DOCUMENT_FRAGMENT_NODE      = 11 | 
					
						
							|  |  |  |     NOTATION_NODE               = 12 | 
					
						
							| 
									
										
										
										
											2000-12-13 14:21:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-13 16:35:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-13 14:21:07 +00:00
										 |  |  | #ExceptionCode | 
					
						
							|  |  |  | INDEX_SIZE_ERR                 = 1 | 
					
						
							|  |  |  | DOMSTRING_SIZE_ERR             = 2 | 
					
						
							|  |  |  | HIERARCHY_REQUEST_ERR          = 3 | 
					
						
							|  |  |  | WRONG_DOCUMENT_ERR             = 4 | 
					
						
							|  |  |  | INVALID_CHARACTER_ERR          = 5 | 
					
						
							|  |  |  | NO_DATA_ALLOWED_ERR            = 6 | 
					
						
							|  |  |  | NO_MODIFICATION_ALLOWED_ERR    = 7 | 
					
						
							|  |  |  | NOT_FOUND_ERR                  = 8 | 
					
						
							|  |  |  | NOT_SUPPORTED_ERR              = 9 | 
					
						
							|  |  |  | INUSE_ATTRIBUTE_ERR            = 10 | 
					
						
							|  |  |  | INVALID_STATE_ERR              = 11 | 
					
						
							|  |  |  | SYNTAX_ERR                     = 12 | 
					
						
							|  |  |  | INVALID_MODIFICATION_ERR       = 13 | 
					
						
							|  |  |  | NAMESPACE_ERR                  = 14 | 
					
						
							|  |  |  | INVALID_ACCESS_ERR             = 15 | 
					
						
							| 
									
										
										
										
											2002-08-09 14:57:55 +00:00
										 |  |  | VALIDATION_ERR                 = 16 | 
					
						
							| 
									
										
										
										
											2000-12-13 14:21:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-13 16:35:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-13 14:21:07 +00:00
										 |  |  | class DOMException(Exception): | 
					
						
							|  |  |  |     """Abstract base class for DOM exceptions.
 | 
					
						
							|  |  |  |     Exceptions with specific codes are specializations of this class."""
 | 
					
						
							| 
									
										
										
										
											2001-01-27 08:47:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-13 16:35:53 +00:00
										 |  |  |     def __init__(self, *args, **kw): | 
					
						
							|  |  |  |         if self.__class__ is DOMException: | 
					
						
							|  |  |  |             raise RuntimeError( | 
					
						
							| 
									
										
										
										
											2000-12-15 23:56:43 +00:00
										 |  |  |                 "DOMException should not be instantiated directly") | 
					
						
							| 
									
										
										
										
											2003-02-27 20:14:51 +00:00
										 |  |  |         Exception.__init__(self, *args, **kw) | 
					
						
							| 
									
										
										
										
											2000-12-13 16:35:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-02-19 14:57:02 +00:00
										 |  |  |     def _get_code(self): | 
					
						
							|  |  |  |         return self.code | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-13 14:21:07 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | class IndexSizeErr(DOMException): | 
					
						
							|  |  |  |     code = INDEX_SIZE_ERR | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DomstringSizeErr(DOMException): | 
					
						
							|  |  |  |     code = DOMSTRING_SIZE_ERR | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class HierarchyRequestErr(DOMException): | 
					
						
							|  |  |  |     code = HIERARCHY_REQUEST_ERR | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class WrongDocumentErr(DOMException): | 
					
						
							|  |  |  |     code = WRONG_DOCUMENT_ERR | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class InvalidCharacterErr(DOMException): | 
					
						
							|  |  |  |     code = INVALID_CHARACTER_ERR | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class NoDataAllowedErr(DOMException): | 
					
						
							|  |  |  |     code = NO_DATA_ALLOWED_ERR | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class NoModificationAllowedErr(DOMException): | 
					
						
							|  |  |  |     code = NO_MODIFICATION_ALLOWED_ERR | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class NotFoundErr(DOMException): | 
					
						
							|  |  |  |     code = NOT_FOUND_ERR | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class NotSupportedErr(DOMException): | 
					
						
							|  |  |  |     code = NOT_SUPPORTED_ERR | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class InuseAttributeErr(DOMException): | 
					
						
							|  |  |  |     code = INUSE_ATTRIBUTE_ERR | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class InvalidStateErr(DOMException): | 
					
						
							|  |  |  |     code = INVALID_STATE_ERR | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class SyntaxErr(DOMException): | 
					
						
							|  |  |  |     code = SYNTAX_ERR | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class InvalidModificationErr(DOMException): | 
					
						
							|  |  |  |     code = INVALID_MODIFICATION_ERR | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class NamespaceErr(DOMException): | 
					
						
							|  |  |  |     code = NAMESPACE_ERR | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class InvalidAccessErr(DOMException): | 
					
						
							|  |  |  |     code = INVALID_ACCESS_ERR | 
					
						
							| 
									
										
										
										
											2001-02-22 14:05:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-08-09 14:57:55 +00:00
										 |  |  | class ValidationErr(DOMException): | 
					
						
							|  |  |  |     code = VALIDATION_ERR | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-01-25 17:11:07 +00:00
										 |  |  | class UserDataHandler: | 
					
						
							|  |  |  |     """Class giving the operation constants for UserDataHandler.handle().""" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Based on DOM Level 3 (WD 9 April 2002) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     NODE_CLONED   = 1 | 
					
						
							|  |  |  |     NODE_IMPORTED = 2 | 
					
						
							|  |  |  |     NODE_DELETED  = 3 | 
					
						
							|  |  |  |     NODE_RENAMED  = 4 | 
					
						
							| 
									
										
										
										
											2001-11-30 15:37:33 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace" | 
					
						
							|  |  |  | XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/" | 
					
						
							|  |  |  | XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml" | 
					
						
							|  |  |  | EMPTY_NAMESPACE = None | 
					
						
							| 
									
										
										
										
											2002-08-09 14:57:55 +00:00
										 |  |  | EMPTY_PREFIX = None | 
					
						
							| 
									
										
										
										
											2001-11-30 15:37:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-17 20:24:18 +00:00
										 |  |  | from .domreg import getDOMImplementation, registerDOMImplementation |