1 #ifndef __DOM_H__
2 #define __DOM_H__
3 /**
4 * Phoebe DOM Implementation.
5 *
6 * This is a C++ approximation of the W3C DOM model, which follows
7 * fairly closely the specifications in the various .idl files, copies of
8 * which are provided for reference. Most important is this one:
9 *
10 * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
11 *
12 * Authors:
13 * Bob Jamison
14 *
15 * Copyright (C) 2005 Bob Jamison
16 *
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License as published by the Free Software Foundation; either
20 * version 2.1 of the License, or (at your option) any later version.
21 *
22 * This library is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * Lesser General Public License for more details.
26 *
27 * You should have received a copy of the GNU Lesser General Public
28 * License along with this library; if not, write to the Free Software
29 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 */
32 #include <string>
33 #include <vector>
35 #define OWN_STRING
37 #ifdef OWN_STRING
38 #include "domstring.h"
39 #endif
41 #define XMLNSNAME "http://www.w3.org/2000/xmlns/"
43 namespace org
44 {
45 namespace w3c
46 {
47 namespace dom
48 {
52 #ifndef OWN_STRING
53 typedef unsigned short XMLCh;
54 typedef std::string DOMString;
55 #endif
57 /**
58 *
59 */
60 typedef unsigned long long DOMTimeStamp;
62 /**
63 *
64 */
65 typedef void DOMUserData;
67 /**
68 *
69 */
70 typedef void DOMObject;
73 class DOMException;
74 class DOMStringList;
75 class NameList;
76 class DOMImplementationList;
77 class DOMImplementationSource;
78 class DOMImplementation;
79 class Node;
80 class NodeList;
81 class NamedNodeMap;
82 class CharacterData;
83 class Attr;
84 class Element;
85 class Text;
86 class Comment;
87 class TypeInfo;
88 class UserDataHandler;
89 class DOMError;
90 class DOMErrorHandler;
91 class DOMLocator;
92 class DOMConfiguration;
93 class CDATASection;
94 class DocumentType;
95 class Notation;
96 class Entity;
97 class EntityReference;
98 class ProcessingInstruction;
99 class DocumentFragment;
100 class Document;
103 /**
104 * NOTE: We were originally intending to split ALL specifications into
105 * interface and implementation. After consideration, though, it behooves
106 * us to simplify things by implementing the base exception and
107 * container classes directly:
108 *
109 * DOMException
110 * DOMStringList
111 * NameList
112 * DOMImplementationList
113 * DOMImplementationSource
114 * DOMImplementation
115 * NodeList
116 * NamedNodeMap
117 */
120 /*#########################################################################
121 ## DOMException
122 #########################################################################*/
123 /**
124 * This is the only non-interface class
125 */
126 class DOMException
127 {
129 public:
131 DOMException(const DOMString &reasonMsg)
132 { msg = reasonMsg; }
134 DOMException(short theCode)
135 {
136 code = theCode;
137 }
139 virtual ~DOMException() throw()
140 {}
142 /**
143 *
144 */
145 unsigned short code;
147 /**
148 *
149 */
150 DOMString msg;
152 /**
153 * Get a string, translated from the code.
154 * Like std::exception. Not in spec.
155 */
156 const char *what()
157 { return (const char *)msg.c_str(); }
161 };
166 /**
167 * ExceptionCode
168 */
169 typedef enum
170 {
171 INDEX_SIZE_ERR = 1,
172 DOMSTRING_SIZE_ERR = 2,
173 HIERARCHY_REQUEST_ERR = 3,
174 WRONG_DOCUMENT_ERR = 4,
175 INVALID_CHARACTER_ERR = 5,
176 NO_DATA_ALLOWED_ERR = 6,
177 NO_MODIFICATION_ALLOWED_ERR = 7,
178 NOT_FOUND_ERR = 8,
179 NOT_SUPPORTED_ERR = 9,
180 INUSE_ATTRIBUTE_ERR = 10,
181 INVALID_STATE_ERR = 11,
182 SYNTAX_ERR = 12,
183 INVALID_MODIFICATION_ERR = 13,
184 NAMESPACE_ERR = 14,
185 INVALID_ACCESS_ERR = 15,
186 VALIDATION_ERR = 16,
187 TYPE_MISMATCH_ERR = 17
188 } ExceptionCode;
191 /*#########################################################################
192 ## DOMStringList
193 #########################################################################*/
195 class DOMStringList
196 {
197 public:
199 /**
200 *
201 */
202 virtual DOMString item(unsigned long index)
203 {
204 if (index>=strings.size())
205 return "";
206 return strings[index];
207 }
209 /**
210 *
211 */
212 virtual unsigned long getLength()
213 {
214 return (unsigned long) strings.size();
215 }
217 /**
218 *
219 */
220 virtual bool contains(const DOMString &str)
221 {
222 for (unsigned int i=0; i<strings.size() ; i++)
223 {
224 if (strings[i] == str)
225 return true;
226 }
227 return false;
228 }
231 //##################
232 //# Non-API methods
233 //##################
235 /**
236 *
237 */
238 DOMStringList() {}
241 /**
242 *
243 */
244 DOMStringList(const DOMStringList &other)
245 {
246 strings = other.strings;
247 }
249 /**
250 *
251 */
252 virtual ~DOMStringList() {}
255 protected:
257 /**
258 *
259 */
260 virtual void add(const DOMString &str)
261 {
262 strings.push_back(str);
263 }
265 std::vector<DOMString>strings;
267 };
271 /*#########################################################################
272 ## NameList
273 #########################################################################*/
274 class NamePair
275 {
276 public:
277 NamePair(const DOMString &theNamespaceURI, const DOMString &theName)
278 {
279 namespaceURI = theNamespaceURI;
280 name = theName;
281 }
282 NamePair(const NamePair &other)
283 {
284 namespaceURI = other.namespaceURI;
285 name = other.name;
286 }
287 virtual ~NamePair() {}
289 DOMString namespaceURI;
290 DOMString name;
291 };
295 class NameList
296 {
297 public:
299 /**
300 *
301 */
302 virtual DOMString getName(unsigned long index)
303 {
304 if (index>=namePairs.size())
305 return "";
306 return namePairs[index].name;
307 }
309 /**
310 *
311 */
312 virtual DOMString getNamespaceURI(unsigned long index)
313 {
314 if (index>=namePairs.size())
315 return "";
316 return namePairs[index].namespaceURI;
317 }
319 /**
320 *
321 */
322 virtual unsigned long getLength()
323 {
324 return (unsigned long)namePairs.size();
325 }
327 /**
328 *
329 */
330 virtual bool contains(const DOMString &name)
331 {
332 for (unsigned int i=0; i<namePairs.size() ; i++)
333 {
334 if (namePairs[i].name == name )
335 return true;
336 }
337 return false;
338 }
340 /**
341 *
342 */
343 virtual bool containsNS(const DOMString namespaceURI,const DOMString &name)
344 {
345 for (unsigned int i=0; i<namePairs.size() ; i++)
346 {
347 if (namePairs[i].namespaceURI == namespaceURI ||
348 namePairs[i].name == name )
349 return true;
350 }
351 return false;
352 }
355 //##################
356 //# Non-API methods
357 //##################
359 /**
360 *
361 */
362 NameList() {}
364 /**
365 *
366 */
367 NameList(const NameList &other)
368 {
369 namePairs = other.namePairs;
370 }
372 /**
373 *
374 */
375 virtual ~NameList() {}
376 protected:
378 std::vector<NamePair> namePairs;
380 };
382 /*#########################################################################
383 ## DOMImplementationList
384 #########################################################################*/
386 class DOMImplementationList
387 {
388 public:
390 /**
391 *
392 */
393 virtual DOMImplementation *getDOMImplementation(unsigned long index)
394 {
395 if (index >implementations.size())
396 return NULL;
397 return implementations[index];
398 }
400 /**
401 *
402 */
403 virtual unsigned long getLength()
404 {
405 return (unsigned long) implementations.size();
406 }
411 //##################
412 //# Non-API methods
413 //##################
415 /**
416 *
417 */
418 DOMImplementationList() {}
421 /**
422 *
423 */
424 DOMImplementationList(const DOMImplementationList &other)
425 {
426 implementations = other.implementations;
427 }
429 /**
430 *
431 */
432 virtual ~DOMImplementationList() {}
434 protected:
436 std::vector<DOMImplementation *>implementations;
438 };
441 /*#########################################################################
442 ## DOMImplementationSource
443 #########################################################################*/
445 class DOMImplementationSource
446 {
447 public:
449 /**
450 *
451 */
452 virtual DOMImplementation *getDOMImplementation(const DOMString &features) = 0;
454 /**
455 *
456 */
457 virtual DOMImplementationList getDOMImplementationList(const DOMString &features) = 0;
459 //##################
460 //# Non-API methods
461 //##################
463 /**
464 *
465 */
466 virtual ~DOMImplementationSource() {}
468 };
474 /*#########################################################################
475 ## DOMImplementation
476 #########################################################################*/
477 /**
478 *
479 */
480 class DOMImplementation
481 {
482 public:
483 /**
484 *
485 */
486 virtual bool hasFeature(const DOMString& feature, const DOMString& version) = 0;
489 /**
490 *
491 */
492 virtual DocumentType *createDocumentType(const DOMString& qualifiedName,
493 const DOMString& publicId,
494 const DOMString& systemId)
495 throw(DOMException) = 0;
497 /**
498 *
499 */
500 virtual Document *createDocument(const DOMString& namespaceURI,
501 const DOMString& qualifiedName,
502 DocumentType *doctype)
503 throw(DOMException) = 0;
504 /**
505 *
506 */
507 virtual DOMObject *getFeature(const DOMString& feature,
508 const DOMString& version) = 0;
511 //##################
512 //# Non-API methods
513 //##################
515 /**
516 *
517 */
518 virtual ~DOMImplementation() {}
520 };
525 /*#########################################################################
526 ## Node
527 #########################################################################*/
529 /**
530 *
531 */
532 class Node
533 {
534 public:
536 typedef enum
537 {
538 ELEMENT_NODE = 1,
539 ATTRIBUTE_NODE = 2,
540 TEXT_NODE = 3,
541 CDATA_SECTION_NODE = 4,
542 ENTITY_REFERENCE_NODE = 5,
543 ENTITY_NODE = 6,
544 PROCESSING_INSTRUCTION_NODE = 7,
545 COMMENT_NODE = 8,
546 DOCUMENT_NODE = 9,
547 DOCUMENT_TYPE_NODE = 10,
548 DOCUMENT_FRAGMENT_NODE = 11,
549 NOTATION_NODE = 12
550 } NodeType;
552 /**
553 *
554 */
555 virtual DOMString getNodeName() = 0;
557 /**
558 *
559 */
560 virtual DOMString getNodeValue() throw (DOMException) = 0;
562 /**
563 *
564 */
565 virtual void setNodeValue(const DOMString& val) throw (DOMException) = 0;
567 /**
568 *
569 */
570 virtual unsigned short getNodeType() = 0;
572 /**
573 *
574 */
575 virtual Node *getParentNode() = 0;
577 /**
578 *
579 */
580 virtual NodeList getChildNodes() = 0;
582 /**
583 *
584 */
585 virtual Node *getFirstChild() = 0;
587 /**
588 *
589 */
590 virtual Node *getLastChild() = 0;
592 /**
593 *
594 */
595 virtual Node *getPreviousSibling() = 0;
597 /**
598 *
599 */
600 virtual Node *getNextSibling() = 0;
602 /**
603 *
604 */
605 virtual NamedNodeMap &getAttributes() = 0;
608 /**
609 *
610 */
611 virtual Document *getOwnerDocument() = 0;
613 /**
614 *
615 */
616 virtual Node *insertBefore(const Node *newChild,
617 const Node *refChild)
618 throw(DOMException) = 0;
620 /**
621 *
622 */
623 virtual Node *replaceChild(const Node *newChild,
624 const Node *oldChild)
625 throw(DOMException) = 0;
627 /**
628 *
629 */
630 virtual Node *removeChild(const Node *oldChild)
631 throw(DOMException) = 0;
633 /**
634 *
635 */
636 virtual Node *appendChild(const Node *newChild)
637 throw(DOMException) = 0;
639 /**
640 *
641 */
642 virtual bool hasChildNodes() = 0;
644 /**
645 *
646 */
647 virtual Node *cloneNode(bool deep) = 0;
649 /**
650 *
651 */
652 virtual void normalize() = 0;
654 /**
655 *
656 */
657 virtual bool isSupported(const DOMString& feature,
658 const DOMString& version) = 0;
660 /**
661 *
662 */
663 virtual DOMString getNamespaceURI() = 0;
665 /**
666 *
667 */
668 virtual DOMString getPrefix() = 0;
670 /**
671 *
672 */
673 virtual void setPrefix(const DOMString& val) throw(DOMException) = 0;
675 /**
676 *
677 */
678 virtual DOMString getLocalName() = 0;
680 /**
681 *
682 */
683 virtual bool hasAttributes() = 0;
685 /**
686 *
687 */
688 virtual DOMString getBaseURI() = 0;
690 typedef enum
691 {
692 DOCUMENT_POSITION_DISCONNECTED = 0x01,
693 DOCUMENT_POSITION_PRECEDING = 0x02,
694 DOCUMENT_POSITION_FOLLOWING = 0x04,
695 DOCUMENT_POSITION_CONTAINS = 0x08,
696 DOCUMENT_POSITION_CONTAINED_BY = 0x10,
697 DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20
698 } DocumentPosition;
701 /**
702 *
703 */
704 virtual unsigned short compareDocumentPosition(const Node *other) = 0;
706 /**
707 *
708 */
709 virtual DOMString getTextContext() throw(DOMException) = 0;
712 /**
713 *
714 */
715 virtual void setTextContext(const DOMString &val) throw(DOMException) = 0;
718 /**
719 *
720 */
721 virtual DOMString lookupPrefix(const DOMString &namespaceURI) =0;
724 /**
725 *
726 */
727 virtual bool isDefaultNamespace(const DOMString &namespaceURI) =0;
730 /**
731 *
732 */
733 virtual DOMString lookupNamespaceURI(const DOMString &prefix) =0;
736 /**
737 *
738 */
739 virtual bool isEqualNode(const Node *node) =0;
743 /**
744 *
745 */
746 virtual DOMObject *getFeature(const DOMString &feature,
747 const DOMString &version) =0;
749 /**
750 *
751 */
752 virtual DOMUserData *setUserData(const DOMString &key,
753 const DOMUserData *data,
754 const UserDataHandler *handler) =0;
757 /**
758 *
759 */
760 virtual DOMUserData *getUserData(const DOMString &namespaceURI) =0;
762 //##################
763 //# Non-API methods
764 //##################
767 /**
768 *
769 */
770 virtual ~Node() {}
775 };
779 /*#########################################################################
780 ## NodeList
781 #########################################################################*/
783 /**
784 *
785 */
786 class NodeList
787 {
788 public:
789 /**
790 *
791 */
792 virtual Node *item(unsigned long index)
793 {
794 if (index>=nodes.size())
795 return NULL;
796 return nodes[index];
797 }
799 /**
800 *
801 */
802 virtual unsigned long getLength()
803 {
804 return (unsigned long) nodes.size();
805 }
807 //##################
808 //# Non-API methods
809 //##################
812 /**
813 *
814 */
815 NodeList() {}
817 /**
818 *
819 */
820 NodeList(const NodeList &other)
821 {
822 nodes = other.nodes;
823 }
825 /**
826 *
827 */
828 virtual ~NodeList() {}
830 protected:
832 friend class NodeImpl;
833 friend class ElementImpl;
835 /*
836 *
837 */
838 virtual void add(const Node *node)
839 {
840 nodes.push_back((Node *)node);
841 }
843 protected:
845 std::vector<Node *> nodes;
847 };
852 /*#########################################################################
853 ## NamedNodeMap
854 #########################################################################*/
856 class NamedNodeMapEntry
857 {
858 public:
859 NamedNodeMapEntry(const DOMString &theNamespaceURI,
860 const DOMString &theName,
861 const Node *theNode)
862 {
863 namespaceURI = theNamespaceURI;
864 name = theName;
865 node = (Node *)theNode;
866 }
867 NamedNodeMapEntry(const NamedNodeMapEntry &other)
868 {
869 namespaceURI = other.namespaceURI;
870 name = other.name;
871 node = other.node;
872 }
873 virtual ~NamedNodeMapEntry()
874 {
875 }
876 DOMString namespaceURI;
877 DOMString name;
878 Node *node;
879 };
881 /**
882 *
883 */
884 class NamedNodeMap
885 {
886 public:
888 /**
889 *
890 */
891 virtual Node *getNamedItem(const DOMString& name)
892 {
893 std::vector<NamedNodeMapEntry>::iterator iter;
894 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
895 {
896 if (iter->name == name)
897 {
898 Node *node = iter->node;
899 return node;
900 }
901 }
902 return NULL;
903 }
905 /**
906 *
907 */
908 virtual Node *setNamedItem(Node *arg) throw(DOMException)
909 {
910 if (!arg)
911 return NULL;
912 DOMString namespaceURI = arg->getNamespaceURI();
913 DOMString name = arg->getNodeName();
914 std::vector<NamedNodeMapEntry>::iterator iter;
915 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
916 {
917 if (iter->name == name)
918 {
919 Node *node = iter->node;
920 iter->node = arg;
921 return node;
922 }
923 }
924 NamedNodeMapEntry entry(namespaceURI, name, arg);
925 entries.push_back(entry);
926 return arg;
927 }
930 /**
931 *
932 */
933 virtual Node *removeNamedItem(const DOMString& name) throw(DOMException)
934 {
935 std::vector<NamedNodeMapEntry>::iterator iter;
936 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
937 {
938 if (iter->name == name)
939 {
940 Node *node = iter->node;
941 entries.erase(iter);
942 return node;
943 }
944 }
945 return NULL;
946 }
948 /**
949 *
950 */
951 virtual Node *item(unsigned long index)
952 {
953 if (index>=entries.size())
954 return NULL;
955 return entries[index].node;
956 }
958 /**
959 *
960 */
961 virtual unsigned long getLength()
962 {
963 return (unsigned long)entries.size();
964 }
966 /**
967 *
968 */
969 virtual Node *getNamedItemNS(const DOMString& namespaceURI,
970 const DOMString& localName)
971 {
972 std::vector<NamedNodeMapEntry>::iterator iter;
973 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
974 {
975 if (iter->namespaceURI == namespaceURI && iter->name == localName)
976 {
977 Node *node = iter->node;
978 return node;
979 }
980 }
981 return NULL;
982 }
984 /**
985 *
986 */
987 virtual Node *setNamedItemNS(Node *arg) throw(DOMException)
988 {
989 if (!arg)
990 return NULL;
991 DOMString namespaceURI = arg->getNamespaceURI();
992 DOMString name = arg->getNodeName();
993 std::vector<NamedNodeMapEntry>::iterator iter;
994 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
995 {
996 if (iter->namespaceURI == namespaceURI && iter->name == name)
997 {
998 Node *node = iter->node;
999 iter->node = arg;
1000 return node;
1001 }
1002 }
1003 NamedNodeMapEntry entry(namespaceURI, name, arg);
1004 entries.push_back(entry);
1005 return arg;
1006 }
1008 /**
1009 *
1010 */
1011 virtual Node *removeNamedItemNS(const DOMString& namespaceURI,
1012 const DOMString& localName)
1013 throw(DOMException)
1014 {
1015 std::vector<NamedNodeMapEntry>::iterator iter;
1016 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1017 {
1018 if (iter->namespaceURI == namespaceURI && iter->name == localName)
1019 {
1020 Node *node = iter->node;
1021 entries.erase(iter);
1022 return node;
1023 }
1024 }
1025 return NULL;
1026 }
1028 //##################
1029 //# Non-API methods
1030 //##################
1032 /**
1033 *
1034 */
1035 NamedNodeMap() {}
1038 /**
1039 *
1040 */
1041 NamedNodeMap(const NamedNodeMap &other)
1042 {
1043 entries = other.entries;
1044 }
1047 /**
1048 *
1049 */
1050 virtual ~NamedNodeMap() {}
1052 protected:
1054 std::vector<NamedNodeMapEntry> entries;
1056 };
1061 /*#########################################################################
1062 ## CharacterData
1063 #########################################################################*/
1065 /**
1066 *
1067 */
1068 class CharacterData : virtual public Node
1069 {
1070 public:
1072 /**
1073 *
1074 */
1075 virtual DOMString getData() throw(DOMException) = 0;
1077 /**
1078 *
1079 */
1080 virtual void setData(const DOMString& val) throw(DOMException) = 0;
1082 /**
1083 *
1084 */
1085 virtual unsigned long getLength() = 0;
1087 /**
1088 *
1089 */
1090 virtual DOMString substringData(unsigned long offset,
1091 unsigned long count)
1092 throw(DOMException) = 0;
1094 /**
1095 *
1096 */
1097 virtual void appendData(const DOMString& arg) throw(DOMException) = 0;
1099 /**
1100 *
1101 */
1102 virtual void insertData(unsigned long offset,
1103 const DOMString& arg)
1104 throw(DOMException) = 0;
1106 /**
1107 *
1108 */
1109 virtual void deleteData(unsigned long offset,
1110 unsigned long count)
1111 throw(DOMException) = 0;
1113 /**
1114 *
1115 */
1116 virtual void replaceData(unsigned long offset,
1117 unsigned long count,
1118 const DOMString& arg)
1119 throw(DOMException) = 0;
1122 //##################
1123 //# Non-API methods
1124 //##################
1127 /**
1128 *
1129 */
1130 virtual ~CharacterData() {}
1132 };
1138 /*#########################################################################
1139 ## Attr
1140 #########################################################################*/
1142 /**
1143 *
1144 */
1145 class Attr : virtual public Node
1146 {
1147 public:
1149 /**
1150 *
1151 */
1152 virtual DOMString getName() = 0;
1154 /**
1155 *
1156 */
1157 virtual bool getSpecified() = 0;
1159 /**
1160 *
1161 */
1162 virtual DOMString getValue() = 0;
1164 /**
1165 *
1166 */
1167 virtual void setValue(const DOMString& val) throw(DOMException) = 0;
1169 /**
1170 *
1171 */
1172 virtual Element *getOwnerElement() = 0;
1175 /**
1176 *
1177 */
1178 virtual TypeInfo *getSchemaTypeInfo() = 0;
1181 /**
1182 *
1183 */
1184 virtual bool getIsId() = 0;
1186 //##################
1187 //# Non-API methods
1188 //##################
1191 /**
1192 *
1193 */
1194 virtual ~Attr() {}
1196 };
1202 /*#########################################################################
1203 ## Element
1204 #########################################################################*/
1206 /**
1207 *
1208 */
1209 class Element : virtual public Node
1210 {
1211 public:
1214 /**
1215 *
1216 */
1217 virtual DOMString getTagName() = 0;
1219 /**
1220 *
1221 */
1222 virtual DOMString getAttribute(const DOMString& name) = 0;
1224 /**
1225 *
1226 */
1227 virtual void setAttribute(const DOMString& name,
1228 const DOMString& value)
1229 throw(DOMException) = 0;
1231 /**
1232 *
1233 */
1234 virtual void removeAttribute(const DOMString& name)
1235 throw(DOMException) = 0;
1237 /**
1238 *
1239 */
1240 virtual Attr *getAttributeNode(const DOMString& name) = 0;
1242 /**
1243 *
1244 */
1245 virtual Attr *setAttributeNode(Attr *newAttr)
1246 throw(DOMException) = 0;
1248 /**
1249 *
1250 */
1251 virtual Attr *removeAttributeNode(Attr *oldAttr)
1252 throw(DOMException) = 0;
1254 /**
1255 *
1256 */
1257 virtual NodeList getElementsByTagName(const DOMString& name) = 0;
1259 /**
1260 *
1261 */
1262 virtual DOMString getAttributeNS(const DOMString& namespaceURI,
1263 const DOMString& localName) = 0;
1265 /**
1266 *
1267 */
1268 virtual void setAttributeNS(const DOMString& namespaceURI,
1269 const DOMString& qualifiedName,
1270 const DOMString& value)
1271 throw(DOMException) = 0;
1273 /**
1274 *
1275 */
1276 virtual void removeAttributeNS(const DOMString& namespaceURI,
1277 const DOMString& localName)
1278 throw(DOMException) = 0;
1280 /**
1281 *
1282 */
1283 virtual Attr *getAttributeNodeNS(const DOMString& namespaceURI,
1284 const DOMString& localName) = 0;
1286 /**
1287 *
1288 */
1289 virtual Attr *setAttributeNodeNS(Attr *newAttr)
1290 throw(DOMException) = 0;
1292 /**
1293 *
1294 */
1295 virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI,
1296 const DOMString& localName) = 0;
1298 /**
1299 *
1300 */
1301 virtual bool hasAttribute(const DOMString& name) = 0;
1303 /**
1304 *
1305 */
1306 virtual bool hasAttributeNS(const DOMString& namespaceURI,
1307 const DOMString& localName) = 0;
1309 /**
1310 *
1311 */
1312 virtual TypeInfo *getSchemaTypeInto() = 0;
1315 /**
1316 *
1317 */
1318 virtual void setIdAttribute(const DOMString &name,
1319 bool isId) throw (DOMException) = 0;
1321 /**
1322 *
1323 */
1324 virtual void setIdAttributeNS(const DOMString &namespaceURI,
1325 const DOMString &localName,
1326 bool isId) throw (DOMException) = 0;
1328 /**
1329 *
1330 */
1331 virtual void setIdAttributeNode(const Attr *idAttr,
1332 bool isId) throw (DOMException) = 0;
1334 //##################
1335 //# Non-API methods
1336 //##################
1338 /**
1339 *
1340 */
1341 virtual ~Element() {}
1343 };
1349 /*#########################################################################
1350 ## Text
1351 #########################################################################*/
1353 /**
1354 *
1355 */
1356 class Text : virtual public CharacterData
1357 {
1358 public:
1360 /**
1361 *
1362 */
1363 virtual Text *splitText(unsigned long offset)
1364 throw(DOMException) = 0;
1366 /**
1367 *
1368 */
1369 virtual bool getIsElementContentWhitespace()= 0;
1371 /**
1372 *
1373 */
1374 virtual DOMString getWholeText() = 0;
1377 /**
1378 *
1379 */
1380 virtual Text *replaceWholeText(const DOMString &content)
1381 throw(DOMException) = 0;
1383 //##################
1384 //# Non-API methods
1385 //##################
1388 /**
1389 *
1390 */
1391 virtual ~Text() {}
1393 };
1397 /*#########################################################################
1398 ## Comment
1399 #########################################################################*/
1401 /**
1402 *
1403 */
1404 class Comment : virtual public CharacterData
1405 {
1406 public:
1408 //##################
1409 //# Non-API methods
1410 //##################
1413 /**
1414 *
1415 */
1416 virtual ~Comment() {}
1419 };
1423 /*#########################################################################
1424 ## TypeInfo
1425 #########################################################################*/
1427 /**
1428 *
1429 */
1430 class TypeInfo
1431 {
1432 public:
1434 /**
1435 *
1436 */
1437 virtual DOMString getTypeName() =0;
1439 /**
1440 *
1441 */
1442 virtual DOMString getTypeNamespace() =0;
1444 typedef enum
1445 {
1446 DERIVATION_RESTRICTION = 0x00000001,
1447 DERIVATION_EXTENSION = 0x00000002,
1448 DERIVATION_UNION = 0x00000004,
1449 DERIVATION_LIST = 0x00000008
1450 } DerivationMethod;
1453 /**
1454 *
1455 */
1456 virtual bool isDerivedFrom(const DOMString &typeNamespaceArg,
1457 const DOMString &typeNameArg,
1458 DerivationMethod derivationMethod) =0;
1460 //##################
1461 //# Non-API methods
1462 //##################
1465 /**
1466 *
1467 */
1468 virtual ~TypeInfo() {}
1470 };
1475 /*#########################################################################
1476 ## UserDataHandler
1477 #########################################################################*/
1479 /**
1480 *
1481 */
1482 class UserDataHandler
1483 {
1484 public:
1486 typedef enum
1487 {
1488 NODE_CLONED = 1,
1489 NODE_IMPORTED = 2,
1490 NODE_DELETED = 3,
1491 NODE_RENAMED = 4,
1492 NODE_ADOPTED = 5
1493 } OperationType;
1496 /**
1497 *
1498 */
1499 virtual void handle(unsigned short operation,
1500 const DOMString &key,
1501 const DOMUserData *data,
1502 const Node *src,
1503 const Node *dst) =0;
1505 //##################
1506 //# Non-API methods
1507 //##################
1510 /**
1511 *
1512 */
1513 virtual ~UserDataHandler() {}
1515 };
1518 /*#########################################################################
1519 ## DOMError
1520 #########################################################################*/
1522 /**
1523 *
1524 */
1525 class DOMError
1526 {
1527 public:
1529 typedef enum
1530 {
1531 SEVERITY_WARNING = 1,
1532 SEVERITY_ERROR = 2,
1533 SEVERITY_FATAL_ERROR = 3
1534 } ErrorSeverity;
1537 /**
1538 *
1539 */
1540 virtual unsigned short getSeverity() =0;
1542 /**
1543 *
1544 */
1545 virtual DOMString getMessage() =0;
1547 /**
1548 *
1549 */
1550 virtual DOMString getType() =0;
1552 /**
1553 *
1554 */
1555 virtual DOMObject *getRelatedException() =0;
1557 /**
1558 *
1559 */
1560 virtual DOMObject *getRelatedData() =0;
1562 /**
1563 *
1564 */
1565 virtual DOMLocator *getLocation() =0;
1568 //##################
1569 //# Non-API methods
1570 //##################
1573 /**
1574 *
1575 */
1576 virtual ~DOMError() {}
1578 };
1581 /*#########################################################################
1582 ## DOMErrorHandler
1583 #########################################################################*/
1585 /**
1586 *
1587 */
1588 class DOMErrorHandler
1589 {
1590 public:
1591 /**
1592 *
1593 */
1594 virtual bool handleError(const DOMError *error) =0;
1596 //##################
1597 //# Non-API methods
1598 //##################
1601 /**
1602 *
1603 */
1604 virtual ~DOMErrorHandler() {}
1606 };
1610 /*#########################################################################
1611 ## DOMLocator
1612 #########################################################################*/
1614 /**
1615 *
1616 */
1617 class DOMLocator
1618 {
1619 public:
1621 /**
1622 *
1623 */
1624 virtual long getLineNumber() =0;
1626 /**
1627 *
1628 */
1629 virtual long getColumnNumber() =0;
1631 /**
1632 *
1633 */
1634 virtual long getByteOffset() =0;
1636 /**
1637 *
1638 */
1639 virtual long getUtf16Offset() =0;
1642 /**
1643 *
1644 */
1645 virtual Node *getRelatedNode() =0;
1648 /**
1649 *
1650 */
1651 virtual DOMString getUri() =0;
1653 //##################
1654 //# Non-API methods
1655 //##################
1657 /**
1658 *
1659 */
1660 virtual ~DOMLocator() {}
1661 };
1664 /*#########################################################################
1665 ## DOMConfiguration
1666 #########################################################################*/
1668 /**
1669 *
1670 */
1671 class DOMConfiguration
1672 {
1673 public:
1675 /**
1676 *
1677 */
1678 virtual void setParameter(const DOMString &name,
1679 const DOMUserData *value) throw (DOMException) =0;
1681 /**
1682 *
1683 */
1684 virtual DOMUserData *getParameter(const DOMString &name)
1685 throw (DOMException) =0;
1687 /**
1688 *
1689 */
1690 virtual bool canSetParameter(const DOMString &name,
1691 const DOMUserData *data) =0;
1693 /**
1694 *
1695 */
1696 virtual DOMStringList *getParameterNames() =0;
1698 //##################
1699 //# Non-API methods
1700 //##################
1703 /**
1704 *
1705 */
1706 virtual ~DOMConfiguration() {}
1708 };
1715 /*#########################################################################
1716 ## CDATASection
1717 #########################################################################*/
1718 /**
1719 *
1720 */
1721 class CDATASection : virtual public Text
1722 {
1723 public:
1725 //##################
1726 //# Non-API methods
1727 //##################
1730 /**
1731 *
1732 */
1733 virtual ~CDATASection() {}
1735 };
1740 /*#########################################################################
1741 ## DocumentType
1742 #########################################################################*/
1744 /**
1745 *
1746 */
1747 class DocumentType : virtual public Node
1748 {
1749 public:
1751 /**
1752 *
1753 */
1754 virtual DOMString getName() = 0;
1756 /**
1757 *
1758 */
1759 virtual NamedNodeMap getEntities() = 0;
1761 /**
1762 *
1763 */
1764 virtual NamedNodeMap getNotations() = 0;
1766 /**
1767 *
1768 */
1769 virtual DOMString getPublicId() = 0;
1771 /**
1772 *
1773 */
1774 virtual DOMString getSystemId() = 0;
1776 /**
1777 *
1778 */
1779 virtual DOMString getInternalSubset() = 0;
1781 //##################
1782 //# Non-API methods
1783 //##################
1785 /**
1786 *
1787 */
1788 virtual ~DocumentType() {}
1790 };
1796 /*#########################################################################
1797 ## Notation
1798 #########################################################################*/
1800 /**
1801 *
1802 */
1803 class Notation : virtual public Node
1804 {
1805 public:
1807 /**
1808 *
1809 */
1810 virtual DOMString getPublicId() = 0;
1812 /**
1813 *
1814 */
1815 virtual DOMString getSystemId() = 0;
1817 //##################
1818 //# Non-API methods
1819 //##################
1822 /**
1823 *
1824 */
1825 virtual ~Notation() {}
1826 };
1833 /*#########################################################################
1834 ## Entity
1835 #########################################################################*/
1837 /**
1838 *
1839 */
1840 class Entity : virtual public Node
1841 {
1842 public:
1844 /**
1845 *
1846 */
1847 virtual DOMString getPublicId() = 0;
1849 /**
1850 *
1851 */
1852 virtual DOMString getSystemId() = 0;
1854 /**
1855 *
1856 */
1857 virtual DOMString getNotationName() = 0;
1859 /**
1860 *
1861 */
1862 virtual DOMString getInputEncoding() = 0;
1864 /**
1865 *
1866 */
1867 virtual DOMString getXmlEncoding() = 0;
1869 /**
1870 *
1871 */
1872 virtual DOMString getXmlVersion() = 0;
1874 //##################
1875 //# Non-API methods
1876 //##################
1879 /**
1880 *
1881 */
1882 virtual ~Entity() {}
1883 };
1889 /*#########################################################################
1890 ## EntityReference
1891 #########################################################################*/
1892 /**
1893 *
1894 */
1895 class EntityReference : virtual public Node
1896 {
1897 public:
1900 //##################
1901 //# Non-API methods
1902 //##################
1904 /**
1905 *
1906 */
1907 virtual ~EntityReference() {}
1908 };
1914 /*#########################################################################
1915 ## ProcessingInstruction
1916 #########################################################################*/
1918 /**
1919 *
1920 */
1921 class ProcessingInstruction : virtual public Node
1922 {
1923 public:
1925 /**
1926 *
1927 */
1928 virtual DOMString getTarget() = 0;
1930 /**
1931 *
1932 */
1933 virtual DOMString getData() = 0;
1935 /**
1936 *
1937 */
1938 virtual void setData(const DOMString& val) throw(DOMException) = 0;
1940 //##################
1941 //# Non-API methods
1942 //##################
1945 /**
1946 *
1947 */
1948 virtual ~ProcessingInstruction() {}
1950 };
1956 /*#########################################################################
1957 ## DocumentFragment
1958 #########################################################################*/
1959 /**
1960 *
1961 */
1962 class DocumentFragment : virtual public Node
1963 {
1964 public:
1966 //##################
1967 //# Non-API methods
1968 //##################
1971 /**
1972 *
1973 */
1974 virtual ~DocumentFragment() {}
1975 };
1982 /*#########################################################################
1983 ## Document
1984 #########################################################################*/
1986 /**
1987 *
1988 */
1989 class Document : virtual public Node
1990 {
1991 public:
1993 /**
1994 *
1995 */
1996 virtual DocumentType *getDoctype() = 0;
1998 /**
1999 *
2000 */
2001 virtual DOMImplementation *getImplementation() = 0;
2003 /**
2004 *
2005 */
2006 virtual Element *getDocumentElement() = 0;
2008 /**
2009 *
2010 */
2011 virtual Element *createElement(const DOMString& tagName)
2012 throw(DOMException) = 0;
2014 /**
2015 *
2016 */
2017 virtual DocumentFragment *createDocumentFragment() = 0;
2019 /**
2020 *
2021 */
2022 virtual Text *createTextNode(const DOMString& data) = 0;
2024 /**
2025 *
2026 */
2027 virtual Comment *createComment(const DOMString& data) = 0;
2029 /**
2030 *
2031 */
2032 virtual CDATASection *createCDATASection(const DOMString& data)
2033 throw(DOMException) = 0;
2035 /**
2036 *
2037 */
2038 virtual ProcessingInstruction *createProcessingInstruction(const DOMString& target,
2039 const DOMString& data)
2040 throw(DOMException) = 0;
2042 /**
2043 *
2044 */
2045 virtual Attr *createAttribute(const DOMString& name)
2046 throw(DOMException) = 0;
2048 /**
2049 *
2050 */
2051 virtual EntityReference *createEntityReference(const DOMString& name)
2052 throw(DOMException) = 0;
2054 /**
2055 *
2056 */
2057 virtual NodeList getElementsByTagName(const DOMString& tagname) = 0;
2060 /**
2061 *
2062 */
2063 virtual Node *importNode(const Node *importedNode,
2064 bool deep)
2065 throw(DOMException) = 0;
2067 /**
2068 *
2069 */
2070 virtual Element *createElementNS(const DOMString& namespaceURI,
2071 const DOMString& qualifiedName)
2072 throw(DOMException) = 0;
2074 /**
2075 *
2076 */
2077 virtual Attr *createAttributeNS(const DOMString& namespaceURI,
2078 const DOMString& qualifiedName)
2079 throw(DOMException) = 0;
2081 /**
2082 *
2083 */
2084 virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI,
2085 const DOMString& localName) = 0;
2087 /**
2088 *
2089 */
2090 virtual Element *getElementById(const DOMString& elementId) = 0;
2093 /**
2094 *
2095 */
2096 virtual DOMString getInputEncoding() = 0;
2099 /**
2100 *
2101 */
2102 virtual DOMString getXmlEncoding() = 0;
2104 /**
2105 *
2106 */
2107 virtual bool getXmlStandalone() = 0;
2109 /**
2110 *
2111 */
2112 virtual void setXmlStandalone(bool val) throw (DOMException) = 0;
2114 /**
2115 *
2116 */
2117 virtual DOMString getXmlVersion() = 0;
2119 /**
2120 *
2121 */
2122 virtual void setXmlVersion(const DOMString &version) throw (DOMException) = 0;
2124 /**
2125 *
2126 */
2127 virtual bool getStrictErrorChecking() = 0;
2129 /**
2130 *
2131 */
2132 virtual void setStrictErrorChecking(bool val) = 0;
2135 /**
2136 *
2137 */
2138 virtual DOMString getDocumentURI() = 0;
2140 /**
2141 *
2142 */
2143 virtual void setDocumentURI(const DOMString &uri) = 0;
2145 /**
2146 *
2147 */
2148 virtual Node *adoptNode(const Node *source) throw (DOMException) = 0;
2150 /**
2151 *
2152 */
2153 virtual DOMConfiguration *getDomConfig() = 0;
2155 /**
2156 *
2157 */
2158 virtual void normalizeDocument() = 0;
2160 /**
2161 *
2162 */
2163 virtual Node *renameNode(const Node *n,
2164 const DOMString &namespaceURI,
2165 const DOMString &qualifiedName)
2166 throw (DOMException) = 0;
2169 //##################
2170 //# Non-API methods
2171 //##################
2173 /**
2174 *
2175 */
2176 virtual ~Document() {}
2178 };
2190 } //namespace dom
2191 } //namespace w3c
2192 } //namespace org
2195 #endif // __DOM_H__
2198 /*#########################################################################
2199 ## E N D O F F I L E
2200 #########################################################################*/