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 * More thorough explanations of the various classes and their algorithms
13 * can be found there.
14 *
15 *
16 * Authors:
17 * Bob Jamison
18 *
19 * Copyright (C) 2006-2008 Bob Jamison
20 *
21 * This library is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU Lesser General Public
23 * License as published by the Free Software Foundation; either
24 * version 2.1 of the License, or (at your option) any later version.
25 *
26 * This library is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 * Lesser General Public License for more details.
30 *
31 * You should have received a copy of the GNU Lesser General Public
32 * License along with this library; if not, write to the Free Software
33 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34 */
36 #include <vector>
38 /**
39 * What type of string do we want? Pick one of the following
40 * Then below, select one of the corresponding typedefs?
41 */
43 #include <glibmm.h>
44 //#include <string>
46 //# Unfortunate hack for a name collision
47 #ifdef SEVERITY_ERROR
48 #undef SEVERITY_ERROR
49 #endif
51 #define XMLNSNAME "http://www.w3.org/2000/xmlns/"
53 namespace org
54 {
55 namespace w3c
56 {
57 namespace dom
58 {
61 /**
62 * This is the org::w3c::dom::DOMString definition.
63 * Which type do we want?
64 */
65 typedef Glib::ustring DOMString;
66 typedef gunichar XMLCh;
68 //typedef std::string DOMString;
69 //typedef unsigned short XMLCh;
72 /**
73 * At least 64 bit time stamp value.
74 */
75 typedef unsigned long long DOMTimeStamp;
77 /**
78 * This is used for storing refs to user-supplied data.
79 */
80 typedef void DOMUserData;
83 /*#########################################################################
84 ## NodePtr
85 #########################################################################*/
87 /**
88 * A simple Smart Pointer class that handles Nodes and all of its
89 * descendants. This is very similar to shared_ptr, but it is customized
90 * to handle our needs.
91 */
92 template<class T> class Ptr
93 {
94 public:
96 /**
97 * Simple constructor
98 */
99 Ptr()
100 { _ref = 0; }
102 /**
103 * Constructor upon a reference
104 */
105 template<class Y> Ptr(const Ptr<Y> &other)
106 {
107 _ref = other._ref;
108 incrementRefCount(_ref);
109 }
111 /**
112 * Constructor upon a reference
113 */
114 Ptr(T * refArg, bool addRef = true)
115 {
116 _ref = refArg;
117 if(addRef)
118 incrementRefCount(_ref);
119 }
122 /**
123 * Copy constructor
124 */
125 Ptr(const Ptr &other)
126 {
127 _ref = other._ref;
128 incrementRefCount(_ref);
129 }
131 /**
132 * Destructor
133 */
134 virtual ~Ptr()
135 {
136 decrementRefCount(_ref);
137 }
140 /**
141 * Assignment operator
142 */
143 template<class Y> Ptr &operator=(const Ptr<Y> &other)
144 {
145 decrementRefCount(_ref);
146 _ref = other._ref;
147 incrementRefCount(_ref);
148 return *this;
149 }
151 /**
152 * Assignment operator
153 */
154 Ptr &operator=(const Ptr &other)
155 {
156 decrementRefCount(_ref);
157 _ref = other._ref;
158 incrementRefCount(_ref);
159 return *this;
160 }
162 /**
163 * Assignment operator
164 */
165 template<class Y> Ptr &operator=(Y * ref)
166 {
167 decrementRefCount(_ref);
168 _ref = ref;
169 incrementRefCount(_ref);
170 return *this;
171 }
173 /**
174 * Assignment operator
175 */
176 template<class Y> Ptr &operator=(const Y * ref)
177 {
178 decrementRefCount(_ref);
179 _ref = (Y *) ref;
180 incrementRefCount(_ref);
181 return *this;
182 }
184 /**
185 * Return the reference
186 */
187 T * get() const
188 {
189 return _ref;
190 }
192 /**
193 * Dereference operator
194 */
195 T &operator*() const
196 {
197 return *_ref;
198 }
200 /**
201 * Point-to operator
202 */
203 T *operator->() const
204 {
205 return _ref;
206 }
208 /**
209 * NOT bool operator. How to check if we are null without a comparison
210 */
211 bool operator! () const
212 {
213 return (_ref == 0);
214 }
216 /**
217 * Swap what I reference with the other guy
218 */
219 void swap(Ptr &other)
220 {
221 T *tmp = _ref;
222 _ref = other._ref;
223 other._ref = tmp;
224 }
226 //The referenced item
227 T *_ref;
228 };
231 /**
232 * Global definitions. Many of these are used to mimic behaviour of
233 * a real pointer
234 */
236 /**
237 * Equality
238 */
239 template<class T, class U> inline bool
240 operator==(const Ptr<T> &a, const Ptr<U> &b)
241 {
242 return a.get() == b.get();
243 }
245 /**
246 * Inequality
247 */
248 template<class T, class U> inline bool
249 operator!=(const Ptr<T> &a, const Ptr<U> &b)
250 {
251 return a.get() != b.get();
252 }
254 /**
255 * Equality
256 */
257 template<class T> inline bool
258 operator==(const Ptr<T> &a, T * b)
259 {
260 return a.get() == b;
261 }
263 /**
264 * Inequality
265 */
266 template<class T> inline bool
267 operator!=(const Ptr<T> &a, T * b)
268 {
269 return a.get() != b;
270 }
272 /**
273 * Equality
274 */
275 template<class T> inline bool
276 operator==(T * a, const Ptr<T> &b)
277 {
278 return a == b.get();
279 }
281 /**
282 * Inequality
283 */
284 template<class T> inline bool
285 operator!=(T * a, const Ptr<T> &b)
286 {
287 return a != b.get();
288 }
291 /**
292 * Less than
293 */
294 template<class T> inline bool
295 operator<(const Ptr<T> &a, const Ptr<T> &b)
296 {
297 return std::less<T *>()(a.get(), b.get());
298 }
300 /**
301 * Swap
302 */
303 template<class T> void
304 swap(Ptr<T> &a, Ptr<T> &b)
305 {
306 a.swap(b);
307 }
310 /**
311 * Get the pointer globally, for <algo>
312 */
313 template<class T> T *
314 get_pointer(const Ptr<T> &p)
315 {
316 return p.get();
317 }
319 /**
320 * Static cast
321 */
322 template<class T, class U> Ptr<T>
323 static_pointer_cast(const Ptr<U> &p)
324 {
325 return static_cast<T *>(p.get());
326 }
328 /**
329 * Const cast
330 */
331 template<class T, class U> Ptr<T>
332 const_pointer_cast(const Ptr<U> &p)
333 {
334 return const_cast<T *>(p.get());
335 }
337 /**
338 * Dynamic cast
339 */
340 template<class T, class U> Ptr<T>
341 dynamic_pointer_cast(const Ptr<U> &p)
342 {
343 return dynamic_cast<T *>(p.get());
344 }
347 /**
348 * This is used for opaque references to arbitrary objects from
349 * the DOM tree.
350 */
351 typedef void DOMObject;
354 /**
355 * Forward references. These are needed because of extensive
356 * inter-referencing within the DOM tree.
357 */
358 class NodeList;
359 class NamedNodeMap;
360 class DOMException;
361 class DOMStringList;
362 class NameList;
363 class DOMImplementationList;
364 class DOMImplementationSource;
365 class DOMImplementation;
366 class TypeInfo;
367 class UserDataHandler;
368 class DOMError;
369 class DOMErrorHandler;
370 class DOMLocator;
371 class DOMConfiguration;
373 /**
374 * Smart pointer definitions. Most methods that return references to
375 * Nodes of various types, will return one of these smart pointers instead,
376 * to allow refcounting and GC.
377 */
378 class Node;
379 typedef Ptr<Node> NodePtr;
380 class CharacterData;
381 typedef Ptr<CharacterData> CharacterDataPtr;
382 class Attr;
383 typedef Ptr<Attr> AttrPtr;
384 class Element;
385 typedef Ptr<Element> ElementPtr;
386 class Text;
387 typedef Ptr<Text> TextPtr;
388 class Comment;
389 typedef Ptr<Comment> CommentPtr;
390 class DocumentType;
391 typedef Ptr<DocumentType> DocumentTypePtr;
392 class CDATASection;
393 typedef Ptr<CDATASection> CDATASectionPtr;
394 class Notation;
395 typedef Ptr<Notation> NotationPtr;
396 class Entity;
397 typedef Ptr<Entity> EntityPtr;
398 class EntityReference;
399 typedef Ptr<EntityReference> EntityReferencePtr;
400 class ProcessingInstruction;
401 typedef Ptr<ProcessingInstruction> ProcessingInstructionPtr;
402 class DocumentFragment;
403 typedef Ptr<DocumentFragment> DocumentFragmentPtr;
404 class Document;
405 typedef Ptr<Document> DocumentPtr;
410 /**
411 * NOTE: We were originally intending to split ALL specifications into
412 * interface and implementation. After consideration, though, it behooves
413 * us to simplify things by implementing the base exception and
414 * container classes directly:
415 *
416 * DOMException
417 * DOMStringList
418 * NameList
419 * DOMImplementationList
420 * DOMImplementationSource
421 * DOMImplementation
422 * NodeList
423 * NamedNodeMap
424 */
427 /*#########################################################################
428 ## DOMException
429 #########################################################################*/
431 /**
432 * An Exception class. Not an interface, since this is something that
433 * all implementations must support.
434 */
435 class DOMException
436 {
438 public:
440 /**
441 * ExceptionCode
442 */
443 typedef enum
444 {
445 INDEX_SIZE_ERR = 1,
446 DOMSTRING_SIZE_ERR = 2,
447 HIERARCHY_REQUEST_ERR = 3,
448 WRONG_DOCUMENT_ERR = 4,
449 INVALID_CHARACTER_ERR = 5,
450 NO_DATA_ALLOWED_ERR = 6,
451 NO_MODIFICATION_ALLOWED_ERR = 7,
452 NOT_FOUND_ERR = 8,
453 NOT_SUPPORTED_ERR = 9,
454 INUSE_ATTRIBUTE_ERR = 10,
455 INVALID_STATE_ERR = 11,
456 SYNTAX_ERR = 12,
457 INVALID_MODIFICATION_ERR = 13,
458 NAMESPACE_ERR = 14,
459 INVALID_ACCESS_ERR = 15,
460 VALIDATION_ERR = 16,
461 TYPE_MISMATCH_ERR = 17
462 } ExceptionCode;
466 DOMException(const DOMString &reasonMsg)
467 { msg = reasonMsg; }
469 DOMException(short theCode)
470 {
471 code = theCode;
472 }
474 virtual ~DOMException() throw()
475 {}
477 /**
478 * What type of exception? One of the ExceptionCodes above.
479 */
480 unsigned short code;
482 /**
483 * Some text describing the context that generated this exception.
484 */
485 DOMString msg;
487 /**
488 * Get a string, translated from the code.
489 * Like std::exception. Not in spec.
490 */
491 const char *what()
492 { return (const char *)msg.c_str(); }
496 };
503 /*#########################################################################
504 ## DOMStringList
505 #########################################################################*/
507 /**
508 * This holds a list of DOMStrings. This is likely the response to a query,
509 * or the value of an attribute.
510 */
511 class DOMStringList
512 {
513 public:
515 /**
516 * Get the nth string of the list
517 */
518 virtual DOMString item(unsigned long index)
519 {
520 if (index>=strings.size())
521 return "";
522 return strings[index];
523 }
525 /**
526 * How many strings in this list?
527 */
528 virtual unsigned long getLength()
529 {
530 return (unsigned long) strings.size();
531 }
533 /**
534 * Is the argument string present in this list? Lexically, not identically.
535 */
536 virtual bool contains(const DOMString &str)
537 {
538 for (unsigned int i=0; i<strings.size() ; i++)
539 {
540 if (strings[i] == str)
541 return true;
542 }
543 return false;
544 }
547 //##################
548 //# Non-API methods
549 //##################
551 /**
552 *
553 */
554 DOMStringList() {}
557 /**
558 *
559 */
560 DOMStringList(const DOMStringList &other)
561 {
562 strings = other.strings;
563 }
565 /**
566 *
567 */
568 DOMStringList &operator=(const DOMStringList &other)
569 {
570 strings = other.strings;
571 return *this;
572 }
574 /**
575 *
576 */
577 virtual ~DOMStringList() {}
580 protected:
582 /**
583 *
584 */
585 virtual void add(const DOMString &str)
586 {
587 strings.push_back(str);
588 }
590 std::vector<DOMString>strings;
592 };
596 /*#########################################################################
597 ## NameList
598 #########################################################################*/
601 /**
602 * Constains a list of namespaced names.
603 */
604 class NameList
605 {
606 private:
608 class NamePair
609 {
610 public:
611 NamePair(const DOMString &theNamespaceURI, const DOMString &theName)
612 {
613 namespaceURI = theNamespaceURI;
614 name = theName;
615 }
616 NamePair(const NamePair &other)
617 {
618 namespaceURI = other.namespaceURI;
619 name = other.name;
620 }
621 NamePair &operator=(const NamePair &other)
622 {
623 namespaceURI = other.namespaceURI;
624 name = other.name;
625 return *this;
626 }
627 virtual ~NamePair() {}
629 DOMString namespaceURI;
630 DOMString name;
631 };
633 public:
635 /**
636 * Returns a name at the given index. If out of range, return -1.
637 */
638 virtual DOMString getName(unsigned long index)
639 {
640 if (index>=namePairs.size())
641 return "";
642 return namePairs[index].name;
643 }
645 /**
646 * Returns a namespace at the given index. If out of range, return -1.
647 */
648 virtual DOMString getNamespaceURI(unsigned long index)
649 {
650 if (index>=namePairs.size())
651 return "";
652 return namePairs[index].namespaceURI;
653 }
655 /**
656 * Return the number of entries in this list.
657 */
658 virtual unsigned long getLength()
659 {
660 return (unsigned long)namePairs.size();
661 }
663 /**
664 * Return whether the name argument is present in the list.
665 * This is done lexically, not identically.
666 */
667 virtual bool contains(const DOMString &name)
668 {
669 for (unsigned int i=0; i<namePairs.size() ; i++)
670 {
671 if (namePairs[i].name == name )
672 return true;
673 }
674 return false;
675 }
677 /**
678 * Return whether the namespaced name argument is present in the list.
679 * This is done lexically, not identically.
680 */
681 virtual bool containsNS(const DOMString namespaceURI,const DOMString &name)
682 {
683 for (unsigned int i=0; i<namePairs.size() ; i++)
684 {
685 if (namePairs[i].namespaceURI == namespaceURI ||
686 namePairs[i].name == name )
687 return true;
688 }
689 return false;
690 }
693 //##################
694 //# Non-API methods
695 //##################
697 /**
698 *
699 */
700 NameList() {}
702 /**
703 *
704 */
705 NameList(const NameList &other)
706 {
707 namePairs = other.namePairs;
708 }
710 /**
711 *
712 */
713 NameList &operator=(const NameList &other)
714 {
715 namePairs = other.namePairs;
716 return *this;
717 }
719 /**
720 *
721 */
722 virtual ~NameList() {}
725 protected:
727 std::vector<NamePair> namePairs;
729 };
731 /*#########################################################################
732 ## DOMImplementationList
733 #########################################################################*/
735 /**
736 * Contains a list of DOMImplementations, with accessors.
737 */
738 class DOMImplementationList
739 {
740 public:
742 /**
743 * Return a DOMImplementation at the given index. If
744 * out of range, return NULL.
745 */
746 virtual DOMImplementation *item(unsigned long index)
747 {
748 if (index >implementations.size())
749 return NULL;
750 return implementations[index];
751 }
753 /**
754 * Return the number of DOMImplementations in this list.
755 */
756 virtual unsigned long getLength()
757 {
758 return (unsigned long) implementations.size();
759 }
762 //##################
763 //# Non-API methods
764 //##################
766 /**
767 *
768 */
769 DOMImplementationList() {}
772 /**
773 *
774 */
775 DOMImplementationList(const DOMImplementationList &other)
776 {
777 implementations = other.implementations;
778 }
780 /**
781 *
782 */
783 DOMImplementationList &operator=(const DOMImplementationList &other)
784 {
785 implementations = other.implementations;
786 return *this;
787 }
789 /**
790 *
791 */
792 virtual ~DOMImplementationList() {}
794 protected:
796 std::vector<DOMImplementation *>implementations;
798 };
801 /*#########################################################################
802 ## DOMImplementationSource
803 #########################################################################*/
805 /**
806 * This is usually the first item to be called when creating a Document.
807 * You will either find one DOMImplementation with a given set of features,
808 * or return a list that match. Using "" will get any implementation
809 * available.
810 */
811 class DOMImplementationSource
812 {
813 public:
815 /**
816 * Return the first DOMImplementation with the given set of features.
817 * Use "" to fetch any implementation.
818 */
819 virtual DOMImplementation *getDOMImplementation(const DOMString &features) = 0;
821 /**
822 * Return a list of DOMImplementations with the given set of features.
823 * Use "" to fetch any implementation.
824 */
825 virtual DOMImplementationList getDOMImplementationList(const DOMString &features) = 0;
827 //##################
828 //# Non-API methods
829 //##################
831 /**
832 *
833 */
834 virtual ~DOMImplementationSource() {}
836 };
842 /*#########################################################################
843 ## DOMImplementation
844 #########################################################################*/
846 /**
847 * This is the class that actually creates a Document.
848 */
849 class DOMImplementation
850 {
851 public:
853 /**
854 * Determine if this implementation has the given feature and version.
855 */
856 virtual bool hasFeature(const DOMString& feature, const DOMString& version) = 0;
859 /**
860 * Create a document type to be used in creating documents.
861 */
862 virtual DocumentTypePtr createDocumentType(
863 const DOMString& qualifiedName,
864 const DOMString& publicId,
865 const DOMString& systemId)
866 throw(DOMException) = 0;
868 /**
869 * Create a DOM document.
870 */
871 virtual DocumentPtr createDocument(const DOMString& namespaceURI,
872 const DOMString& qualifiedName,
873 DocumentTypePtr doctype)
874 throw(DOMException) = 0;
875 /**
876 * Return the thing which is the feature of this implementation. Since
877 * this is a "one size fits all" call, you will need to typecast the
878 * result to the expected type.
879 */
880 virtual DOMObject *getFeature(const DOMString& feature,
881 const DOMString& version) = 0;
884 //##################
885 //# Non-API methods
886 //##################
888 /**
889 *
890 */
891 virtual ~DOMImplementation() {}
893 };
899 /*#########################################################################
900 ## Node
901 #########################################################################*/
903 /**
904 * The basic Node class, which is the root of most other
905 * classes in DOM.
906 */
907 class Node
908 {
909 public:
911 /**
912 * Which of the DOM Core node types is this node?
913 */
914 typedef enum
915 {
916 ELEMENT_NODE = 1,
917 ATTRIBUTE_NODE = 2,
918 TEXT_NODE = 3,
919 CDATA_SECTION_NODE = 4,
920 ENTITY_REFERENCE_NODE = 5,
921 ENTITY_NODE = 6,
922 PROCESSING_INSTRUCTION_NODE = 7,
923 COMMENT_NODE = 8,
924 DOCUMENT_NODE = 9,
925 DOCUMENT_TYPE_NODE = 10,
926 DOCUMENT_FRAGMENT_NODE = 11,
927 NOTATION_NODE = 12
928 } NodeType;
930 /**
931 * Return the name of this node.
932 */
933 virtual DOMString getNodeName() = 0;
935 /**
936 * Return the value of this node. The interpretation of the
937 * value is type-specific.
938 */
939 virtual DOMString getNodeValue() throw (DOMException) = 0;
941 /**
942 * Set the value of this node. The interpretation of the
943 * value is type-specific.
944 */
945 virtual void setNodeValue(const DOMString& val) throw (DOMException) = 0;
947 /**
948 * Return the type of this Node. One of the NodeType values above.
949 */
950 virtual unsigned short getNodeType() = 0;
952 /**
953 * Return the parent which references this node as a child in the DOM
954 * tree. Return NULL if there is none.
955 */
956 virtual NodePtr getParentNode() = 0;
958 /**
959 * Return a list of the children of this Node.
960 * NOTE: the spec expects this to be a "live" list that always
961 * reflects an accurate list of what the Node current possesses, not
962 * a snapshot. How do we do this?
963 */
964 virtual NodeList getChildNodes() = 0;
966 /**
967 *
968 */
969 virtual NodePtr getFirstChild() = 0;
971 /**
972 *
973 */
974 virtual NodePtr getLastChild() = 0;
976 /**
977 *
978 */
979 virtual NodePtr getPreviousSibling() = 0;
981 /**
982 *
983 */
984 virtual NodePtr getNextSibling() = 0;
986 /**
987 *
988 */
989 virtual NamedNodeMap &getAttributes() = 0;
992 /**
993 *
994 */
995 virtual DocumentPtr getOwnerDocument() = 0;
997 /**
998 *
999 */
1000 virtual NodePtr insertBefore(const NodePtr newChild,
1001 const NodePtr refChild)
1002 throw(DOMException) = 0;
1004 /**
1005 *
1006 */
1007 virtual NodePtr replaceChild(const NodePtr newChild,
1008 const NodePtr oldChild)
1009 throw(DOMException) = 0;
1011 /**
1012 *
1013 */
1014 virtual NodePtr removeChild(const NodePtr oldChild)
1015 throw(DOMException) = 0;
1017 /**
1018 *
1019 */
1020 virtual NodePtr appendChild(const NodePtr newChild)
1021 throw(DOMException) = 0;
1023 /**
1024 *
1025 */
1026 virtual bool hasChildNodes() = 0;
1028 /**
1029 *
1030 */
1031 virtual NodePtr cloneNode(bool deep) = 0;
1033 /**
1034 *
1035 */
1036 virtual void normalize() = 0;
1038 /**
1039 *
1040 */
1041 virtual bool isSupported(const DOMString& feature,
1042 const DOMString& version) = 0;
1044 /**
1045 *
1046 */
1047 virtual DOMString getNamespaceURI() = 0;
1049 /**
1050 *
1051 */
1052 virtual DOMString getPrefix() = 0;
1054 /**
1055 *
1056 */
1057 virtual void setPrefix(const DOMString& val) throw(DOMException) = 0;
1059 /**
1060 *
1061 */
1062 virtual DOMString getLocalName() = 0;
1064 /**
1065 *
1066 */
1067 virtual bool hasAttributes() = 0;
1069 /**
1070 *
1071 */
1072 virtual DOMString getBaseURI() = 0;
1074 typedef enum
1075 {
1076 DOCUMENT_POSITION_DISCONNECTED = 0x01,
1077 DOCUMENT_POSITION_PRECEDING = 0x02,
1078 DOCUMENT_POSITION_FOLLOWING = 0x04,
1079 DOCUMENT_POSITION_CONTAINS = 0x08,
1080 DOCUMENT_POSITION_CONTAINED_BY = 0x10,
1081 DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20
1082 } DocumentPosition;
1085 /**
1086 *
1087 */
1088 virtual unsigned short compareDocumentPosition(
1089 const NodePtr other) = 0;
1091 /**
1092 *
1093 */
1094 virtual DOMString getTextContent() throw(DOMException) = 0;
1097 /**
1098 *
1099 */
1100 virtual void setTextContent(const DOMString &val) throw(DOMException) = 0;
1103 /**
1104 *
1105 */
1106 virtual DOMString lookupPrefix(const DOMString &namespaceURI) =0;
1109 /**
1110 *
1111 */
1112 virtual bool isDefaultNamespace(const DOMString &namespaceURI) =0;
1115 /**
1116 *
1117 */
1118 virtual DOMString lookupNamespaceURI(const DOMString &prefix) =0;
1121 /**
1122 *
1123 */
1124 virtual bool isEqualNode(const NodePtr node) =0;
1128 /**
1129 *
1130 */
1131 virtual DOMObject *getFeature(const DOMString &feature,
1132 const DOMString &version) =0;
1134 /**
1135 *
1136 */
1137 virtual DOMUserData *setUserData(const DOMString &key,
1138 const DOMUserData *data,
1139 const UserDataHandler *handler) =0;
1142 /**
1143 *
1144 */
1145 virtual DOMUserData *getUserData(const DOMString &namespaceURI) =0;
1147 //##################
1148 //# Non-API methods
1149 //##################
1151 /**
1152 *
1153 */
1154 Node() : _refCnt(0)
1155 {}
1157 /**
1158 *
1159 */
1160 virtual ~Node() {}
1162 protected:
1164 friend void incrementRefCount(Node *p);
1165 friend void decrementRefCount(Node *p);
1167 /**
1168 * For the Ptr smart pointer
1169 */
1170 int _refCnt;
1172 };
1177 /*#########################################################################
1178 ## NodeList
1179 #########################################################################*/
1181 /**
1182 * Contains a list of Nodes. This is the standard API container for Nodes,
1183 * and is used in lieu of other lists, arrays, etc, in order to provide
1184 * a consistent API and algorithm.
1185 */
1186 class NodeList
1187 {
1188 public:
1190 /**
1191 * Retrieve the Node at the given index. Return NULL
1192 * if out of range.
1193 */
1194 virtual NodePtr item(unsigned long index)
1195 {
1196 if (index>=nodes.size())
1197 return NULL;
1198 return nodes[index];
1199 }
1201 /**
1202 *
1203 */
1204 virtual unsigned long getLength()
1205 {
1206 return (unsigned long) nodes.size();
1207 }
1209 //##################
1210 //# Non-API methods
1211 //##################
1214 /**
1215 *
1216 */
1217 NodeList() {}
1219 /**
1220 *
1221 */
1222 NodeList(const NodeList &other)
1223 {
1224 nodes = other.nodes;
1225 }
1227 /**
1228 *
1229 */
1230 NodeList &operator=(const NodeList &other)
1231 {
1232 nodes = other.nodes;
1233 return *this;
1234 }
1236 /**
1237 *
1238 */
1239 virtual ~NodeList() {}
1241 /**
1242 *
1243 */
1244 virtual void clear()
1245 {
1246 nodes.clear();
1247 }
1249 protected:
1251 friend class NodeImpl;
1252 friend class ElementImpl;
1254 /*
1255 *
1256 */
1257 virtual void add(const NodePtr node)
1258 {
1259 nodes.push_back(node);
1260 }
1262 protected:
1264 std::vector<NodePtr> nodes;
1266 };
1271 /*#########################################################################
1272 ## NamedNodeMap
1273 #########################################################################*/
1275 class NamedNodeMapEntry
1276 {
1277 public:
1278 NamedNodeMapEntry(const DOMString &theNamespaceURI,
1279 const DOMString &theName,
1280 const NodePtr theNode)
1281 {
1282 namespaceURI = theNamespaceURI;
1283 name = theName;
1284 node = theNode;
1285 }
1286 NamedNodeMapEntry(const NamedNodeMapEntry &other)
1287 {
1288 assign(other);
1289 }
1290 NamedNodeMapEntry &operator=(const NamedNodeMapEntry &other)
1291 {
1292 assign(other);
1293 return *this;
1294 }
1295 virtual ~NamedNodeMapEntry()
1296 {
1297 }
1298 void assign(const NamedNodeMapEntry &other)
1299 {
1300 namespaceURI = other.namespaceURI;
1301 name = other.name;
1302 node = other.node;
1303 }
1304 DOMString namespaceURI;
1305 DOMString name;
1306 NodePtr node;
1307 };
1309 /**
1310 *
1311 */
1312 class NamedNodeMap
1313 {
1314 public:
1316 /**
1317 *
1318 */
1319 virtual NodePtr getNamedItem(const DOMString& name)
1320 {
1321 std::vector<NamedNodeMapEntry>::iterator iter;
1322 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1323 {
1324 if (iter->name == name)
1325 {
1326 NodePtr node = iter->node;
1327 return node;
1328 }
1329 }
1330 return NULL;
1331 }
1333 /**
1334 *
1335 */
1336 virtual NodePtr setNamedItem(NodePtr arg) throw(DOMException)
1337 {
1338 if (!arg)
1339 return NULL;
1340 DOMString namespaceURI = arg->getNamespaceURI();
1341 DOMString name = arg->getNodeName();
1342 std::vector<NamedNodeMapEntry>::iterator iter;
1343 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1344 {
1345 if (iter->name == name)
1346 {
1347 NodePtr node = iter->node;
1348 iter->node = arg;
1349 return node;
1350 }
1351 }
1352 NamedNodeMapEntry entry(namespaceURI, name, arg);
1353 entries.push_back(entry);
1354 return arg;
1355 }
1358 /**
1359 *
1360 */
1361 virtual NodePtr removeNamedItem(const DOMString& name) throw(DOMException)
1362 {
1363 std::vector<NamedNodeMapEntry>::iterator iter;
1364 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1365 {
1366 if (iter->name == name)
1367 {
1368 NodePtr node = iter->node;
1369 entries.erase(iter);
1370 return node;
1371 }
1372 }
1373 return NULL;
1374 }
1376 /**
1377 *
1378 */
1379 virtual NodePtr item(unsigned long index)
1380 {
1381 if (index>=entries.size())
1382 return NULL;
1383 return entries[index].node;
1384 }
1386 /**
1387 *
1388 */
1389 virtual unsigned long getLength()
1390 {
1391 return (unsigned long)entries.size();
1392 }
1394 /**
1395 *
1396 */
1397 virtual NodePtr getNamedItemNS(const DOMString& namespaceURI,
1398 const DOMString& localName)
1399 {
1400 std::vector<NamedNodeMapEntry>::iterator iter;
1401 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1402 {
1403 if (iter->namespaceURI == namespaceURI && iter->name == localName)
1404 {
1405 NodePtr node = iter->node;
1406 return node;
1407 }
1408 }
1409 return NULL;
1410 }
1412 /**
1413 *
1414 */
1415 virtual NodePtr setNamedItemNS(NodePtr arg) throw(DOMException)
1416 {
1417 if (!arg)
1418 return NULL;
1419 DOMString namespaceURI = arg->getNamespaceURI();
1420 DOMString name = arg->getNodeName();
1421 std::vector<NamedNodeMapEntry>::iterator iter;
1422 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1423 {
1424 if (iter->namespaceURI == namespaceURI && iter->name == name)
1425 {
1426 NodePtr node = iter->node;
1427 iter->node = arg;
1428 return node;
1429 }
1430 }
1431 NamedNodeMapEntry entry(namespaceURI, name, arg);
1432 entries.push_back(entry);
1433 return arg;
1434 }
1436 /**
1437 *
1438 */
1439 virtual NodePtr removeNamedItemNS(const DOMString& namespaceURI,
1440 const DOMString& localName)
1441 throw(DOMException)
1442 {
1443 std::vector<NamedNodeMapEntry>::iterator iter;
1444 for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1445 {
1446 if (iter->namespaceURI == namespaceURI && iter->name == localName)
1447 {
1448 NodePtr node = iter->node;
1449 entries.erase(iter);
1450 return node;
1451 }
1452 }
1453 return NULL;
1454 }
1456 //##################
1457 //# Non-API methods
1458 //##################
1460 /**
1461 *
1462 */
1463 NamedNodeMap() {}
1466 /**
1467 *
1468 */
1469 NamedNodeMap(const NamedNodeMap &other)
1470 {
1471 entries = other.entries;
1472 }
1474 /**
1475 *
1476 */
1477 NamedNodeMap &operator=(const NamedNodeMap &other)
1478 {
1479 entries = other.entries;
1480 return *this;
1481 }
1484 /**
1485 *
1486 */
1487 virtual ~NamedNodeMap() {}
1489 protected:
1491 std::vector<NamedNodeMapEntry> entries;
1493 };
1498 /*#########################################################################
1499 ## CharacterData
1500 #########################################################################*/
1502 /**
1503 *
1504 */
1505 class CharacterData : virtual public Node
1506 {
1507 public:
1509 /**
1510 *
1511 */
1512 virtual DOMString getData() throw(DOMException) = 0;
1514 /**
1515 *
1516 */
1517 virtual void setData(const DOMString& val) throw(DOMException) = 0;
1519 /**
1520 *
1521 */
1522 virtual unsigned long getLength() = 0;
1524 /**
1525 *
1526 */
1527 virtual DOMString substringData(unsigned long offset,
1528 unsigned long count)
1529 throw(DOMException) = 0;
1531 /**
1532 *
1533 */
1534 virtual void appendData(const DOMString& arg) throw(DOMException) = 0;
1536 /**
1537 *
1538 */
1539 virtual void insertData(unsigned long offset,
1540 const DOMString& arg)
1541 throw(DOMException) = 0;
1543 /**
1544 *
1545 */
1546 virtual void deleteData(unsigned long offset,
1547 unsigned long count)
1548 throw(DOMException) = 0;
1550 /**
1551 *
1552 */
1553 virtual void replaceData(unsigned long offset,
1554 unsigned long count,
1555 const DOMString& arg)
1556 throw(DOMException) = 0;
1559 //##################
1560 //# Non-API methods
1561 //##################
1564 /**
1565 *
1566 */
1567 virtual ~CharacterData() {}
1569 };
1572 typedef Ptr<CharacterData> CharacterDataPtr;
1577 /*#########################################################################
1578 ## Attr
1579 #########################################################################*/
1581 /**
1582 *
1583 */
1584 class Attr : virtual public Node
1585 {
1586 public:
1588 /**
1589 *
1590 */
1591 virtual DOMString getName() = 0;
1593 /**
1594 *
1595 */
1596 virtual bool getSpecified() = 0;
1598 /**
1599 *
1600 */
1601 virtual DOMString getValue() = 0;
1603 /**
1604 *
1605 */
1606 virtual void setValue(const DOMString& val) throw(DOMException) = 0;
1608 /**
1609 *
1610 */
1611 virtual ElementPtr getOwnerElement() = 0;
1614 /**
1615 *
1616 */
1617 virtual TypeInfo &getSchemaTypeInfo() = 0;
1620 /**
1621 *
1622 */
1623 virtual bool getIsId() = 0;
1625 //##################
1626 //# Non-API methods
1627 //##################
1630 /**
1631 *
1632 */
1633 virtual ~Attr() {}
1635 };
1641 /*#########################################################################
1642 ## Element
1643 #########################################################################*/
1645 /**
1646 *
1647 */
1648 class Element : virtual public Node
1649 {
1650 public:
1653 /**
1654 *
1655 */
1656 virtual DOMString getTagName() = 0;
1658 /**
1659 *
1660 */
1661 virtual DOMString getAttribute(const DOMString& name) = 0;
1663 /**
1664 *
1665 */
1666 virtual void setAttribute(const DOMString& name,
1667 const DOMString& value)
1668 throw(DOMException) = 0;
1670 /**
1671 *
1672 */
1673 virtual void removeAttribute(const DOMString& name)
1674 throw(DOMException) = 0;
1676 /**
1677 *
1678 */
1679 virtual AttrPtr getAttributeNode(const DOMString& name) = 0;
1681 /**
1682 *
1683 */
1684 virtual AttrPtr setAttributeNode(AttrPtr newAttr)
1685 throw(DOMException) = 0;
1687 /**
1688 *
1689 */
1690 virtual AttrPtr removeAttributeNode(AttrPtr oldAttr)
1691 throw(DOMException) = 0;
1693 /**
1694 *
1695 */
1696 virtual NodeList getElementsByTagName(const DOMString& name) = 0;
1698 /**
1699 *
1700 */
1701 virtual DOMString getAttributeNS(const DOMString& namespaceURI,
1702 const DOMString& localName) = 0;
1704 /**
1705 *
1706 */
1707 virtual void setAttributeNS(const DOMString& namespaceURI,
1708 const DOMString& qualifiedName,
1709 const DOMString& value)
1710 throw(DOMException) = 0;
1712 /**
1713 *
1714 */
1715 virtual void removeAttributeNS(const DOMString& namespaceURI,
1716 const DOMString& localName)
1717 throw(DOMException) = 0;
1719 /**
1720 *
1721 */
1722 virtual AttrPtr getAttributeNodeNS(const DOMString& namespaceURI,
1723 const DOMString& localName) = 0;
1725 /**
1726 *
1727 */
1728 virtual AttrPtr setAttributeNodeNS(AttrPtr newAttr)
1729 throw(DOMException) = 0;
1731 /**
1732 *
1733 */
1734 virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI,
1735 const DOMString& localName) = 0;
1737 /**
1738 *
1739 */
1740 virtual bool hasAttribute(const DOMString& name) = 0;
1742 /**
1743 *
1744 */
1745 virtual bool hasAttributeNS(const DOMString& namespaceURI,
1746 const DOMString& localName) = 0;
1748 /**
1749 *
1750 */
1751 virtual TypeInfo &getSchemaTypeInfo() = 0;
1754 /**
1755 *
1756 */
1757 virtual void setIdAttribute(const DOMString &name,
1758 bool isId) throw (DOMException) = 0;
1760 /**
1761 *
1762 */
1763 virtual void setIdAttributeNS(const DOMString &namespaceURI,
1764 const DOMString &localName,
1765 bool isId) throw (DOMException) = 0;
1767 /**
1768 *
1769 */
1770 virtual void setIdAttributeNode(const AttrPtr idAttr,
1771 bool isId) throw (DOMException) = 0;
1773 //##################
1774 //# Non-API methods
1775 //##################
1777 /**
1778 *
1779 */
1780 virtual ~Element() {}
1782 };
1788 /*#########################################################################
1789 ## Text
1790 #########################################################################*/
1792 /**
1793 *
1794 */
1795 class Text : virtual public CharacterData
1796 {
1797 public:
1799 /**
1800 *
1801 */
1802 virtual TextPtr splitText(unsigned long offset)
1803 throw(DOMException) = 0;
1805 /**
1806 *
1807 */
1808 virtual bool getIsElementContentWhitespace()= 0;
1810 /**
1811 *
1812 */
1813 virtual DOMString getWholeText() = 0;
1816 /**
1817 *
1818 */
1819 virtual TextPtr replaceWholeText(const DOMString &content)
1820 throw(DOMException) = 0;
1822 //##################
1823 //# Non-API methods
1824 //##################
1827 /**
1828 *
1829 */
1830 virtual ~Text() {}
1832 };
1836 /*#########################################################################
1837 ## Comment
1838 #########################################################################*/
1840 /**
1841 *
1842 */
1843 class Comment : virtual public CharacterData
1844 {
1845 public:
1847 //##################
1848 //# Non-API methods
1849 //##################
1852 /**
1853 *
1854 */
1855 virtual ~Comment() {}
1858 };
1862 /*#########################################################################
1863 ## TypeInfo
1864 #########################################################################*/
1866 /**
1867 *
1868 */
1869 class TypeInfo
1870 {
1871 public:
1873 /**
1874 *
1875 */
1876 virtual DOMString getTypeName()
1877 { return typeName; }
1879 /**
1880 *
1881 */
1882 virtual DOMString getTypeNamespace()
1883 { return typeNameSpace; }
1885 typedef enum
1886 {
1887 DERIVATION_RESTRICTION = 0x00000001,
1888 DERIVATION_EXTENSION = 0x00000002,
1889 DERIVATION_UNION = 0x00000004,
1890 DERIVATION_LIST = 0x00000008
1891 } DerivationMethod;
1894 /**
1895 *
1896 */
1897 virtual bool isDerivedFrom(const DOMString &typeNamespaceArg,
1898 const DOMString &typeNameArg,
1899 DerivationMethod derivationMethod)
1900 { (void)typeNamespaceArg; (void)typeNameArg; (void)derivationMethod; return false; }
1902 //##################
1903 //# Non-API methods
1904 //##################
1907 /**
1908 *
1909 */
1910 TypeInfo()
1911 {}
1913 /**
1914 *
1915 */
1916 TypeInfo(const TypeInfo &other)
1917 { assign(other); }
1919 /**
1920 *
1921 */
1922 TypeInfo &operator=(const TypeInfo &other)
1923 { assign(other); return *this; }
1925 /**
1926 *
1927 */
1928 virtual ~TypeInfo() {}
1930 private:
1932 void assign(const TypeInfo &other)
1933 {
1934 typeName = other.typeName;
1935 typeNameSpace = other.typeNameSpace;
1936 }
1938 DOMString typeName;
1939 DOMString typeNameSpace;
1940 };
1945 /*#########################################################################
1946 ## UserDataHandler
1947 #########################################################################*/
1949 /**
1950 *
1951 */
1952 class UserDataHandler
1953 {
1954 public:
1956 typedef enum
1957 {
1958 NODE_CLONED = 1,
1959 NODE_IMPORTED = 2,
1960 NODE_DELETED = 3,
1961 NODE_RENAMED = 4,
1962 NODE_ADOPTED = 5
1963 } OperationType;
1966 /**
1967 *
1968 */
1969 virtual void handle(unsigned short operation,
1970 const DOMString &key,
1971 const DOMUserData *data,
1972 const NodePtr src,
1973 const NodePtr dst) =0;
1975 //##################
1976 //# Non-API methods
1977 //##################
1980 /**
1981 *
1982 */
1983 virtual ~UserDataHandler() {}
1985 };
1988 /*#########################################################################
1989 ## DOMError
1990 #########################################################################*/
1992 /**
1993 *
1994 */
1995 class DOMError
1996 {
1997 public:
1999 typedef enum
2000 {
2001 SEVERITY_WARNING = 1,
2002 SEVERITY_ERROR = 2,
2003 SEVERITY_FATAL_ERROR = 3
2004 } ErrorSeverity;
2007 /**
2008 *
2009 */
2010 virtual unsigned short getSeverity() =0;
2012 /**
2013 *
2014 */
2015 virtual DOMString getMessage() =0;
2017 /**
2018 *
2019 */
2020 virtual DOMString getType() =0;
2022 /**
2023 *
2024 */
2025 virtual DOMObject *getRelatedException() =0;
2027 /**
2028 *
2029 */
2030 virtual DOMObject *getRelatedData() =0;
2032 /**
2033 *
2034 */
2035 virtual DOMLocator *getLocation() =0;
2038 //##################
2039 //# Non-API methods
2040 //##################
2043 /**
2044 *
2045 */
2046 virtual ~DOMError() {}
2048 };
2051 /*#########################################################################
2052 ## DOMErrorHandler
2053 #########################################################################*/
2055 /**
2056 *
2057 */
2058 class DOMErrorHandler
2059 {
2060 public:
2061 /**
2062 *
2063 */
2064 virtual bool handleError(const DOMError *error) =0;
2066 //##################
2067 //# Non-API methods
2068 //##################
2071 /**
2072 *
2073 */
2074 virtual ~DOMErrorHandler() {}
2076 };
2080 /*#########################################################################
2081 ## DOMLocator
2082 #########################################################################*/
2084 /**
2085 *
2086 */
2087 class DOMLocator
2088 {
2089 public:
2091 /**
2092 *
2093 */
2094 virtual long getLineNumber() =0;
2096 /**
2097 *
2098 */
2099 virtual long getColumnNumber() =0;
2101 /**
2102 *
2103 */
2104 virtual long getByteOffset() =0;
2106 /**
2107 *
2108 */
2109 virtual long getUtf16Offset() =0;
2112 /**
2113 *
2114 */
2115 virtual NodePtr getRelatedNode() =0;
2118 /**
2119 *
2120 */
2121 virtual DOMString getUri() =0;
2123 //##################
2124 //# Non-API methods
2125 //##################
2127 /**
2128 *
2129 */
2130 virtual ~DOMLocator() {}
2131 };
2134 /*#########################################################################
2135 ## DOMConfiguration
2136 #########################################################################*/
2138 /**
2139 *
2140 */
2141 class DOMConfiguration
2142 {
2143 public:
2145 /**
2146 *
2147 */
2148 virtual void setParameter(const DOMString &name,
2149 const DOMUserData *value)
2150 throw (DOMException) =0;
2152 /**
2153 *
2154 */
2155 virtual DOMUserData *getParameter(const DOMString &name)
2156 throw (DOMException) =0;
2158 /**
2159 *
2160 */
2161 virtual bool canSetParameter(const DOMString &name,
2162 const DOMUserData *data) =0;
2164 /**
2165 *
2166 */
2167 virtual DOMStringList *getParameterNames() =0;
2169 //##################
2170 //# Non-API methods
2171 //##################
2174 /**
2175 *
2176 */
2177 virtual ~DOMConfiguration() {}
2179 };
2186 /*#########################################################################
2187 ## CDATASection
2188 #########################################################################*/
2189 /**
2190 *
2191 */
2192 class CDATASection : virtual public Text
2193 {
2194 public:
2196 //##################
2197 //# Non-API methods
2198 //##################
2201 /**
2202 *
2203 */
2204 virtual ~CDATASection() {}
2206 };
2211 /*#########################################################################
2212 ## DocumentType
2213 #########################################################################*/
2215 /**
2216 *
2217 */
2218 class DocumentType : virtual public Node
2219 {
2220 public:
2222 /**
2223 *
2224 */
2225 virtual DOMString getName() = 0;
2227 /**
2228 *
2229 */
2230 virtual NamedNodeMap getEntities() = 0;
2232 /**
2233 *
2234 */
2235 virtual NamedNodeMap getNotations() = 0;
2237 /**
2238 *
2239 */
2240 virtual DOMString getPublicId() = 0;
2242 /**
2243 *
2244 */
2245 virtual DOMString getSystemId() = 0;
2247 /**
2248 *
2249 */
2250 virtual DOMString getInternalSubset() = 0;
2252 //##################
2253 //# Non-API methods
2254 //##################
2256 /**
2257 *
2258 */
2259 virtual ~DocumentType() {}
2261 };
2267 /*#########################################################################
2268 ## Notation
2269 #########################################################################*/
2271 /**
2272 *
2273 */
2274 class Notation : virtual public Node
2275 {
2276 public:
2278 /**
2279 *
2280 */
2281 virtual DOMString getPublicId() = 0;
2283 /**
2284 *
2285 */
2286 virtual DOMString getSystemId() = 0;
2288 //##################
2289 //# Non-API methods
2290 //##################
2293 /**
2294 *
2295 */
2296 virtual ~Notation() {}
2297 };
2304 /*#########################################################################
2305 ## Entity
2306 #########################################################################*/
2308 /**
2309 *
2310 */
2311 class Entity : virtual public Node
2312 {
2313 public:
2315 /**
2316 *
2317 */
2318 virtual DOMString getPublicId() = 0;
2320 /**
2321 *
2322 */
2323 virtual DOMString getSystemId() = 0;
2325 /**
2326 *
2327 */
2328 virtual DOMString getNotationName() = 0;
2330 /**
2331 *
2332 */
2333 virtual DOMString getInputEncoding() = 0;
2335 /**
2336 *
2337 */
2338 virtual DOMString getXmlEncoding() = 0;
2340 /**
2341 *
2342 */
2343 virtual DOMString getXmlVersion() = 0;
2345 //##################
2346 //# Non-API methods
2347 //##################
2350 /**
2351 *
2352 */
2353 virtual ~Entity() {}
2354 };
2360 /*#########################################################################
2361 ## EntityReference
2362 #########################################################################*/
2363 /**
2364 *
2365 */
2366 class EntityReference : virtual public Node
2367 {
2368 public:
2371 //##################
2372 //# Non-API methods
2373 //##################
2375 /**
2376 *
2377 */
2378 virtual ~EntityReference() {}
2379 };
2385 /*#########################################################################
2386 ## ProcessingInstruction
2387 #########################################################################*/
2389 /**
2390 *
2391 */
2392 class ProcessingInstruction : virtual public Node
2393 {
2394 public:
2396 /**
2397 *
2398 */
2399 virtual DOMString getTarget() = 0;
2401 /**
2402 *
2403 */
2404 virtual DOMString getData() = 0;
2406 /**
2407 *
2408 */
2409 virtual void setData(const DOMString& val) throw(DOMException) = 0;
2411 //##################
2412 //# Non-API methods
2413 //##################
2416 /**
2417 *
2418 */
2419 virtual ~ProcessingInstruction() {}
2421 };
2427 /*#########################################################################
2428 ## DocumentFragment
2429 #########################################################################*/
2430 /**
2431 *
2432 */
2433 class DocumentFragment : virtual public Node
2434 {
2435 public:
2437 //##################
2438 //# Non-API methods
2439 //##################
2442 /**
2443 *
2444 */
2445 virtual ~DocumentFragment() {}
2446 };
2453 /*#########################################################################
2454 ## Document
2455 #########################################################################*/
2457 /**
2458 *
2459 */
2460 class Document : virtual public Node
2461 {
2462 public:
2464 /**
2465 *
2466 */
2467 virtual DocumentTypePtr getDoctype() = 0;
2469 /**
2470 *
2471 */
2472 virtual DOMImplementation *getImplementation() = 0;
2474 /**
2475 *
2476 */
2477 virtual ElementPtr getDocumentElement() = 0;
2479 /**
2480 *
2481 */
2482 virtual ElementPtr createElement(const DOMString& tagName)
2483 throw(DOMException) = 0;
2485 /**
2486 *
2487 */
2488 virtual DocumentFragmentPtr createDocumentFragment() = 0;
2490 /**
2491 *
2492 */
2493 virtual TextPtr createTextNode(const DOMString& data) = 0;
2495 /**
2496 *
2497 */
2498 virtual CommentPtr createComment(const DOMString& data) = 0;
2500 /**
2501 *
2502 */
2503 virtual CDATASectionPtr createCDATASection(const DOMString& data)
2504 throw(DOMException) = 0;
2506 /**
2507 *
2508 */
2509 virtual ProcessingInstructionPtr
2510 createProcessingInstruction(const DOMString& target,
2511 const DOMString& data)
2512 throw(DOMException) = 0;
2514 /**
2515 *
2516 */
2517 virtual AttrPtr createAttribute(const DOMString& name)
2518 throw(DOMException) = 0;
2520 /**
2521 *
2522 */
2523 virtual EntityReferencePtr createEntityReference(const DOMString& name)
2524 throw(DOMException) = 0;
2526 /**
2527 *
2528 */
2529 virtual NodeList getElementsByTagName(const DOMString& tagname) = 0;
2532 /**
2533 *
2534 */
2535 virtual NodePtr importNode(const NodePtr importedNode,
2536 bool deep)
2537 throw(DOMException) = 0;
2539 /**
2540 *
2541 */
2542 virtual ElementPtr createElementNS(const DOMString& namespaceURI,
2543 const DOMString& qualifiedName)
2544 throw(DOMException) = 0;
2546 /**
2547 *
2548 */
2549 virtual AttrPtr createAttributeNS(const DOMString& namespaceURI,
2550 const DOMString& qualifiedName)
2551 throw(DOMException) = 0;
2553 /**
2554 *
2555 */
2556 virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI,
2557 const DOMString& localName) = 0;
2559 /**
2560 *
2561 */
2562 virtual ElementPtr getElementById(const DOMString& elementId) = 0;
2565 /**
2566 *
2567 */
2568 virtual DOMString getInputEncoding() = 0;
2571 /**
2572 *
2573 */
2574 virtual DOMString getXmlEncoding() = 0;
2576 /**
2577 *
2578 */
2579 virtual bool getXmlStandalone() = 0;
2581 /**
2582 *
2583 */
2584 virtual void setXmlStandalone(bool val) throw (DOMException) = 0;
2586 /**
2587 *
2588 */
2589 virtual DOMString getXmlVersion() = 0;
2591 /**
2592 *
2593 */
2594 virtual void setXmlVersion(const DOMString &version)
2595 throw (DOMException) = 0;
2597 /**
2598 *
2599 */
2600 virtual bool getStrictErrorChecking() = 0;
2602 /**
2603 *
2604 */
2605 virtual void setStrictErrorChecking(bool val) = 0;
2608 /**
2609 *
2610 */
2611 virtual DOMString getDocumentURI() = 0;
2613 /**
2614 *
2615 */
2616 virtual void setDocumentURI(const DOMString &uri) = 0;
2618 /**
2619 *
2620 */
2621 virtual NodePtr adoptNode(const NodePtr source) throw (DOMException) = 0;
2623 /**
2624 *
2625 */
2626 virtual DOMConfiguration *getDomConfig() = 0;
2628 /**
2629 *
2630 */
2631 virtual void normalizeDocument() = 0;
2633 /**
2634 *
2635 */
2636 virtual NodePtr renameNode(const NodePtr n,
2637 const DOMString &namespaceURI,
2638 const DOMString &qualifiedName)
2639 throw (DOMException) = 0;
2642 //##################
2643 //# Non-API methods
2644 //##################
2646 /**
2647 *
2648 */
2649 virtual ~Document() {}
2651 };
2660 } //namespace dom
2661 } //namespace w3c
2662 } //namespace org
2665 #endif // __DOM_H__
2668 /*#########################################################################
2669 ## E N D O F F I L E
2670 #########################################################################*/