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