Fred Drake | e85c350 | 2000-06-29 19:28:01 +0000 | [diff] [blame] | 1 | """W3C Document Object Model implementation for Python. |
| 2 | |
Fred Drake | 6bcf4c2 | 2000-12-11 22:29:23 +0000 | [diff] [blame] | 3 | The Python mapping of the Document Object Model is documented in the |
| 4 | Python Library Reference in the section on the xml.dom package. |
Fred Drake | e85c350 | 2000-06-29 19:28:01 +0000 | [diff] [blame] | 5 | |
| 6 | This package contains the following modules: |
| 7 | |
| 8 | minidom -- A simple implementation of the Level 1 DOM with namespace |
Fred Drake | 6bcf4c2 | 2000-12-11 22:29:23 +0000 | [diff] [blame] | 9 | support added (based on the Level 2 specification) and other |
| 10 | minor Level 2 functionality. |
| 11 | |
| 12 | pulldom -- DOM builder supporting on-demand tree-building for selected |
| 13 | subtrees of the document. |
Fred Drake | e85c350 | 2000-06-29 19:28:01 +0000 | [diff] [blame] | 14 | |
| 15 | """ |
Fred Drake | 6bcf4c2 | 2000-12-11 22:29:23 +0000 | [diff] [blame] | 16 | |
| 17 | |
| 18 | class Node: |
| 19 | """Class giving the NodeType constants.""" |
| 20 | |
| 21 | # DOM implementations may use this as a base class for their own |
| 22 | # Node implementations. If they don't, the constants defined here |
| 23 | # should still be used as the canonical definitions as they match |
| 24 | # the values given in the W3C recommendation. Client code can |
| 25 | # safely refer to these values in all tests of Node.nodeType |
| 26 | # values. |
| 27 | |
| 28 | ELEMENT_NODE = 1 |
| 29 | ATTRIBUTE_NODE = 2 |
| 30 | TEXT_NODE = 3 |
| 31 | CDATA_SECTION_NODE = 4 |
| 32 | ENTITY_REFERENCE_NODE = 5 |
| 33 | ENTITY_NODE = 6 |
| 34 | PROCESSING_INSTRUCTION_NODE = 7 |
| 35 | COMMENT_NODE = 8 |
| 36 | DOCUMENT_NODE = 9 |
| 37 | DOCUMENT_TYPE_NODE = 10 |
| 38 | DOCUMENT_FRAGMENT_NODE = 11 |
| 39 | NOTATION_NODE = 12 |
Martin v. Löwis | 64acf1d | 2000-12-13 14:21:07 +0000 | [diff] [blame^] | 40 | |
| 41 | #ExceptionCode |
| 42 | INDEX_SIZE_ERR = 1 |
| 43 | DOMSTRING_SIZE_ERR = 2 |
| 44 | HIERARCHY_REQUEST_ERR = 3 |
| 45 | WRONG_DOCUMENT_ERR = 4 |
| 46 | INVALID_CHARACTER_ERR = 5 |
| 47 | NO_DATA_ALLOWED_ERR = 6 |
| 48 | NO_MODIFICATION_ALLOWED_ERR = 7 |
| 49 | NOT_FOUND_ERR = 8 |
| 50 | NOT_SUPPORTED_ERR = 9 |
| 51 | INUSE_ATTRIBUTE_ERR = 10 |
| 52 | INVALID_STATE_ERR = 11 |
| 53 | SYNTAX_ERR = 12 |
| 54 | INVALID_MODIFICATION_ERR = 13 |
| 55 | NAMESPACE_ERR = 14 |
| 56 | INVALID_ACCESS_ERR = 15 |
| 57 | |
| 58 | class DOMException(Exception): |
| 59 | """Abstract base class for DOM exceptions. |
| 60 | Exceptions with specific codes are specializations of this class.""" |
| 61 | |
| 62 | pass |
| 63 | |
| 64 | class IndexSizeErr(DOMException): |
| 65 | code = INDEX_SIZE_ERR |
| 66 | |
| 67 | class DomstringSizeErr(DOMException): |
| 68 | code = DOMSTRING_SIZE_ERR |
| 69 | |
| 70 | class HierarchyRequestErr(DOMException): |
| 71 | code = HIERARCHY_REQUEST_ERR |
| 72 | |
| 73 | class WrongDocumentErr(DOMException): |
| 74 | code = WRONG_DOCUMENT_ERR |
| 75 | |
| 76 | class InvalidCharacterErr(DOMException): |
| 77 | code = INVALID_CHARACTER_ERR |
| 78 | |
| 79 | class NoDataAllowedErr(DOMException): |
| 80 | code = NO_DATA_ALLOWED_ERR |
| 81 | |
| 82 | class NoModificationAllowedErr(DOMException): |
| 83 | code = NO_MODIFICATION_ALLOWED_ERR |
| 84 | |
| 85 | class NotFoundErr(DOMException): |
| 86 | code = NOT_FOUND_ERR |
| 87 | |
| 88 | class NotSupportedErr(DOMException): |
| 89 | code = NOT_SUPPORTED_ERR |
| 90 | |
| 91 | class InuseAttributeErr(DOMException): |
| 92 | code = INUSE_ATTRIBUTE_ERR |
| 93 | |
| 94 | class InvalidStateErr(DOMException): |
| 95 | code = INVALID_STATE_ERR |
| 96 | |
| 97 | class SyntaxErr(DOMException): |
| 98 | code = SYNTAX_ERR |
| 99 | |
| 100 | class InvalidModificationErr(DOMException): |
| 101 | code = INVALID_MODIFICATION_ERR |
| 102 | |
| 103 | class NamespaceErr(DOMException): |
| 104 | code = NAMESPACE_ERR |
| 105 | |
| 106 | class InvalidAccessErr(DOMException): |
| 107 | code = INVALID_ACCESS_ERR |