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) 2006 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 <vector>
34 //# include this before the #ifdefs below
35 #include "domconfig.h"
37 #ifdef DOM_STRING_OWN
38 #include "domstring.h"
39 #else
40 #ifdef DOM_STRING_GLIBMM
41 #include <glibmm.h>
42 #else
43 #include <string>
44 #endif
45 #endif
47 #define XMLNSNAME "http://www.w3.org/2000/xmlns/"
49 namespace org
50 {
51 namespace w3c
52 {
53 namespace dom
54 {
58 #ifdef DOM_STRING_OWN
59 #else
60 #ifdef DOM_STRING_GLIBMM
61 typedef Glib::ustring DOMString;
62 typedef gunichar XMLCh;
63 #else
64 typedef std::string DOMString;
65 typedef unsigned short XMLCh;
66 #endif
67 #endif
70 /**
71 *
72 */
73 typedef unsigned long long DOMTimeStamp;
75 /**
76 *
77 */
78 typedef void DOMUserData;
80 /**
81 *
82 */
83 typedef void DOMObject;
86 class DOMException;
87 class DOMStringList;
88 class NameList;
89 class DOMImplementationList;
90 class DOMImplementationSource;
91 class DOMImplementation;
92 class Node;
93 class NodeList;
94 class NamedNodeMap;
95 class CharacterData;
96 class Attr;
97 class Element;
98 class Text;
99 class Comment;
100 class TypeInfo;
101 class UserDataHandler;
102 class DOMError;
103 class DOMErrorHandler;
104 class DOMLocator;
105 class DOMConfiguration;
106 class CDATASection;
107 class DocumentType;
108 class Notation;
109 class Entity;
110 class EntityReference;
111 class ProcessingInstruction;
112 class DocumentFragment;
113 class Document;
116 /**
117 * NOTE: We were originally intending to split ALL specifications into
118 * interface and implementation. After consideration, though, it behooves
119 * us to simplify things by implementing the base exception and
120 * container classes directly:
121 *
122 * DOMException
123 * DOMStringList
124 * NameList
125 * DOMImplementationList
126 * DOMImplementationSource
127 * DOMImplementation
128 * NodeList
129 * NamedNodeMap
130 */
133 /*#########################################################################
134 ## DOMException
135 #########################################################################*/
136 /**
137 * This is the only non-interface class
138 */
139 class DOMException
140 {
142 public:
144 /**
145 * ExceptionCode
146 */
147 typedef enum
148 {
149 INDEX_SIZE_ERR = 1,
150 DOMSTRING_SIZE_ERR = 2,
151 HIERARCHY_REQUEST_ERR = 3,
152 WRONG_DOCUMENT_ERR = 4,
153 INVALID_CHARACTER_ERR = 5,
154 NO_DATA_ALLOWED_ERR = 6,
155 NO_MODIFICATION_ALLOWED_ERR = 7,
156 NOT_FOUND_ERR = 8,
157 NOT_SUPPORTED_ERR = 9,
158 INUSE_ATTRIBUTE_ERR = 10,
159 INVALID_STATE_ERR = 11,
160 SYNTAX_ERR = 12,
161 INVALID_MODIFICATION_ERR = 13,
162 NAMESPACE_ERR = 14,
163 INVALID_ACCESS_ERR = 15,
164 VALIDATION_ERR = 16,
165 TYPE_MISMATCH_ERR = 17
166 } ExceptionCode;
170 DOMException(const DOMString &reasonMsg)
171 { msg = reasonMsg; }
173 DOMException(short theCode)
174 {
175 code = theCode;
176 }
178 virtual ~DOMException() throw()
179 {}
181 /**
182 *
183 */
184 unsigned short code;
186 /**
187 *
188 */
189 DOMString msg;
191 /**
192 * Get a string, translated from the code.
193 * Like std::exception. Not in spec.
194 */
195 const char *what()
196 { return (const char *)msg.c_str(); }
200 };
207 /*#########################################################################
208 ## DOMStringList
209 #########################################################################*/
211 class DOMStringList
212 {
213 public:
215 /**
216 *
217 */
218 virtual DOMString item(unsigned long index)
219 {
220 if (index>=strings.size())
221 return "";
222 return strings[index];
223 }
225 /**
226 *
227 */
228 virtual unsigned long getLength()
229 {
230 return (unsigned long) strings.size();
231 }
233 /**
234 *
235 */
236 virtual bool contains(const DOMString &str)
237 {
238 for (unsigned int i=0; i<strings.size() ; i++)
239 {
240 if (strings[i] == str)
241 return true;
242 }
243 return false;
244 }
247 //##################
248 //# Non-API methods
249 //##################
251 /**
252 *
253 */
254 DOMStringList() {}
257 /**
258 *
259 */
260 DOMStringList(const DOMStringList &other)
261 {
262 strings = other.strings;
263 }
265 /**
266 *
267 */
268 DOMStringList &operator=(const DOMStringList &other)
269 {
270 strings = other.strings;
271 return *this;
272 }
274 /**
275 *
276 */
277 virtual ~DOMStringList() {}
280 protected:
282 /**
283 *
284 */
285 virtual void add(const DOMString &str)
286 {
287 strings.push_back(str);
288 }
290 std::vector<DOMString>strings;
292 };
296 /*#########################################################################
297 ## NameList
298 #########################################################################*/
299 class NamePair
300 {
301 public:
302 NamePair(const DOMString &theNamespaceURI, const DOMString &theName)
303 {
304 namespaceURI = theNamespaceURI;
305 name = theName;
306 }
307 NamePair(const NamePair &other)
308 {
309 namespaceURI = other.namespaceURI;
310 name = other.name;
311 }
312 NamePair &operator=(const NamePair &other)
313 {
314 namespaceURI = other.namespaceURI;
315 name = other.name;
316 return *this;
317 }
318 virtual ~NamePair() {}
320 DOMString namespaceURI;
321 DOMString name;
322 };
326 class NameList
327 {
328 public:
330 /**
331 *
332 */
333 virtual DOMString getName(unsigned long index)
334 {
335 if (index>=namePairs.size())
336 return "";
337 return namePairs[index].name;
338 }
340 /**
341 *
342 */
343 virtual DOMString getNamespaceURI(unsigned long index)
344 {
345 if (index>=namePairs.size())
346 return "";
347 return namePairs[index].namespaceURI;
348 }
350 /**
351 *
352 */
353 virtual unsigned long getLength()
354 {
355 return (unsigned long)namePairs.size();
356 }
358 /**
359 *
360 */
361 virtual bool contains(const DOMString &name)
362 {
363 for (unsigned int i=0; i<namePairs.size() ; i++)
364 {
365 if (namePairs[i].name == name )
366 return true;
367 }
368 return false;
369 }
371 /**
372 *
373 */
374 virtual bool containsNS(const DOMString namespaceURI,const DOMString &name)
375 {
376 for (unsigned int i=0; i<namePairs.size() ; i++)
377 {
378 if (namePairs[i].namespaceURI == namespaceURI ||
379 namePairs[i].name == name )
380 return true;
381 }
382 return false;
383 }
386 //##################
387 //# Non-API methods
388 //##################
390 /**
391 *
392 */
393 NameList() {}
395 /**
396 *
397 */
398 NameList(const NameList &other)
399 {
400 namePairs = other.namePairs;
401 }
403 /**
404 *
405 */
406 NameList &operator=(const NameList &other)
407 {
408 namePairs = other.namePairs;
409 return *this;
410 }
412 /**
413 *
414 */
415 virtual ~NameList() {}
416 protected:
418 std::vector<NamePair> namePairs;
420 };
422 /*#########################################################################
423 ## DOMImplementationList
424 #########################################################################*/
426 class DOMImplementationList
427 {
428 public:
430 /**
431 *
432 */
433 virtual DOMImplementation *getDOMImplementation(unsigned long index)
434 {
435 if (index >implementations.size())
436 return NULL;
437 return implementations[index];
438 }
440 /**
441 *
442 */
443 virtual unsigned long getLength()
444 {
445 return (unsigned long) implementations.size();
446 }
451 //##################
452 //# Non-API methods
453 //##################
455 /**
456 *
457 */
458 DOMImplementationList() {}
461 /**
462 *
463 */
464 DOMImplementationList(const DOMImplementationList &other)
465 {
466 implementations = other.implementations;
467 }
469 /**
470 *
471 */
472 DOMImplementationList &operator=(const DOMImplementationList &other)
473 {
474 implementations = other.implementations;
475 return *this;
476 }
478 /**
479 *
480 */
481 virtual ~DOMImplementationList() {}
483 protected:
485 std::vector<DOMImplementation *>implementations;
487 };
490 /*#########################################################################
491 ## DOMImplementationSource
492 #########################################################################*/
494 class DOMImplementationSource
495 {
496 public:
498 /**
499 *
500 */
501 virtual DOMImplementation *getDOMImplementation(const DOMString &features) = 0;
503 /**
504 *
505 */
506 virtual DOMImplementationList getDOMImplementationList(const DOMString &features) = 0;
508 //##################
509 //# Non-API methods
510 //##################
512 /**
513 *
514 */
515 virtual ~DOMImplementationSource() {}
517 };
523 /*#########################################################################
524 ## DOMImplementation
525 #########################################################################*/
526 /**
527 *
528 */
529 class DOMImplementation
530 {
531 public:
532 /**
533 *
534 */
535 virtual bool hasFeature(const DOMString& feature, const DOMString& version) = 0;
538 /**
539 *
540 */
541 virtual DocumentType *createDocumentType(const DOMString& qualifiedName,
542 const DOMString& publicId,
543 const DOMString& systemId)
544 throw(DOMException) = 0;
546 /**
547 *
548 */
549 virtual Document *createDocument(const DOMString& namespaceURI,
550 const DOMString& qualifiedName,
551 DocumentType *doctype)
552 throw(DOMException) = 0;
553 /**
554 *
555 */
556 virtual DOMObject *getFeature(const DOMString& feature,
557 const DOMString& version) = 0;
560 //##################
561 //# Non-API methods
562 //##################
564 /**
565 *
566 */
567 virtual ~DOMImplementation() {}
569 };
574 /*#########################################################################
575 ## Node
576 #########################################################################*/
578 /**
579 *
580 */
581 class Node
582 {
583 public:
585 typedef enum
586 {
587 ELEMENT_NODE = 1,
588 ATTRIBUTE_NODE = 2,
589 TEXT_NODE = 3,
590 CDATA_SECTION_NODE = 4,
591 ENTITY_REFERENCE_NODE = 5,
592 ENTITY_NODE = 6,
593 PROCESSING_INSTRUCTION_NODE = 7,
594 COMMENT_NODE = 8,
595 DOCUMENT_NODE = 9,
596 DOCUMENT_TYPE_NODE = 10,
597 DOCUMENT_FRAGMENT_NODE = 11,
598 NOTATION_NODE = 12
599 } NodeType;
601 /**
602 *
603 */
604 virtual DOMString getNodeName() = 0;
606 /**
607 *
608 */
609 virtual DOMString getNodeValue() throw (DOMException) = 0;
611 /**
612 *
613 */
614 virtual void setNodeValue(const DOMString& val) throw (DOMException) = 0;
616 /**
617 *
618 */
619 virtual unsigned short getNodeType() = 0;
621 /**
622 *
623 */
624 virtual Node *getParentNode() = 0;
626 /**
627 *
628 */
629 virtual NodeList getChildNodes() = 0;
631 /**
632 *
633 */
634 virtual Node *getFirstChild() = 0;
636 /**
637 *
638 */
639 virtual Node *getLastChild() = 0;
641 /**
642 *
643 */
644 virtual Node *getPreviousSibling() = 0;
646 /**
647 *
648 */
649 virtual Node *getNextSibling() = 0;
651 /**
652 *
653 */
654 virtual NamedNodeMap &getAttributes() = 0;
657 /**
658 *
659 */
660 virtual Document *getOwnerDocument() = 0;
662 /**
663 *
664 */
665 virtual Node *insertBefore(const Node *newChild,
666 const Node *refChild)
667 throw(DOMException) = 0;
669 /**
670 *
671 */
672 virtual Node *replaceChild(const Node *newChild,
673 const Node *oldChild)
674 throw(DOMException) = 0;
676 /**
677 *
678 */
679 virtual Node *removeChild(const Node *oldChild)
680 throw(DOMException) = 0;
682 /**
683 *
684 */
685 virtual Node *appendChild(const Node *newChild)
686 throw(DOMException) = 0;
688 /**
689 *
690 */
691 virtual bool hasChildNodes() = 0;
693 /**
694 *
695 */
696 virtual Node *cloneNode(bool deep) = 0;
698 /**
699 *
700 */
701 virtual void normalize() = 0;
703 /**
704 *
705 */
706 virtual bool isSupported(const DOMString& feature,
707 const DOMString& version) = 0;
709 /**
710 *
711 */
712 virtual DOMString getNamespaceURI() = 0;
714 /**
715 *
716 */
717 virtual DOMString getPrefix() = 0;
719 /**
720 *
721 */
722 virtual void setPrefix(const DOMString& val) throw(DOMException) = 0;
724 /**
725 *
726 */
727 virtual DOMString getLocalName() = 0;
729 /**
730 *
731 */
732 virtual bool hasAttributes() = 0;
734 /**
735 *
736 */
737 virtual DOMString getBaseURI() = 0;
739 typedef enum
740 {
741 DOCUMENT_POSITION_DISCONNECTED = 0x01,
742 DOCUMENT_POSITION_PRECEDING = 0x02,
743 DOCUMENT_POSITION_FOLLOWING = 0x04,
744 DOCUMENT_POSITION_CONTAINS = 0x08,
745 DOCUMENT_POSITION_CONTAINED_BY = 0x10,
746 DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20
747 } DocumentPosition;
750 /**
751 *
752 */
753 virtual unsigned short compareDocumentPosition(const Node *other) = 0;
755 /**
756 *
757 */
758 virtual DOMString getTextContext() throw(DOMException) = 0;
761 /**
762 *
763 */
764 virtual void setTextContext(const DOMString &val) throw(DOMException) = 0;
767 /**
768 *
769 */
770 virtual DOMString lookupPrefix(const DOMString &namespaceURI) =0;
773 /**
774 *
775 */
776 virtual bool isDefaultNamespace(const DOMString &namespaceURI) =0;
779 /**
780 *
781 */
782 virtual DOMString lookupNamespaceURI(const DOMString &prefix) =0;
785 /**
786 *
787 */
788 virtual bool isEqualNode(const Node *node) =0;
792 /**
793 *
794 */
795 virtual DOMObject *getFeature(const DOMString &feature,
796 const DOMString &version) =0;
798 /**
799 *
800 */
801 virtual DOMUserData *setUserData(const DOMString &key,
802 const DOMUserData *data,
803 const UserDataHandler *handler) =0;
806 /**
807 *
808 */
809 virtual DOMUserData *getUserData(const DOMString &namespaceURI) =0;
811 //##################
812 //# Non-API methods
813 //##################
816 /**
817 *
818 */
819 virtual ~Node() {}
824 };
828 /*#########################################################################
829 ## NodeList
830 #########################################################################*/
832 /**
833 *
834 */
835 class NodeList
836 {
837 public:
838 /**
839 *
840 */
841 virtual Node *item(unsigned long index)
842 {
843 if (index>=nodes.size())
844 return NULL;
845 return nodes[index];
846 }
848 /**
849 *
850 */
851 virtual unsigned long getLength()
852 {
853 return (unsigned long) nodes.size();
854 }
856 //##################
857 //# Non-API methods
858 //##################
861 /**
862 *
863 */
864 NodeList() {}
866 /**
867 *
868 */
869 NodeList(const NodeList &other)
870 {
871 nodes = other.nodes;
872 }
874 /**
875 *
876 */
877 NodeList &operator=(const NodeList &other)
878 {
879 nodes = other.nodes;
880 return *this;
881 }
883 /**
884 *
885 */
886 virtual ~NodeList() {}
888 /**
889 *
890 */
891 virtual void clear()
892 {
893 nodes.clear();
894 }
896 protected:
898 friend class NodeImpl;
899 friend class ElementImpl;
901 /*
902 *
903 */
904 virtual void add(const Node *node)
905 {
906 nodes.push_back((Node *)node);
907 }
909 protected:
911 std::vector<Node *> nodes;
913 };
918 /*#########################################################################
919 ## NamedNodeMap
920 #########################################################################*/
922 class NamedNodeMapEntry
923 {
924 public:
925 NamedNodeMapEntry(const DOMString &theNamespaceURI,
926 const DOMString &theName,
927 const Node *theNode)
928 {
929 namespaceURI = theNamespaceURI;
930 name = theName;
931 node = (Node *)theNode;
932 }
933 NamedNodeMapEntry(const NamedNodeMapEntry &other)
934 {
935 assign(other);
936 }
937 NamedNodeMapEntry &operator=(const NamedNodeMapEntry &other)
938 {
939 assign(other);
940 return *this;
941 }
942 virtual ~NamedNodeMapEntry()
943 {
944 }
945 void assign(const NamedNodeMapEntry &other)
946 {
947 namespaceURI = other.namespaceURI;
948 name = other.name;
949 node = other.node;
950 }
951 DOMString namespaceURI;
952 DOMString name;
953 Node *node;
954 };
956 /**
957 *
958 */
959 class NamedNodeMap
960 {
961 public:
963 /**
964 *
965 */
966 virtual Node *getNamedItem(const DOMString& name)
967 {
968 std::vector<NamedNodeMapEntry>::iterator iter;
969 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
970 {
971 if (iter->name == name)
972 {
973 Node *node = iter->node;
974 return node;
975 }
976 }
977 return NULL;
978 }
980 /**
981 *
982 */
983 virtual Node *setNamedItem(Node *arg) throw(DOMException)
984 {
985 if (!arg)
986 return NULL;
987 DOMString namespaceURI = arg->getNamespaceURI();
988 DOMString name = arg->getNodeName();
989 std::vector<NamedNodeMapEntry>::iterator iter;
990 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
991 {
992 if (iter->name == name)
993 {
994 Node *node = iter->node;
995 iter->node = arg;
996 return node;
997 }
998 }
999 NamedNodeMapEntry entry(namespaceURI, name, arg);
1000 entries.push_back(entry);
1001 return arg;
1002 }
1005 /**
1006 *
1007 */
1008 virtual Node *removeNamedItem(const DOMString& name) throw(DOMException)
1009 {
1010 std::vector<NamedNodeMapEntry>::iterator iter;
1011 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1012 {
1013 if (iter->name == name)
1014 {
1015 Node *node = iter->node;
1016 entries.erase(iter);
1017 return node;
1018 }
1019 }
1020 return NULL;
1021 }
1023 /**
1024 *
1025 */
1026 virtual Node *item(unsigned long index)
1027 {
1028 if (index>=entries.size())
1029 return NULL;
1030 return entries[index].node;
1031 }
1033 /**
1034 *
1035 */
1036 virtual unsigned long getLength()
1037 {
1038 return (unsigned long)entries.size();
1039 }
1041 /**
1042 *
1043 */
1044 virtual Node *getNamedItemNS(const DOMString& namespaceURI,
1045 const DOMString& localName)
1046 {
1047 std::vector<NamedNodeMapEntry>::iterator iter;
1048 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1049 {
1050 if (iter->namespaceURI == namespaceURI && iter->name == localName)
1051 {
1052 Node *node = iter->node;
1053 return node;
1054 }
1055 }
1056 return NULL;
1057 }
1059 /**
1060 *
1061 */
1062 virtual Node *setNamedItemNS(Node *arg) throw(DOMException)
1063 {
1064 if (!arg)
1065 return NULL;
1066 DOMString namespaceURI = arg->getNamespaceURI();
1067 DOMString name = arg->getNodeName();
1068 std::vector<NamedNodeMapEntry>::iterator iter;
1069 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1070 {
1071 if (iter->namespaceURI == namespaceURI && iter->name == name)
1072 {
1073 Node *node = iter->node;
1074 iter->node = arg;
1075 return node;
1076 }
1077 }
1078 NamedNodeMapEntry entry(namespaceURI, name, arg);
1079 entries.push_back(entry);
1080 return arg;
1081 }
1083 /**
1084 *
1085 */
1086 virtual Node *removeNamedItemNS(const DOMString& namespaceURI,
1087 const DOMString& localName)
1088 throw(DOMException)
1089 {
1090 std::vector<NamedNodeMapEntry>::iterator iter;
1091 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1092 {
1093 if (iter->namespaceURI == namespaceURI && iter->name == localName)
1094 {
1095 Node *node = iter->node;
1096 entries.erase(iter);
1097 return node;
1098 }
1099 }
1100 return NULL;
1101 }
1103 //##################
1104 //# Non-API methods
1105 //##################
1107 /**
1108 *
1109 */
1110 NamedNodeMap() {}
1113 /**
1114 *
1115 */
1116 NamedNodeMap(const NamedNodeMap &other)
1117 {
1118 entries = other.entries;
1119 }
1121 /**
1122 *
1123 */
1124 NamedNodeMap &operator=(const NamedNodeMap &other)
1125 {
1126 entries = other.entries;
1127 return *this;
1128 }
1131 /**
1132 *
1133 */
1134 virtual ~NamedNodeMap() {}
1136 protected:
1138 std::vector<NamedNodeMapEntry> entries;
1140 };
1145 /*#########################################################################
1146 ## CharacterData
1147 #########################################################################*/
1149 /**
1150 *
1151 */
1152 class CharacterData : virtual public Node
1153 {
1154 public:
1156 /**
1157 *
1158 */
1159 virtual DOMString getData() throw(DOMException) = 0;
1161 /**
1162 *
1163 */
1164 virtual void setData(const DOMString& val) throw(DOMException) = 0;
1166 /**
1167 *
1168 */
1169 virtual unsigned long getLength() = 0;
1171 /**
1172 *
1173 */
1174 virtual DOMString substringData(unsigned long offset,
1175 unsigned long count)
1176 throw(DOMException) = 0;
1178 /**
1179 *
1180 */
1181 virtual void appendData(const DOMString& arg) throw(DOMException) = 0;
1183 /**
1184 *
1185 */
1186 virtual void insertData(unsigned long offset,
1187 const DOMString& arg)
1188 throw(DOMException) = 0;
1190 /**
1191 *
1192 */
1193 virtual void deleteData(unsigned long offset,
1194 unsigned long count)
1195 throw(DOMException) = 0;
1197 /**
1198 *
1199 */
1200 virtual void replaceData(unsigned long offset,
1201 unsigned long count,
1202 const DOMString& arg)
1203 throw(DOMException) = 0;
1206 //##################
1207 //# Non-API methods
1208 //##################
1211 /**
1212 *
1213 */
1214 virtual ~CharacterData() {}
1216 };
1222 /*#########################################################################
1223 ## Attr
1224 #########################################################################*/
1226 /**
1227 *
1228 */
1229 class Attr : virtual public Node
1230 {
1231 public:
1233 /**
1234 *
1235 */
1236 virtual DOMString getName() = 0;
1238 /**
1239 *
1240 */
1241 virtual bool getSpecified() = 0;
1243 /**
1244 *
1245 */
1246 virtual DOMString getValue() = 0;
1248 /**
1249 *
1250 */
1251 virtual void setValue(const DOMString& val) throw(DOMException) = 0;
1253 /**
1254 *
1255 */
1256 virtual Element *getOwnerElement() = 0;
1259 /**
1260 *
1261 */
1262 virtual TypeInfo *getSchemaTypeInfo() = 0;
1265 /**
1266 *
1267 */
1268 virtual bool getIsId() = 0;
1270 //##################
1271 //# Non-API methods
1272 //##################
1275 /**
1276 *
1277 */
1278 virtual ~Attr() {}
1280 };
1286 /*#########################################################################
1287 ## Element
1288 #########################################################################*/
1290 /**
1291 *
1292 */
1293 class Element : virtual public Node
1294 {
1295 public:
1298 /**
1299 *
1300 */
1301 virtual DOMString getTagName() = 0;
1303 /**
1304 *
1305 */
1306 virtual DOMString getAttribute(const DOMString& name) = 0;
1308 /**
1309 *
1310 */
1311 virtual void setAttribute(const DOMString& name,
1312 const DOMString& value)
1313 throw(DOMException) = 0;
1315 /**
1316 *
1317 */
1318 virtual void removeAttribute(const DOMString& name)
1319 throw(DOMException) = 0;
1321 /**
1322 *
1323 */
1324 virtual Attr *getAttributeNode(const DOMString& name) = 0;
1326 /**
1327 *
1328 */
1329 virtual Attr *setAttributeNode(Attr *newAttr)
1330 throw(DOMException) = 0;
1332 /**
1333 *
1334 */
1335 virtual Attr *removeAttributeNode(Attr *oldAttr)
1336 throw(DOMException) = 0;
1338 /**
1339 *
1340 */
1341 virtual NodeList getElementsByTagName(const DOMString& name) = 0;
1343 /**
1344 *
1345 */
1346 virtual DOMString getAttributeNS(const DOMString& namespaceURI,
1347 const DOMString& localName) = 0;
1349 /**
1350 *
1351 */
1352 virtual void setAttributeNS(const DOMString& namespaceURI,
1353 const DOMString& qualifiedName,
1354 const DOMString& value)
1355 throw(DOMException) = 0;
1357 /**
1358 *
1359 */
1360 virtual void removeAttributeNS(const DOMString& namespaceURI,
1361 const DOMString& localName)
1362 throw(DOMException) = 0;
1364 /**
1365 *
1366 */
1367 virtual Attr *getAttributeNodeNS(const DOMString& namespaceURI,
1368 const DOMString& localName) = 0;
1370 /**
1371 *
1372 */
1373 virtual Attr *setAttributeNodeNS(Attr *newAttr)
1374 throw(DOMException) = 0;
1376 /**
1377 *
1378 */
1379 virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI,
1380 const DOMString& localName) = 0;
1382 /**
1383 *
1384 */
1385 virtual bool hasAttribute(const DOMString& name) = 0;
1387 /**
1388 *
1389 */
1390 virtual bool hasAttributeNS(const DOMString& namespaceURI,
1391 const DOMString& localName) = 0;
1393 /**
1394 *
1395 */
1396 virtual TypeInfo *getSchemaTypeInto() = 0;
1399 /**
1400 *
1401 */
1402 virtual void setIdAttribute(const DOMString &name,
1403 bool isId) throw (DOMException) = 0;
1405 /**
1406 *
1407 */
1408 virtual void setIdAttributeNS(const DOMString &namespaceURI,
1409 const DOMString &localName,
1410 bool isId) throw (DOMException) = 0;
1412 /**
1413 *
1414 */
1415 virtual void setIdAttributeNode(const Attr *idAttr,
1416 bool isId) throw (DOMException) = 0;
1418 //##################
1419 //# Non-API methods
1420 //##################
1422 /**
1423 *
1424 */
1425 virtual ~Element() {}
1427 };
1433 /*#########################################################################
1434 ## Text
1435 #########################################################################*/
1437 /**
1438 *
1439 */
1440 class Text : virtual public CharacterData
1441 {
1442 public:
1444 /**
1445 *
1446 */
1447 virtual Text *splitText(unsigned long offset)
1448 throw(DOMException) = 0;
1450 /**
1451 *
1452 */
1453 virtual bool getIsElementContentWhitespace()= 0;
1455 /**
1456 *
1457 */
1458 virtual DOMString getWholeText() = 0;
1461 /**
1462 *
1463 */
1464 virtual Text *replaceWholeText(const DOMString &content)
1465 throw(DOMException) = 0;
1467 //##################
1468 //# Non-API methods
1469 //##################
1472 /**
1473 *
1474 */
1475 virtual ~Text() {}
1477 };
1481 /*#########################################################################
1482 ## Comment
1483 #########################################################################*/
1485 /**
1486 *
1487 */
1488 class Comment : virtual public CharacterData
1489 {
1490 public:
1492 //##################
1493 //# Non-API methods
1494 //##################
1497 /**
1498 *
1499 */
1500 virtual ~Comment() {}
1503 };
1507 /*#########################################################################
1508 ## TypeInfo
1509 #########################################################################*/
1511 /**
1512 *
1513 */
1514 class TypeInfo
1515 {
1516 public:
1518 /**
1519 *
1520 */
1521 virtual DOMString getTypeName() =0;
1523 /**
1524 *
1525 */
1526 virtual DOMString getTypeNamespace() =0;
1528 typedef enum
1529 {
1530 DERIVATION_RESTRICTION = 0x00000001,
1531 DERIVATION_EXTENSION = 0x00000002,
1532 DERIVATION_UNION = 0x00000004,
1533 DERIVATION_LIST = 0x00000008
1534 } DerivationMethod;
1537 /**
1538 *
1539 */
1540 virtual bool isDerivedFrom(const DOMString &typeNamespaceArg,
1541 const DOMString &typeNameArg,
1542 DerivationMethod derivationMethod) =0;
1544 //##################
1545 //# Non-API methods
1546 //##################
1549 /**
1550 *
1551 */
1552 virtual ~TypeInfo() {}
1554 };
1559 /*#########################################################################
1560 ## UserDataHandler
1561 #########################################################################*/
1563 /**
1564 *
1565 */
1566 class UserDataHandler
1567 {
1568 public:
1570 typedef enum
1571 {
1572 NODE_CLONED = 1,
1573 NODE_IMPORTED = 2,
1574 NODE_DELETED = 3,
1575 NODE_RENAMED = 4,
1576 NODE_ADOPTED = 5
1577 } OperationType;
1580 /**
1581 *
1582 */
1583 virtual void handle(unsigned short operation,
1584 const DOMString &key,
1585 const DOMUserData *data,
1586 const Node *src,
1587 const Node *dst) =0;
1589 //##################
1590 //# Non-API methods
1591 //##################
1594 /**
1595 *
1596 */
1597 virtual ~UserDataHandler() {}
1599 };
1602 /*#########################################################################
1603 ## DOMError
1604 #########################################################################*/
1606 /**
1607 *
1608 */
1609 class DOMError
1610 {
1611 public:
1613 typedef enum
1614 {
1615 SEVERITY_WARNING = 1,
1616 SEVERITY_ERROR = 2,
1617 SEVERITY_FATAL_ERROR = 3
1618 } ErrorSeverity;
1621 /**
1622 *
1623 */
1624 virtual unsigned short getSeverity() =0;
1626 /**
1627 *
1628 */
1629 virtual DOMString getMessage() =0;
1631 /**
1632 *
1633 */
1634 virtual DOMString getType() =0;
1636 /**
1637 *
1638 */
1639 virtual DOMObject *getRelatedException() =0;
1641 /**
1642 *
1643 */
1644 virtual DOMObject *getRelatedData() =0;
1646 /**
1647 *
1648 */
1649 virtual DOMLocator *getLocation() =0;
1652 //##################
1653 //# Non-API methods
1654 //##################
1657 /**
1658 *
1659 */
1660 virtual ~DOMError() {}
1662 };
1665 /*#########################################################################
1666 ## DOMErrorHandler
1667 #########################################################################*/
1669 /**
1670 *
1671 */
1672 class DOMErrorHandler
1673 {
1674 public:
1675 /**
1676 *
1677 */
1678 virtual bool handleError(const DOMError *error) =0;
1680 //##################
1681 //# Non-API methods
1682 //##################
1685 /**
1686 *
1687 */
1688 virtual ~DOMErrorHandler() {}
1690 };
1694 /*#########################################################################
1695 ## DOMLocator
1696 #########################################################################*/
1698 /**
1699 *
1700 */
1701 class DOMLocator
1702 {
1703 public:
1705 /**
1706 *
1707 */
1708 virtual long getLineNumber() =0;
1710 /**
1711 *
1712 */
1713 virtual long getColumnNumber() =0;
1715 /**
1716 *
1717 */
1718 virtual long getByteOffset() =0;
1720 /**
1721 *
1722 */
1723 virtual long getUtf16Offset() =0;
1726 /**
1727 *
1728 */
1729 virtual Node *getRelatedNode() =0;
1732 /**
1733 *
1734 */
1735 virtual DOMString getUri() =0;
1737 //##################
1738 //# Non-API methods
1739 //##################
1741 /**
1742 *
1743 */
1744 virtual ~DOMLocator() {}
1745 };
1748 /*#########################################################################
1749 ## DOMConfiguration
1750 #########################################################################*/
1752 /**
1753 *
1754 */
1755 class DOMConfiguration
1756 {
1757 public:
1759 /**
1760 *
1761 */
1762 virtual void setParameter(const DOMString &name,
1763 const DOMUserData *value) throw (DOMException) =0;
1765 /**
1766 *
1767 */
1768 virtual DOMUserData *getParameter(const DOMString &name)
1769 throw (DOMException) =0;
1771 /**
1772 *
1773 */
1774 virtual bool canSetParameter(const DOMString &name,
1775 const DOMUserData *data) =0;
1777 /**
1778 *
1779 */
1780 virtual DOMStringList *getParameterNames() =0;
1782 //##################
1783 //# Non-API methods
1784 //##################
1787 /**
1788 *
1789 */
1790 virtual ~DOMConfiguration() {}
1792 };
1799 /*#########################################################################
1800 ## CDATASection
1801 #########################################################################*/
1802 /**
1803 *
1804 */
1805 class CDATASection : virtual public Text
1806 {
1807 public:
1809 //##################
1810 //# Non-API methods
1811 //##################
1814 /**
1815 *
1816 */
1817 virtual ~CDATASection() {}
1819 };
1824 /*#########################################################################
1825 ## DocumentType
1826 #########################################################################*/
1828 /**
1829 *
1830 */
1831 class DocumentType : virtual public Node
1832 {
1833 public:
1835 /**
1836 *
1837 */
1838 virtual DOMString getName() = 0;
1840 /**
1841 *
1842 */
1843 virtual NamedNodeMap getEntities() = 0;
1845 /**
1846 *
1847 */
1848 virtual NamedNodeMap getNotations() = 0;
1850 /**
1851 *
1852 */
1853 virtual DOMString getPublicId() = 0;
1855 /**
1856 *
1857 */
1858 virtual DOMString getSystemId() = 0;
1860 /**
1861 *
1862 */
1863 virtual DOMString getInternalSubset() = 0;
1865 //##################
1866 //# Non-API methods
1867 //##################
1869 /**
1870 *
1871 */
1872 virtual ~DocumentType() {}
1874 };
1880 /*#########################################################################
1881 ## Notation
1882 #########################################################################*/
1884 /**
1885 *
1886 */
1887 class Notation : virtual public Node
1888 {
1889 public:
1891 /**
1892 *
1893 */
1894 virtual DOMString getPublicId() = 0;
1896 /**
1897 *
1898 */
1899 virtual DOMString getSystemId() = 0;
1901 //##################
1902 //# Non-API methods
1903 //##################
1906 /**
1907 *
1908 */
1909 virtual ~Notation() {}
1910 };
1917 /*#########################################################################
1918 ## Entity
1919 #########################################################################*/
1921 /**
1922 *
1923 */
1924 class Entity : virtual public Node
1925 {
1926 public:
1928 /**
1929 *
1930 */
1931 virtual DOMString getPublicId() = 0;
1933 /**
1934 *
1935 */
1936 virtual DOMString getSystemId() = 0;
1938 /**
1939 *
1940 */
1941 virtual DOMString getNotationName() = 0;
1943 /**
1944 *
1945 */
1946 virtual DOMString getInputEncoding() = 0;
1948 /**
1949 *
1950 */
1951 virtual DOMString getXmlEncoding() = 0;
1953 /**
1954 *
1955 */
1956 virtual DOMString getXmlVersion() = 0;
1958 //##################
1959 //# Non-API methods
1960 //##################
1963 /**
1964 *
1965 */
1966 virtual ~Entity() {}
1967 };
1973 /*#########################################################################
1974 ## EntityReference
1975 #########################################################################*/
1976 /**
1977 *
1978 */
1979 class EntityReference : virtual public Node
1980 {
1981 public:
1984 //##################
1985 //# Non-API methods
1986 //##################
1988 /**
1989 *
1990 */
1991 virtual ~EntityReference() {}
1992 };
1998 /*#########################################################################
1999 ## ProcessingInstruction
2000 #########################################################################*/
2002 /**
2003 *
2004 */
2005 class ProcessingInstruction : virtual public Node
2006 {
2007 public:
2009 /**
2010 *
2011 */
2012 virtual DOMString getTarget() = 0;
2014 /**
2015 *
2016 */
2017 virtual DOMString getData() = 0;
2019 /**
2020 *
2021 */
2022 virtual void setData(const DOMString& val) throw(DOMException) = 0;
2024 //##################
2025 //# Non-API methods
2026 //##################
2029 /**
2030 *
2031 */
2032 virtual ~ProcessingInstruction() {}
2034 };
2040 /*#########################################################################
2041 ## DocumentFragment
2042 #########################################################################*/
2043 /**
2044 *
2045 */
2046 class DocumentFragment : virtual public Node
2047 {
2048 public:
2050 //##################
2051 //# Non-API methods
2052 //##################
2055 /**
2056 *
2057 */
2058 virtual ~DocumentFragment() {}
2059 };
2066 /*#########################################################################
2067 ## Document
2068 #########################################################################*/
2070 /**
2071 *
2072 */
2073 class Document : virtual public Node
2074 {
2075 public:
2077 /**
2078 *
2079 */
2080 virtual DocumentType *getDoctype() = 0;
2082 /**
2083 *
2084 */
2085 virtual DOMImplementation *getImplementation() = 0;
2087 /**
2088 *
2089 */
2090 virtual Element *getDocumentElement() = 0;
2092 /**
2093 *
2094 */
2095 virtual Element *createElement(const DOMString& tagName)
2096 throw(DOMException) = 0;
2098 /**
2099 *
2100 */
2101 virtual DocumentFragment *createDocumentFragment() = 0;
2103 /**
2104 *
2105 */
2106 virtual Text *createTextNode(const DOMString& data) = 0;
2108 /**
2109 *
2110 */
2111 virtual Comment *createComment(const DOMString& data) = 0;
2113 /**
2114 *
2115 */
2116 virtual CDATASection *createCDATASection(const DOMString& data)
2117 throw(DOMException) = 0;
2119 /**
2120 *
2121 */
2122 virtual ProcessingInstruction *createProcessingInstruction(const DOMString& target,
2123 const DOMString& data)
2124 throw(DOMException) = 0;
2126 /**
2127 *
2128 */
2129 virtual Attr *createAttribute(const DOMString& name)
2130 throw(DOMException) = 0;
2132 /**
2133 *
2134 */
2135 virtual EntityReference *createEntityReference(const DOMString& name)
2136 throw(DOMException) = 0;
2138 /**
2139 *
2140 */
2141 virtual NodeList getElementsByTagName(const DOMString& tagname) = 0;
2144 /**
2145 *
2146 */
2147 virtual Node *importNode(const Node *importedNode,
2148 bool deep)
2149 throw(DOMException) = 0;
2151 /**
2152 *
2153 */
2154 virtual Element *createElementNS(const DOMString& namespaceURI,
2155 const DOMString& qualifiedName)
2156 throw(DOMException) = 0;
2158 /**
2159 *
2160 */
2161 virtual Attr *createAttributeNS(const DOMString& namespaceURI,
2162 const DOMString& qualifiedName)
2163 throw(DOMException) = 0;
2165 /**
2166 *
2167 */
2168 virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI,
2169 const DOMString& localName) = 0;
2171 /**
2172 *
2173 */
2174 virtual Element *getElementById(const DOMString& elementId) = 0;
2177 /**
2178 *
2179 */
2180 virtual DOMString getInputEncoding() = 0;
2183 /**
2184 *
2185 */
2186 virtual DOMString getXmlEncoding() = 0;
2188 /**
2189 *
2190 */
2191 virtual bool getXmlStandalone() = 0;
2193 /**
2194 *
2195 */
2196 virtual void setXmlStandalone(bool val) throw (DOMException) = 0;
2198 /**
2199 *
2200 */
2201 virtual DOMString getXmlVersion() = 0;
2203 /**
2204 *
2205 */
2206 virtual void setXmlVersion(const DOMString &version) throw (DOMException) = 0;
2208 /**
2209 *
2210 */
2211 virtual bool getStrictErrorChecking() = 0;
2213 /**
2214 *
2215 */
2216 virtual void setStrictErrorChecking(bool val) = 0;
2219 /**
2220 *
2221 */
2222 virtual DOMString getDocumentURI() = 0;
2224 /**
2225 *
2226 */
2227 virtual void setDocumentURI(const DOMString &uri) = 0;
2229 /**
2230 *
2231 */
2232 virtual Node *adoptNode(const Node *source) throw (DOMException) = 0;
2234 /**
2235 *
2236 */
2237 virtual DOMConfiguration *getDomConfig() = 0;
2239 /**
2240 *
2241 */
2242 virtual void normalizeDocument() = 0;
2244 /**
2245 *
2246 */
2247 virtual Node *renameNode(const Node *n,
2248 const DOMString &namespaceURI,
2249 const DOMString &qualifiedName)
2250 throw (DOMException) = 0;
2253 //##################
2254 //# Non-API methods
2255 //##################
2257 /**
2258 *
2259 */
2260 virtual ~Document() {}
2262 };
2274 } //namespace dom
2275 } //namespace w3c
2276 } //namespace org
2279 #endif // __DOM_H__
2282 /*#########################################################################
2283 ## E N D O F F I L E
2284 #########################################################################*/