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 <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 DOMException(const DOMString &reasonMsg)
145 { msg = reasonMsg; }
147 DOMException(short theCode)
148 {
149 code = theCode;
150 }
152 virtual ~DOMException() throw()
153 {}
155 /**
156 *
157 */
158 unsigned short code;
160 /**
161 *
162 */
163 DOMString msg;
165 /**
166 * Get a string, translated from the code.
167 * Like std::exception. Not in spec.
168 */
169 const char *what()
170 { return (const char *)msg.c_str(); }
174 };
179 /**
180 * ExceptionCode
181 */
182 typedef enum
183 {
184 INDEX_SIZE_ERR = 1,
185 DOMSTRING_SIZE_ERR = 2,
186 HIERARCHY_REQUEST_ERR = 3,
187 WRONG_DOCUMENT_ERR = 4,
188 INVALID_CHARACTER_ERR = 5,
189 NO_DATA_ALLOWED_ERR = 6,
190 NO_MODIFICATION_ALLOWED_ERR = 7,
191 NOT_FOUND_ERR = 8,
192 NOT_SUPPORTED_ERR = 9,
193 INUSE_ATTRIBUTE_ERR = 10,
194 INVALID_STATE_ERR = 11,
195 SYNTAX_ERR = 12,
196 INVALID_MODIFICATION_ERR = 13,
197 NAMESPACE_ERR = 14,
198 INVALID_ACCESS_ERR = 15,
199 VALIDATION_ERR = 16,
200 TYPE_MISMATCH_ERR = 17
201 } ExceptionCode;
204 /*#########################################################################
205 ## DOMStringList
206 #########################################################################*/
208 class DOMStringList
209 {
210 public:
212 /**
213 *
214 */
215 virtual DOMString item(unsigned long index)
216 {
217 if (index>=strings.size())
218 return "";
219 return strings[index];
220 }
222 /**
223 *
224 */
225 virtual unsigned long getLength()
226 {
227 return (unsigned long) strings.size();
228 }
230 /**
231 *
232 */
233 virtual bool contains(const DOMString &str)
234 {
235 for (unsigned int i=0; i<strings.size() ; i++)
236 {
237 if (strings[i] == str)
238 return true;
239 }
240 return false;
241 }
244 //##################
245 //# Non-API methods
246 //##################
248 /**
249 *
250 */
251 DOMStringList() {}
254 /**
255 *
256 */
257 DOMStringList(const DOMStringList &other)
258 {
259 strings = other.strings;
260 }
262 /**
263 *
264 */
265 virtual ~DOMStringList() {}
268 protected:
270 /**
271 *
272 */
273 virtual void add(const DOMString &str)
274 {
275 strings.push_back(str);
276 }
278 std::vector<DOMString>strings;
280 };
284 /*#########################################################################
285 ## NameList
286 #########################################################################*/
287 class NamePair
288 {
289 public:
290 NamePair(const DOMString &theNamespaceURI, const DOMString &theName)
291 {
292 namespaceURI = theNamespaceURI;
293 name = theName;
294 }
295 NamePair(const NamePair &other)
296 {
297 namespaceURI = other.namespaceURI;
298 name = other.name;
299 }
300 virtual ~NamePair() {}
302 DOMString namespaceURI;
303 DOMString name;
304 };
308 class NameList
309 {
310 public:
312 /**
313 *
314 */
315 virtual DOMString getName(unsigned long index)
316 {
317 if (index>=namePairs.size())
318 return "";
319 return namePairs[index].name;
320 }
322 /**
323 *
324 */
325 virtual DOMString getNamespaceURI(unsigned long index)
326 {
327 if (index>=namePairs.size())
328 return "";
329 return namePairs[index].namespaceURI;
330 }
332 /**
333 *
334 */
335 virtual unsigned long getLength()
336 {
337 return (unsigned long)namePairs.size();
338 }
340 /**
341 *
342 */
343 virtual bool contains(const DOMString &name)
344 {
345 for (unsigned int i=0; i<namePairs.size() ; i++)
346 {
347 if (namePairs[i].name == name )
348 return true;
349 }
350 return false;
351 }
353 /**
354 *
355 */
356 virtual bool containsNS(const DOMString namespaceURI,const DOMString &name)
357 {
358 for (unsigned int i=0; i<namePairs.size() ; i++)
359 {
360 if (namePairs[i].namespaceURI == namespaceURI ||
361 namePairs[i].name == name )
362 return true;
363 }
364 return false;
365 }
368 //##################
369 //# Non-API methods
370 //##################
372 /**
373 *
374 */
375 NameList() {}
377 /**
378 *
379 */
380 NameList(const NameList &other)
381 {
382 namePairs = other.namePairs;
383 }
385 /**
386 *
387 */
388 virtual ~NameList() {}
389 protected:
391 std::vector<NamePair> namePairs;
393 };
395 /*#########################################################################
396 ## DOMImplementationList
397 #########################################################################*/
399 class DOMImplementationList
400 {
401 public:
403 /**
404 *
405 */
406 virtual DOMImplementation *getDOMImplementation(unsigned long index)
407 {
408 if (index >implementations.size())
409 return NULL;
410 return implementations[index];
411 }
413 /**
414 *
415 */
416 virtual unsigned long getLength()
417 {
418 return (unsigned long) implementations.size();
419 }
424 //##################
425 //# Non-API methods
426 //##################
428 /**
429 *
430 */
431 DOMImplementationList() {}
434 /**
435 *
436 */
437 DOMImplementationList(const DOMImplementationList &other)
438 {
439 implementations = other.implementations;
440 }
442 /**
443 *
444 */
445 virtual ~DOMImplementationList() {}
447 protected:
449 std::vector<DOMImplementation *>implementations;
451 };
454 /*#########################################################################
455 ## DOMImplementationSource
456 #########################################################################*/
458 class DOMImplementationSource
459 {
460 public:
462 /**
463 *
464 */
465 virtual DOMImplementation *getDOMImplementation(const DOMString &features) = 0;
467 /**
468 *
469 */
470 virtual DOMImplementationList getDOMImplementationList(const DOMString &features) = 0;
472 //##################
473 //# Non-API methods
474 //##################
476 /**
477 *
478 */
479 virtual ~DOMImplementationSource() {}
481 };
487 /*#########################################################################
488 ## DOMImplementation
489 #########################################################################*/
490 /**
491 *
492 */
493 class DOMImplementation
494 {
495 public:
496 /**
497 *
498 */
499 virtual bool hasFeature(const DOMString& feature, const DOMString& version) = 0;
502 /**
503 *
504 */
505 virtual DocumentType *createDocumentType(const DOMString& qualifiedName,
506 const DOMString& publicId,
507 const DOMString& systemId)
508 throw(DOMException) = 0;
510 /**
511 *
512 */
513 virtual Document *createDocument(const DOMString& namespaceURI,
514 const DOMString& qualifiedName,
515 DocumentType *doctype)
516 throw(DOMException) = 0;
517 /**
518 *
519 */
520 virtual DOMObject *getFeature(const DOMString& feature,
521 const DOMString& version) = 0;
524 //##################
525 //# Non-API methods
526 //##################
528 /**
529 *
530 */
531 virtual ~DOMImplementation() {}
533 };
538 /*#########################################################################
539 ## Node
540 #########################################################################*/
542 /**
543 *
544 */
545 class Node
546 {
547 public:
549 typedef enum
550 {
551 ELEMENT_NODE = 1,
552 ATTRIBUTE_NODE = 2,
553 TEXT_NODE = 3,
554 CDATA_SECTION_NODE = 4,
555 ENTITY_REFERENCE_NODE = 5,
556 ENTITY_NODE = 6,
557 PROCESSING_INSTRUCTION_NODE = 7,
558 COMMENT_NODE = 8,
559 DOCUMENT_NODE = 9,
560 DOCUMENT_TYPE_NODE = 10,
561 DOCUMENT_FRAGMENT_NODE = 11,
562 NOTATION_NODE = 12
563 } NodeType;
565 /**
566 *
567 */
568 virtual DOMString getNodeName() = 0;
570 /**
571 *
572 */
573 virtual DOMString getNodeValue() throw (DOMException) = 0;
575 /**
576 *
577 */
578 virtual void setNodeValue(const DOMString& val) throw (DOMException) = 0;
580 /**
581 *
582 */
583 virtual unsigned short getNodeType() = 0;
585 /**
586 *
587 */
588 virtual Node *getParentNode() = 0;
590 /**
591 *
592 */
593 virtual NodeList getChildNodes() = 0;
595 /**
596 *
597 */
598 virtual Node *getFirstChild() = 0;
600 /**
601 *
602 */
603 virtual Node *getLastChild() = 0;
605 /**
606 *
607 */
608 virtual Node *getPreviousSibling() = 0;
610 /**
611 *
612 */
613 virtual Node *getNextSibling() = 0;
615 /**
616 *
617 */
618 virtual NamedNodeMap &getAttributes() = 0;
621 /**
622 *
623 */
624 virtual Document *getOwnerDocument() = 0;
626 /**
627 *
628 */
629 virtual Node *insertBefore(const Node *newChild,
630 const Node *refChild)
631 throw(DOMException) = 0;
633 /**
634 *
635 */
636 virtual Node *replaceChild(const Node *newChild,
637 const Node *oldChild)
638 throw(DOMException) = 0;
640 /**
641 *
642 */
643 virtual Node *removeChild(const Node *oldChild)
644 throw(DOMException) = 0;
646 /**
647 *
648 */
649 virtual Node *appendChild(const Node *newChild)
650 throw(DOMException) = 0;
652 /**
653 *
654 */
655 virtual bool hasChildNodes() = 0;
657 /**
658 *
659 */
660 virtual Node *cloneNode(bool deep) = 0;
662 /**
663 *
664 */
665 virtual void normalize() = 0;
667 /**
668 *
669 */
670 virtual bool isSupported(const DOMString& feature,
671 const DOMString& version) = 0;
673 /**
674 *
675 */
676 virtual DOMString getNamespaceURI() = 0;
678 /**
679 *
680 */
681 virtual DOMString getPrefix() = 0;
683 /**
684 *
685 */
686 virtual void setPrefix(const DOMString& val) throw(DOMException) = 0;
688 /**
689 *
690 */
691 virtual DOMString getLocalName() = 0;
693 /**
694 *
695 */
696 virtual bool hasAttributes() = 0;
698 /**
699 *
700 */
701 virtual DOMString getBaseURI() = 0;
703 typedef enum
704 {
705 DOCUMENT_POSITION_DISCONNECTED = 0x01,
706 DOCUMENT_POSITION_PRECEDING = 0x02,
707 DOCUMENT_POSITION_FOLLOWING = 0x04,
708 DOCUMENT_POSITION_CONTAINS = 0x08,
709 DOCUMENT_POSITION_CONTAINED_BY = 0x10,
710 DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20
711 } DocumentPosition;
714 /**
715 *
716 */
717 virtual unsigned short compareDocumentPosition(const Node *other) = 0;
719 /**
720 *
721 */
722 virtual DOMString getTextContext() throw(DOMException) = 0;
725 /**
726 *
727 */
728 virtual void setTextContext(const DOMString &val) throw(DOMException) = 0;
731 /**
732 *
733 */
734 virtual DOMString lookupPrefix(const DOMString &namespaceURI) =0;
737 /**
738 *
739 */
740 virtual bool isDefaultNamespace(const DOMString &namespaceURI) =0;
743 /**
744 *
745 */
746 virtual DOMString lookupNamespaceURI(const DOMString &prefix) =0;
749 /**
750 *
751 */
752 virtual bool isEqualNode(const Node *node) =0;
756 /**
757 *
758 */
759 virtual DOMObject *getFeature(const DOMString &feature,
760 const DOMString &version) =0;
762 /**
763 *
764 */
765 virtual DOMUserData *setUserData(const DOMString &key,
766 const DOMUserData *data,
767 const UserDataHandler *handler) =0;
770 /**
771 *
772 */
773 virtual DOMUserData *getUserData(const DOMString &namespaceURI) =0;
775 //##################
776 //# Non-API methods
777 //##################
780 /**
781 *
782 */
783 virtual ~Node() {}
788 };
792 /*#########################################################################
793 ## NodeList
794 #########################################################################*/
796 /**
797 *
798 */
799 class NodeList
800 {
801 public:
802 /**
803 *
804 */
805 virtual Node *item(unsigned long index)
806 {
807 if (index>=nodes.size())
808 return NULL;
809 return nodes[index];
810 }
812 /**
813 *
814 */
815 virtual unsigned long getLength()
816 {
817 return (unsigned long) nodes.size();
818 }
820 //##################
821 //# Non-API methods
822 //##################
825 /**
826 *
827 */
828 NodeList() {}
830 /**
831 *
832 */
833 NodeList(const NodeList &other)
834 {
835 nodes = other.nodes;
836 }
838 /**
839 *
840 */
841 virtual ~NodeList() {}
843 protected:
845 friend class NodeImpl;
846 friend class ElementImpl;
848 /*
849 *
850 */
851 virtual void add(const Node *node)
852 {
853 nodes.push_back((Node *)node);
854 }
856 protected:
858 std::vector<Node *> nodes;
860 };
865 /*#########################################################################
866 ## NamedNodeMap
867 #########################################################################*/
869 class NamedNodeMapEntry
870 {
871 public:
872 NamedNodeMapEntry(const DOMString &theNamespaceURI,
873 const DOMString &theName,
874 const Node *theNode)
875 {
876 namespaceURI = theNamespaceURI;
877 name = theName;
878 node = (Node *)theNode;
879 }
880 NamedNodeMapEntry(const NamedNodeMapEntry &other)
881 {
882 namespaceURI = other.namespaceURI;
883 name = other.name;
884 node = other.node;
885 }
886 virtual ~NamedNodeMapEntry()
887 {
888 }
889 DOMString namespaceURI;
890 DOMString name;
891 Node *node;
892 };
894 /**
895 *
896 */
897 class NamedNodeMap
898 {
899 public:
901 /**
902 *
903 */
904 virtual Node *getNamedItem(const DOMString& name)
905 {
906 std::vector<NamedNodeMapEntry>::iterator iter;
907 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
908 {
909 if (iter->name == name)
910 {
911 Node *node = iter->node;
912 return node;
913 }
914 }
915 return NULL;
916 }
918 /**
919 *
920 */
921 virtual Node *setNamedItem(Node *arg) throw(DOMException)
922 {
923 if (!arg)
924 return NULL;
925 DOMString namespaceURI = arg->getNamespaceURI();
926 DOMString name = arg->getNodeName();
927 std::vector<NamedNodeMapEntry>::iterator iter;
928 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
929 {
930 if (iter->name == name)
931 {
932 Node *node = iter->node;
933 iter->node = arg;
934 return node;
935 }
936 }
937 NamedNodeMapEntry entry(namespaceURI, name, arg);
938 entries.push_back(entry);
939 return arg;
940 }
943 /**
944 *
945 */
946 virtual Node *removeNamedItem(const DOMString& name) throw(DOMException)
947 {
948 std::vector<NamedNodeMapEntry>::iterator iter;
949 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
950 {
951 if (iter->name == name)
952 {
953 Node *node = iter->node;
954 entries.erase(iter);
955 return node;
956 }
957 }
958 return NULL;
959 }
961 /**
962 *
963 */
964 virtual Node *item(unsigned long index)
965 {
966 if (index>=entries.size())
967 return NULL;
968 return entries[index].node;
969 }
971 /**
972 *
973 */
974 virtual unsigned long getLength()
975 {
976 return (unsigned long)entries.size();
977 }
979 /**
980 *
981 */
982 virtual Node *getNamedItemNS(const DOMString& namespaceURI,
983 const DOMString& localName)
984 {
985 std::vector<NamedNodeMapEntry>::iterator iter;
986 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
987 {
988 if (iter->namespaceURI == namespaceURI && iter->name == localName)
989 {
990 Node *node = iter->node;
991 return node;
992 }
993 }
994 return NULL;
995 }
997 /**
998 *
999 */
1000 virtual Node *setNamedItemNS(Node *arg) throw(DOMException)
1001 {
1002 if (!arg)
1003 return NULL;
1004 DOMString namespaceURI = arg->getNamespaceURI();
1005 DOMString name = arg->getNodeName();
1006 std::vector<NamedNodeMapEntry>::iterator iter;
1007 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1008 {
1009 if (iter->namespaceURI == namespaceURI && iter->name == name)
1010 {
1011 Node *node = iter->node;
1012 iter->node = arg;
1013 return node;
1014 }
1015 }
1016 NamedNodeMapEntry entry(namespaceURI, name, arg);
1017 entries.push_back(entry);
1018 return arg;
1019 }
1021 /**
1022 *
1023 */
1024 virtual Node *removeNamedItemNS(const DOMString& namespaceURI,
1025 const DOMString& localName)
1026 throw(DOMException)
1027 {
1028 std::vector<NamedNodeMapEntry>::iterator iter;
1029 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1030 {
1031 if (iter->namespaceURI == namespaceURI && iter->name == localName)
1032 {
1033 Node *node = iter->node;
1034 entries.erase(iter);
1035 return node;
1036 }
1037 }
1038 return NULL;
1039 }
1041 //##################
1042 //# Non-API methods
1043 //##################
1045 /**
1046 *
1047 */
1048 NamedNodeMap() {}
1051 /**
1052 *
1053 */
1054 NamedNodeMap(const NamedNodeMap &other)
1055 {
1056 entries = other.entries;
1057 }
1060 /**
1061 *
1062 */
1063 virtual ~NamedNodeMap() {}
1065 protected:
1067 std::vector<NamedNodeMapEntry> entries;
1069 };
1074 /*#########################################################################
1075 ## CharacterData
1076 #########################################################################*/
1078 /**
1079 *
1080 */
1081 class CharacterData : virtual public Node
1082 {
1083 public:
1085 /**
1086 *
1087 */
1088 virtual DOMString getData() throw(DOMException) = 0;
1090 /**
1091 *
1092 */
1093 virtual void setData(const DOMString& val) throw(DOMException) = 0;
1095 /**
1096 *
1097 */
1098 virtual unsigned long getLength() = 0;
1100 /**
1101 *
1102 */
1103 virtual DOMString substringData(unsigned long offset,
1104 unsigned long count)
1105 throw(DOMException) = 0;
1107 /**
1108 *
1109 */
1110 virtual void appendData(const DOMString& arg) throw(DOMException) = 0;
1112 /**
1113 *
1114 */
1115 virtual void insertData(unsigned long offset,
1116 const DOMString& arg)
1117 throw(DOMException) = 0;
1119 /**
1120 *
1121 */
1122 virtual void deleteData(unsigned long offset,
1123 unsigned long count)
1124 throw(DOMException) = 0;
1126 /**
1127 *
1128 */
1129 virtual void replaceData(unsigned long offset,
1130 unsigned long count,
1131 const DOMString& arg)
1132 throw(DOMException) = 0;
1135 //##################
1136 //# Non-API methods
1137 //##################
1140 /**
1141 *
1142 */
1143 virtual ~CharacterData() {}
1145 };
1151 /*#########################################################################
1152 ## Attr
1153 #########################################################################*/
1155 /**
1156 *
1157 */
1158 class Attr : virtual public Node
1159 {
1160 public:
1162 /**
1163 *
1164 */
1165 virtual DOMString getName() = 0;
1167 /**
1168 *
1169 */
1170 virtual bool getSpecified() = 0;
1172 /**
1173 *
1174 */
1175 virtual DOMString getValue() = 0;
1177 /**
1178 *
1179 */
1180 virtual void setValue(const DOMString& val) throw(DOMException) = 0;
1182 /**
1183 *
1184 */
1185 virtual Element *getOwnerElement() = 0;
1188 /**
1189 *
1190 */
1191 virtual TypeInfo *getSchemaTypeInfo() = 0;
1194 /**
1195 *
1196 */
1197 virtual bool getIsId() = 0;
1199 //##################
1200 //# Non-API methods
1201 //##################
1204 /**
1205 *
1206 */
1207 virtual ~Attr() {}
1209 };
1215 /*#########################################################################
1216 ## Element
1217 #########################################################################*/
1219 /**
1220 *
1221 */
1222 class Element : virtual public Node
1223 {
1224 public:
1227 /**
1228 *
1229 */
1230 virtual DOMString getTagName() = 0;
1232 /**
1233 *
1234 */
1235 virtual DOMString getAttribute(const DOMString& name) = 0;
1237 /**
1238 *
1239 */
1240 virtual void setAttribute(const DOMString& name,
1241 const DOMString& value)
1242 throw(DOMException) = 0;
1244 /**
1245 *
1246 */
1247 virtual void removeAttribute(const DOMString& name)
1248 throw(DOMException) = 0;
1250 /**
1251 *
1252 */
1253 virtual Attr *getAttributeNode(const DOMString& name) = 0;
1255 /**
1256 *
1257 */
1258 virtual Attr *setAttributeNode(Attr *newAttr)
1259 throw(DOMException) = 0;
1261 /**
1262 *
1263 */
1264 virtual Attr *removeAttributeNode(Attr *oldAttr)
1265 throw(DOMException) = 0;
1267 /**
1268 *
1269 */
1270 virtual NodeList getElementsByTagName(const DOMString& name) = 0;
1272 /**
1273 *
1274 */
1275 virtual DOMString getAttributeNS(const DOMString& namespaceURI,
1276 const DOMString& localName) = 0;
1278 /**
1279 *
1280 */
1281 virtual void setAttributeNS(const DOMString& namespaceURI,
1282 const DOMString& qualifiedName,
1283 const DOMString& value)
1284 throw(DOMException) = 0;
1286 /**
1287 *
1288 */
1289 virtual void removeAttributeNS(const DOMString& namespaceURI,
1290 const DOMString& localName)
1291 throw(DOMException) = 0;
1293 /**
1294 *
1295 */
1296 virtual Attr *getAttributeNodeNS(const DOMString& namespaceURI,
1297 const DOMString& localName) = 0;
1299 /**
1300 *
1301 */
1302 virtual Attr *setAttributeNodeNS(Attr *newAttr)
1303 throw(DOMException) = 0;
1305 /**
1306 *
1307 */
1308 virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI,
1309 const DOMString& localName) = 0;
1311 /**
1312 *
1313 */
1314 virtual bool hasAttribute(const DOMString& name) = 0;
1316 /**
1317 *
1318 */
1319 virtual bool hasAttributeNS(const DOMString& namespaceURI,
1320 const DOMString& localName) = 0;
1322 /**
1323 *
1324 */
1325 virtual TypeInfo *getSchemaTypeInto() = 0;
1328 /**
1329 *
1330 */
1331 virtual void setIdAttribute(const DOMString &name,
1332 bool isId) throw (DOMException) = 0;
1334 /**
1335 *
1336 */
1337 virtual void setIdAttributeNS(const DOMString &namespaceURI,
1338 const DOMString &localName,
1339 bool isId) throw (DOMException) = 0;
1341 /**
1342 *
1343 */
1344 virtual void setIdAttributeNode(const Attr *idAttr,
1345 bool isId) throw (DOMException) = 0;
1347 //##################
1348 //# Non-API methods
1349 //##################
1351 /**
1352 *
1353 */
1354 virtual ~Element() {}
1356 };
1362 /*#########################################################################
1363 ## Text
1364 #########################################################################*/
1366 /**
1367 *
1368 */
1369 class Text : virtual public CharacterData
1370 {
1371 public:
1373 /**
1374 *
1375 */
1376 virtual Text *splitText(unsigned long offset)
1377 throw(DOMException) = 0;
1379 /**
1380 *
1381 */
1382 virtual bool getIsElementContentWhitespace()= 0;
1384 /**
1385 *
1386 */
1387 virtual DOMString getWholeText() = 0;
1390 /**
1391 *
1392 */
1393 virtual Text *replaceWholeText(const DOMString &content)
1394 throw(DOMException) = 0;
1396 //##################
1397 //# Non-API methods
1398 //##################
1401 /**
1402 *
1403 */
1404 virtual ~Text() {}
1406 };
1410 /*#########################################################################
1411 ## Comment
1412 #########################################################################*/
1414 /**
1415 *
1416 */
1417 class Comment : virtual public CharacterData
1418 {
1419 public:
1421 //##################
1422 //# Non-API methods
1423 //##################
1426 /**
1427 *
1428 */
1429 virtual ~Comment() {}
1432 };
1436 /*#########################################################################
1437 ## TypeInfo
1438 #########################################################################*/
1440 /**
1441 *
1442 */
1443 class TypeInfo
1444 {
1445 public:
1447 /**
1448 *
1449 */
1450 virtual DOMString getTypeName() =0;
1452 /**
1453 *
1454 */
1455 virtual DOMString getTypeNamespace() =0;
1457 typedef enum
1458 {
1459 DERIVATION_RESTRICTION = 0x00000001,
1460 DERIVATION_EXTENSION = 0x00000002,
1461 DERIVATION_UNION = 0x00000004,
1462 DERIVATION_LIST = 0x00000008
1463 } DerivationMethod;
1466 /**
1467 *
1468 */
1469 virtual bool isDerivedFrom(const DOMString &typeNamespaceArg,
1470 const DOMString &typeNameArg,
1471 DerivationMethod derivationMethod) =0;
1473 //##################
1474 //# Non-API methods
1475 //##################
1478 /**
1479 *
1480 */
1481 virtual ~TypeInfo() {}
1483 };
1488 /*#########################################################################
1489 ## UserDataHandler
1490 #########################################################################*/
1492 /**
1493 *
1494 */
1495 class UserDataHandler
1496 {
1497 public:
1499 typedef enum
1500 {
1501 NODE_CLONED = 1,
1502 NODE_IMPORTED = 2,
1503 NODE_DELETED = 3,
1504 NODE_RENAMED = 4,
1505 NODE_ADOPTED = 5
1506 } OperationType;
1509 /**
1510 *
1511 */
1512 virtual void handle(unsigned short operation,
1513 const DOMString &key,
1514 const DOMUserData *data,
1515 const Node *src,
1516 const Node *dst) =0;
1518 //##################
1519 //# Non-API methods
1520 //##################
1523 /**
1524 *
1525 */
1526 virtual ~UserDataHandler() {}
1528 };
1531 /*#########################################################################
1532 ## DOMError
1533 #########################################################################*/
1535 /**
1536 *
1537 */
1538 class DOMError
1539 {
1540 public:
1542 typedef enum
1543 {
1544 DOMERROR_SEVERITY_WARNING = 1,
1545 DOMERROR_SEVERITY_ERROR = 2,
1546 DOMERROR_SEVERITY_FATAL_ERROR = 3
1547 } ErrorSeverity;
1550 /**
1551 *
1552 */
1553 virtual unsigned short getSeverity() =0;
1555 /**
1556 *
1557 */
1558 virtual DOMString getMessage() =0;
1560 /**
1561 *
1562 */
1563 virtual DOMString getType() =0;
1565 /**
1566 *
1567 */
1568 virtual DOMObject *getRelatedException() =0;
1570 /**
1571 *
1572 */
1573 virtual DOMObject *getRelatedData() =0;
1575 /**
1576 *
1577 */
1578 virtual DOMLocator *getLocation() =0;
1581 //##################
1582 //# Non-API methods
1583 //##################
1586 /**
1587 *
1588 */
1589 virtual ~DOMError() {}
1591 };
1594 /*#########################################################################
1595 ## DOMErrorHandler
1596 #########################################################################*/
1598 /**
1599 *
1600 */
1601 class DOMErrorHandler
1602 {
1603 public:
1604 /**
1605 *
1606 */
1607 virtual bool handleError(const DOMError *error) =0;
1609 //##################
1610 //# Non-API methods
1611 //##################
1614 /**
1615 *
1616 */
1617 virtual ~DOMErrorHandler() {}
1619 };
1623 /*#########################################################################
1624 ## DOMLocator
1625 #########################################################################*/
1627 /**
1628 *
1629 */
1630 class DOMLocator
1631 {
1632 public:
1634 /**
1635 *
1636 */
1637 virtual long getLineNumber() =0;
1639 /**
1640 *
1641 */
1642 virtual long getColumnNumber() =0;
1644 /**
1645 *
1646 */
1647 virtual long getByteOffset() =0;
1649 /**
1650 *
1651 */
1652 virtual long getUtf16Offset() =0;
1655 /**
1656 *
1657 */
1658 virtual Node *getRelatedNode() =0;
1661 /**
1662 *
1663 */
1664 virtual DOMString getUri() =0;
1666 //##################
1667 //# Non-API methods
1668 //##################
1670 /**
1671 *
1672 */
1673 virtual ~DOMLocator() {}
1674 };
1677 /*#########################################################################
1678 ## DOMConfiguration
1679 #########################################################################*/
1681 /**
1682 *
1683 */
1684 class DOMConfiguration
1685 {
1686 public:
1688 /**
1689 *
1690 */
1691 virtual void setParameter(const DOMString &name,
1692 const DOMUserData *value) throw (DOMException) =0;
1694 /**
1695 *
1696 */
1697 virtual DOMUserData *getParameter(const DOMString &name)
1698 throw (DOMException) =0;
1700 /**
1701 *
1702 */
1703 virtual bool canSetParameter(const DOMString &name,
1704 const DOMUserData *data) =0;
1706 /**
1707 *
1708 */
1709 virtual DOMStringList *getParameterNames() =0;
1711 //##################
1712 //# Non-API methods
1713 //##################
1716 /**
1717 *
1718 */
1719 virtual ~DOMConfiguration() {}
1721 };
1728 /*#########################################################################
1729 ## CDATASection
1730 #########################################################################*/
1731 /**
1732 *
1733 */
1734 class CDATASection : virtual public Text
1735 {
1736 public:
1738 //##################
1739 //# Non-API methods
1740 //##################
1743 /**
1744 *
1745 */
1746 virtual ~CDATASection() {}
1748 };
1753 /*#########################################################################
1754 ## DocumentType
1755 #########################################################################*/
1757 /**
1758 *
1759 */
1760 class DocumentType : virtual public Node
1761 {
1762 public:
1764 /**
1765 *
1766 */
1767 virtual DOMString getName() = 0;
1769 /**
1770 *
1771 */
1772 virtual NamedNodeMap getEntities() = 0;
1774 /**
1775 *
1776 */
1777 virtual NamedNodeMap getNotations() = 0;
1779 /**
1780 *
1781 */
1782 virtual DOMString getPublicId() = 0;
1784 /**
1785 *
1786 */
1787 virtual DOMString getSystemId() = 0;
1789 /**
1790 *
1791 */
1792 virtual DOMString getInternalSubset() = 0;
1794 //##################
1795 //# Non-API methods
1796 //##################
1798 /**
1799 *
1800 */
1801 virtual ~DocumentType() {}
1803 };
1809 /*#########################################################################
1810 ## Notation
1811 #########################################################################*/
1813 /**
1814 *
1815 */
1816 class Notation : virtual public Node
1817 {
1818 public:
1820 /**
1821 *
1822 */
1823 virtual DOMString getPublicId() = 0;
1825 /**
1826 *
1827 */
1828 virtual DOMString getSystemId() = 0;
1830 //##################
1831 //# Non-API methods
1832 //##################
1835 /**
1836 *
1837 */
1838 virtual ~Notation() {}
1839 };
1846 /*#########################################################################
1847 ## Entity
1848 #########################################################################*/
1850 /**
1851 *
1852 */
1853 class Entity : virtual public Node
1854 {
1855 public:
1857 /**
1858 *
1859 */
1860 virtual DOMString getPublicId() = 0;
1862 /**
1863 *
1864 */
1865 virtual DOMString getSystemId() = 0;
1867 /**
1868 *
1869 */
1870 virtual DOMString getNotationName() = 0;
1872 /**
1873 *
1874 */
1875 virtual DOMString getInputEncoding() = 0;
1877 /**
1878 *
1879 */
1880 virtual DOMString getXmlEncoding() = 0;
1882 /**
1883 *
1884 */
1885 virtual DOMString getXmlVersion() = 0;
1887 //##################
1888 //# Non-API methods
1889 //##################
1892 /**
1893 *
1894 */
1895 virtual ~Entity() {}
1896 };
1902 /*#########################################################################
1903 ## EntityReference
1904 #########################################################################*/
1905 /**
1906 *
1907 */
1908 class EntityReference : virtual public Node
1909 {
1910 public:
1913 //##################
1914 //# Non-API methods
1915 //##################
1917 /**
1918 *
1919 */
1920 virtual ~EntityReference() {}
1921 };
1927 /*#########################################################################
1928 ## ProcessingInstruction
1929 #########################################################################*/
1931 /**
1932 *
1933 */
1934 class ProcessingInstruction : virtual public Node
1935 {
1936 public:
1938 /**
1939 *
1940 */
1941 virtual DOMString getTarget() = 0;
1943 /**
1944 *
1945 */
1946 virtual DOMString getData() = 0;
1948 /**
1949 *
1950 */
1951 virtual void setData(const DOMString& val) throw(DOMException) = 0;
1953 //##################
1954 //# Non-API methods
1955 //##################
1958 /**
1959 *
1960 */
1961 virtual ~ProcessingInstruction() {}
1963 };
1969 /*#########################################################################
1970 ## DocumentFragment
1971 #########################################################################*/
1972 /**
1973 *
1974 */
1975 class DocumentFragment : virtual public Node
1976 {
1977 public:
1979 //##################
1980 //# Non-API methods
1981 //##################
1984 /**
1985 *
1986 */
1987 virtual ~DocumentFragment() {}
1988 };
1995 /*#########################################################################
1996 ## Document
1997 #########################################################################*/
1999 /**
2000 *
2001 */
2002 class Document : virtual public Node
2003 {
2004 public:
2006 /**
2007 *
2008 */
2009 virtual DocumentType *getDoctype() = 0;
2011 /**
2012 *
2013 */
2014 virtual DOMImplementation *getImplementation() = 0;
2016 /**
2017 *
2018 */
2019 virtual Element *getDocumentElement() = 0;
2021 /**
2022 *
2023 */
2024 virtual Element *createElement(const DOMString& tagName)
2025 throw(DOMException) = 0;
2027 /**
2028 *
2029 */
2030 virtual DocumentFragment *createDocumentFragment() = 0;
2032 /**
2033 *
2034 */
2035 virtual Text *createTextNode(const DOMString& data) = 0;
2037 /**
2038 *
2039 */
2040 virtual Comment *createComment(const DOMString& data) = 0;
2042 /**
2043 *
2044 */
2045 virtual CDATASection *createCDATASection(const DOMString& data)
2046 throw(DOMException) = 0;
2048 /**
2049 *
2050 */
2051 virtual ProcessingInstruction *createProcessingInstruction(const DOMString& target,
2052 const DOMString& data)
2053 throw(DOMException) = 0;
2055 /**
2056 *
2057 */
2058 virtual Attr *createAttribute(const DOMString& name)
2059 throw(DOMException) = 0;
2061 /**
2062 *
2063 */
2064 virtual EntityReference *createEntityReference(const DOMString& name)
2065 throw(DOMException) = 0;
2067 /**
2068 *
2069 */
2070 virtual NodeList getElementsByTagName(const DOMString& tagname) = 0;
2073 /**
2074 *
2075 */
2076 virtual Node *importNode(const Node *importedNode,
2077 bool deep)
2078 throw(DOMException) = 0;
2080 /**
2081 *
2082 */
2083 virtual Element *createElementNS(const DOMString& namespaceURI,
2084 const DOMString& qualifiedName)
2085 throw(DOMException) = 0;
2087 /**
2088 *
2089 */
2090 virtual Attr *createAttributeNS(const DOMString& namespaceURI,
2091 const DOMString& qualifiedName)
2092 throw(DOMException) = 0;
2094 /**
2095 *
2096 */
2097 virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI,
2098 const DOMString& localName) = 0;
2100 /**
2101 *
2102 */
2103 virtual Element *getElementById(const DOMString& elementId) = 0;
2106 /**
2107 *
2108 */
2109 virtual DOMString getInputEncoding() = 0;
2112 /**
2113 *
2114 */
2115 virtual DOMString getXmlEncoding() = 0;
2117 /**
2118 *
2119 */
2120 virtual bool getXmlStandalone() = 0;
2122 /**
2123 *
2124 */
2125 virtual void setXmlStandalone(bool val) throw (DOMException) = 0;
2127 /**
2128 *
2129 */
2130 virtual DOMString getXmlVersion() = 0;
2132 /**
2133 *
2134 */
2135 virtual void setXmlVersion(const DOMString &version) throw (DOMException) = 0;
2137 /**
2138 *
2139 */
2140 virtual bool getStrictErrorChecking() = 0;
2142 /**
2143 *
2144 */
2145 virtual void setStrictErrorChecking(bool val) = 0;
2148 /**
2149 *
2150 */
2151 virtual DOMString getDocumentURI() = 0;
2153 /**
2154 *
2155 */
2156 virtual void setDocumentURI(const DOMString &uri) = 0;
2158 /**
2159 *
2160 */
2161 virtual Node *adoptNode(const Node *source) throw (DOMException) = 0;
2163 /**
2164 *
2165 */
2166 virtual DOMConfiguration *getDomConfig() = 0;
2168 /**
2169 *
2170 */
2171 virtual void normalizeDocument() = 0;
2173 /**
2174 *
2175 */
2176 virtual Node *renameNode(const Node *n,
2177 const DOMString &namespaceURI,
2178 const DOMString &qualifiedName)
2179 throw (DOMException) = 0;
2182 //##################
2183 //# Non-API methods
2184 //##################
2186 /**
2187 *
2188 */
2189 virtual ~Document() {}
2191 };
2203 } //namespace dom
2204 } //namespace w3c
2205 } //namespace org
2208 #endif // __DOM_H__
2211 /*#########################################################################
2212 ## E N D O F F I L E
2213 #########################################################################*/