| 1 | n/a | """W3C Document Object Model implementation for Python. |
|---|
| 2 | n/a | |
|---|
| 3 | n/a | The Python mapping of the Document Object Model is documented in the |
|---|
| 4 | n/a | Python Library Reference in the section on the xml.dom package. |
|---|
| 5 | n/a | |
|---|
| 6 | n/a | This package contains the following modules: |
|---|
| 7 | n/a | |
|---|
| 8 | n/a | minidom -- A simple implementation of the Level 1 DOM with namespace |
|---|
| 9 | n/a | support added (based on the Level 2 specification) and other |
|---|
| 10 | n/a | minor Level 2 functionality. |
|---|
| 11 | n/a | |
|---|
| 12 | n/a | pulldom -- DOM builder supporting on-demand tree-building for selected |
|---|
| 13 | n/a | subtrees of the document. |
|---|
| 14 | n/a | |
|---|
| 15 | n/a | """ |
|---|
| 16 | n/a | |
|---|
| 17 | n/a | |
|---|
| 18 | n/a | class Node: |
|---|
| 19 | n/a | """Class giving the NodeType constants.""" |
|---|
| 20 | n/a | __slots__ = () |
|---|
| 21 | n/a | |
|---|
| 22 | n/a | # DOM implementations may use this as a base class for their own |
|---|
| 23 | n/a | # Node implementations. If they don't, the constants defined here |
|---|
| 24 | n/a | # should still be used as the canonical definitions as they match |
|---|
| 25 | n/a | # the values given in the W3C recommendation. Client code can |
|---|
| 26 | n/a | # safely refer to these values in all tests of Node.nodeType |
|---|
| 27 | n/a | # values. |
|---|
| 28 | n/a | |
|---|
| 29 | n/a | ELEMENT_NODE = 1 |
|---|
| 30 | n/a | ATTRIBUTE_NODE = 2 |
|---|
| 31 | n/a | TEXT_NODE = 3 |
|---|
| 32 | n/a | CDATA_SECTION_NODE = 4 |
|---|
| 33 | n/a | ENTITY_REFERENCE_NODE = 5 |
|---|
| 34 | n/a | ENTITY_NODE = 6 |
|---|
| 35 | n/a | PROCESSING_INSTRUCTION_NODE = 7 |
|---|
| 36 | n/a | COMMENT_NODE = 8 |
|---|
| 37 | n/a | DOCUMENT_NODE = 9 |
|---|
| 38 | n/a | DOCUMENT_TYPE_NODE = 10 |
|---|
| 39 | n/a | DOCUMENT_FRAGMENT_NODE = 11 |
|---|
| 40 | n/a | NOTATION_NODE = 12 |
|---|
| 41 | n/a | |
|---|
| 42 | n/a | |
|---|
| 43 | n/a | #ExceptionCode |
|---|
| 44 | n/a | INDEX_SIZE_ERR = 1 |
|---|
| 45 | n/a | DOMSTRING_SIZE_ERR = 2 |
|---|
| 46 | n/a | HIERARCHY_REQUEST_ERR = 3 |
|---|
| 47 | n/a | WRONG_DOCUMENT_ERR = 4 |
|---|
| 48 | n/a | INVALID_CHARACTER_ERR = 5 |
|---|
| 49 | n/a | NO_DATA_ALLOWED_ERR = 6 |
|---|
| 50 | n/a | NO_MODIFICATION_ALLOWED_ERR = 7 |
|---|
| 51 | n/a | NOT_FOUND_ERR = 8 |
|---|
| 52 | n/a | NOT_SUPPORTED_ERR = 9 |
|---|
| 53 | n/a | INUSE_ATTRIBUTE_ERR = 10 |
|---|
| 54 | n/a | INVALID_STATE_ERR = 11 |
|---|
| 55 | n/a | SYNTAX_ERR = 12 |
|---|
| 56 | n/a | INVALID_MODIFICATION_ERR = 13 |
|---|
| 57 | n/a | NAMESPACE_ERR = 14 |
|---|
| 58 | n/a | INVALID_ACCESS_ERR = 15 |
|---|
| 59 | n/a | VALIDATION_ERR = 16 |
|---|
| 60 | n/a | |
|---|
| 61 | n/a | |
|---|
| 62 | n/a | class DOMException(Exception): |
|---|
| 63 | n/a | """Abstract base class for DOM exceptions. |
|---|
| 64 | n/a | Exceptions with specific codes are specializations of this class.""" |
|---|
| 65 | n/a | |
|---|
| 66 | n/a | def __init__(self, *args, **kw): |
|---|
| 67 | n/a | if self.__class__ is DOMException: |
|---|
| 68 | n/a | raise RuntimeError( |
|---|
| 69 | n/a | "DOMException should not be instantiated directly") |
|---|
| 70 | n/a | Exception.__init__(self, *args, **kw) |
|---|
| 71 | n/a | |
|---|
| 72 | n/a | def _get_code(self): |
|---|
| 73 | n/a | return self.code |
|---|
| 74 | n/a | |
|---|
| 75 | n/a | |
|---|
| 76 | n/a | class IndexSizeErr(DOMException): |
|---|
| 77 | n/a | code = INDEX_SIZE_ERR |
|---|
| 78 | n/a | |
|---|
| 79 | n/a | class DomstringSizeErr(DOMException): |
|---|
| 80 | n/a | code = DOMSTRING_SIZE_ERR |
|---|
| 81 | n/a | |
|---|
| 82 | n/a | class HierarchyRequestErr(DOMException): |
|---|
| 83 | n/a | code = HIERARCHY_REQUEST_ERR |
|---|
| 84 | n/a | |
|---|
| 85 | n/a | class WrongDocumentErr(DOMException): |
|---|
| 86 | n/a | code = WRONG_DOCUMENT_ERR |
|---|
| 87 | n/a | |
|---|
| 88 | n/a | class InvalidCharacterErr(DOMException): |
|---|
| 89 | n/a | code = INVALID_CHARACTER_ERR |
|---|
| 90 | n/a | |
|---|
| 91 | n/a | class NoDataAllowedErr(DOMException): |
|---|
| 92 | n/a | code = NO_DATA_ALLOWED_ERR |
|---|
| 93 | n/a | |
|---|
| 94 | n/a | class NoModificationAllowedErr(DOMException): |
|---|
| 95 | n/a | code = NO_MODIFICATION_ALLOWED_ERR |
|---|
| 96 | n/a | |
|---|
| 97 | n/a | class NotFoundErr(DOMException): |
|---|
| 98 | n/a | code = NOT_FOUND_ERR |
|---|
| 99 | n/a | |
|---|
| 100 | n/a | class NotSupportedErr(DOMException): |
|---|
| 101 | n/a | code = NOT_SUPPORTED_ERR |
|---|
| 102 | n/a | |
|---|
| 103 | n/a | class InuseAttributeErr(DOMException): |
|---|
| 104 | n/a | code = INUSE_ATTRIBUTE_ERR |
|---|
| 105 | n/a | |
|---|
| 106 | n/a | class InvalidStateErr(DOMException): |
|---|
| 107 | n/a | code = INVALID_STATE_ERR |
|---|
| 108 | n/a | |
|---|
| 109 | n/a | class SyntaxErr(DOMException): |
|---|
| 110 | n/a | code = SYNTAX_ERR |
|---|
| 111 | n/a | |
|---|
| 112 | n/a | class InvalidModificationErr(DOMException): |
|---|
| 113 | n/a | code = INVALID_MODIFICATION_ERR |
|---|
| 114 | n/a | |
|---|
| 115 | n/a | class NamespaceErr(DOMException): |
|---|
| 116 | n/a | code = NAMESPACE_ERR |
|---|
| 117 | n/a | |
|---|
| 118 | n/a | class InvalidAccessErr(DOMException): |
|---|
| 119 | n/a | code = INVALID_ACCESS_ERR |
|---|
| 120 | n/a | |
|---|
| 121 | n/a | class ValidationErr(DOMException): |
|---|
| 122 | n/a | code = VALIDATION_ERR |
|---|
| 123 | n/a | |
|---|
| 124 | n/a | class UserDataHandler: |
|---|
| 125 | n/a | """Class giving the operation constants for UserDataHandler.handle().""" |
|---|
| 126 | n/a | |
|---|
| 127 | n/a | # Based on DOM Level 3 (WD 9 April 2002) |
|---|
| 128 | n/a | |
|---|
| 129 | n/a | NODE_CLONED = 1 |
|---|
| 130 | n/a | NODE_IMPORTED = 2 |
|---|
| 131 | n/a | NODE_DELETED = 3 |
|---|
| 132 | n/a | NODE_RENAMED = 4 |
|---|
| 133 | n/a | |
|---|
| 134 | n/a | XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace" |
|---|
| 135 | n/a | XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/" |
|---|
| 136 | n/a | XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml" |
|---|
| 137 | n/a | EMPTY_NAMESPACE = None |
|---|
| 138 | n/a | EMPTY_PREFIX = None |
|---|
| 139 | n/a | |
|---|
| 140 | n/a | from .domreg import getDOMImplementation, registerDOMImplementation |
|---|