Code

interim cleanup commit
[inkscape.git] / src / dom / dom.h
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
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
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
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     DOMStringList &operator=(const DOMStringList &other)
266         {
267         strings = other.strings;
268         return *this;
269         }
271     /**
272      *
273      */
274     virtual ~DOMStringList() {}
277 protected:
279     /**
280      *
281      */
282     virtual void add(const DOMString &str)
283         {
284         strings.push_back(str);
285         }
287     std::vector<DOMString>strings;
289 };
293 /*#########################################################################
294 ## NameList
295 #########################################################################*/
296 class NamePair
298 public:
299     NamePair(const DOMString &theNamespaceURI, const DOMString &theName)
300         {
301         namespaceURI = theNamespaceURI;
302         name         = theName;
303         }
304     NamePair(const NamePair &other)
305         {
306         namespaceURI = other.namespaceURI;
307         name         = other.name;
308         }
309     NamePair &operator=(const NamePair &other)
310         {
311         namespaceURI = other.namespaceURI;
312         name         = other.name;
313         return *this;
314         }
315     virtual ~NamePair() {}
317     DOMString namespaceURI;
318     DOMString name;
319 };
323 class NameList
325 public:
327     /**
328      *
329      */
330     virtual DOMString getName(unsigned long index)
331         {
332         if (index>=namePairs.size())
333             return "";
334         return namePairs[index].name;
335         }
337     /**
338      *
339      */
340     virtual DOMString getNamespaceURI(unsigned long index)
341         {
342         if (index>=namePairs.size())
343             return "";
344         return namePairs[index].namespaceURI;
345         }
347     /**
348      *
349      */
350     virtual unsigned long getLength()
351         {
352         return (unsigned long)namePairs.size();
353         }
355     /**
356      *
357      */
358     virtual bool contains(const DOMString &name)
359         {
360         for (unsigned int i=0; i<namePairs.size() ; i++)
361             {
362             if (namePairs[i].name == name )
363                 return true;
364             }
365         return false;
366         }
368     /**
369      *
370      */
371     virtual bool containsNS(const DOMString namespaceURI,const DOMString &name)
372         {
373         for (unsigned int i=0; i<namePairs.size() ; i++)
374             {
375             if (namePairs[i].namespaceURI == namespaceURI ||
376                 namePairs[i].name         == name           )
377                 return true;
378             }
379         return false;
380         }
383     //##################
384     //# Non-API methods
385     //##################
387     /**
388      *
389      */
390     NameList() {}
392     /**
393      *
394      */
395     NameList(const NameList &other)
396         {
397         namePairs = other.namePairs;
398         }
400     /**
401      *
402      */
403     NameList &operator=(const NameList &other)
404         {
405         namePairs = other.namePairs;
406         return *this;
407         }
409     /**
410      *
411      */
412     virtual ~NameList() {}
413 protected:
415     std::vector<NamePair> namePairs;
417 };
419 /*#########################################################################
420 ## DOMImplementationList
421 #########################################################################*/
423 class DOMImplementationList
425 public:
427     /**
428      *
429      */
430     virtual DOMImplementation *getDOMImplementation(unsigned long index)
431         {
432         if (index >implementations.size())
433             return NULL;
434         return implementations[index];
435         }
437     /**
438      *
439      */
440     virtual unsigned long getLength()
441         {
442         return (unsigned long) implementations.size();
443         }
448     //##################
449     //# Non-API methods
450     //##################
452     /**
453      *
454      */
455     DOMImplementationList() {}
458     /**
459      *
460      */
461     DOMImplementationList(const DOMImplementationList &other)
462         {
463         implementations = other.implementations;
464         }
466     /**
467      *
468      */
469     DOMImplementationList &operator=(const DOMImplementationList &other)
470         {
471         implementations = other.implementations;
472         return *this;
473         }
475     /**
476      *
477      */
478     virtual ~DOMImplementationList() {}
480 protected:
482     std::vector<DOMImplementation *>implementations;
484 };
487 /*#########################################################################
488 ## DOMImplementationSource
489 #########################################################################*/
491 class DOMImplementationSource
493 public:
495     /**
496      *
497      */
498     virtual DOMImplementation *getDOMImplementation(const DOMString &features) = 0;
500     /**
501      *
502      */
503     virtual DOMImplementationList getDOMImplementationList(const DOMString &features) = 0;
505     //##################
506     //# Non-API methods
507     //##################
509     /**
510      *
511      */
512     virtual ~DOMImplementationSource() {}
514 };
520 /*#########################################################################
521 ## DOMImplementation
522 #########################################################################*/
523 /**
524  *
525  */
526 class DOMImplementation
528 public:
529     /**
530      *
531      */
532     virtual bool hasFeature(const DOMString& feature, const DOMString& version) = 0;
535     /**
536      *
537      */
538     virtual DocumentType *createDocumentType(const DOMString& qualifiedName,
539                                      const DOMString& publicId,
540                                      const DOMString& systemId)
541                                      throw(DOMException) = 0;
543     /**
544      *
545      */
546     virtual Document *createDocument(const DOMString& namespaceURI,
547                              const DOMString& qualifiedName,
548                              DocumentType *doctype)
549                              throw(DOMException) = 0;
550     /**
551      *
552      */
553     virtual DOMObject *getFeature(const DOMString& feature,
554                              const DOMString& version) = 0;
557     //##################
558     //# Non-API methods
559     //##################
561     /**
562      *
563      */
564     virtual ~DOMImplementation() {}
566 };
571 /*#########################################################################
572 ## Node
573 #########################################################################*/
575 /**
576  *
577  */
578 class Node
580 public:
582     typedef enum
583         {
584         ELEMENT_NODE                   = 1,
585         ATTRIBUTE_NODE                 = 2,
586         TEXT_NODE                      = 3,
587         CDATA_SECTION_NODE             = 4,
588         ENTITY_REFERENCE_NODE          = 5,
589         ENTITY_NODE                    = 6,
590         PROCESSING_INSTRUCTION_NODE    = 7,
591         COMMENT_NODE                   = 8,
592         DOCUMENT_NODE                  = 9,
593         DOCUMENT_TYPE_NODE             = 10,
594         DOCUMENT_FRAGMENT_NODE         = 11,
595         NOTATION_NODE                  = 12
596         } NodeType;
598     /**
599      *
600      */
601     virtual DOMString getNodeName() = 0;
603     /**
604      *
605      */
606     virtual DOMString getNodeValue() throw (DOMException) = 0;
608     /**
609      *
610      */
611     virtual void setNodeValue(const DOMString& val) throw (DOMException) = 0;
613     /**
614      *
615      */
616     virtual unsigned short getNodeType() = 0;
618     /**
619      *
620      */
621     virtual Node *getParentNode() = 0;
623     /**
624      *
625      */
626     virtual NodeList getChildNodes() = 0;
628     /**
629      *
630      */
631     virtual Node *getFirstChild() = 0;
633     /**
634      *
635      */
636     virtual Node *getLastChild() = 0;
638     /**
639      *
640      */
641     virtual Node *getPreviousSibling() = 0;
643     /**
644      *
645      */
646     virtual Node *getNextSibling() = 0;
648     /**
649      *
650      */
651     virtual NamedNodeMap &getAttributes() = 0;
654     /**
655      *
656      */
657     virtual Document *getOwnerDocument() = 0;
659     /**
660      *
661      */
662     virtual Node *insertBefore(const Node *newChild,
663                        const Node *refChild)
664                        throw(DOMException) = 0;
666     /**
667      *
668      */
669     virtual Node *replaceChild(const Node *newChild,
670                        const Node *oldChild)
671                        throw(DOMException) = 0;
673     /**
674      *
675      */
676     virtual Node *removeChild(const Node *oldChild)
677                       throw(DOMException) = 0;
679     /**
680      *
681      */
682     virtual Node *appendChild(const Node *newChild)
683                       throw(DOMException) = 0;
685     /**
686      *
687      */
688     virtual bool hasChildNodes() = 0;
690     /**
691      *
692      */
693     virtual Node *cloneNode(bool deep) = 0;
695     /**
696      *
697      */
698     virtual void normalize() = 0;
700     /**
701      *
702      */
703     virtual bool isSupported(const DOMString& feature,
704                      const DOMString& version) = 0;
706     /**
707      *
708      */
709     virtual DOMString getNamespaceURI() = 0;
711     /**
712      *
713      */
714     virtual DOMString getPrefix() = 0;
716     /**
717      *
718      */
719     virtual void setPrefix(const DOMString& val) throw(DOMException) = 0;
721     /**
722      *
723      */
724     virtual DOMString getLocalName() = 0;
726     /**
727      *
728      */
729     virtual bool hasAttributes() = 0;
731     /**
732      *
733      */
734     virtual DOMString getBaseURI() = 0;
736     typedef enum
737         {
738         DOCUMENT_POSITION_DISCONNECTED            = 0x01,
739         DOCUMENT_POSITION_PRECEDING               = 0x02,
740         DOCUMENT_POSITION_FOLLOWING               = 0x04,
741         DOCUMENT_POSITION_CONTAINS                = 0x08,
742         DOCUMENT_POSITION_CONTAINED_BY            = 0x10,
743         DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20
744         } DocumentPosition;
747     /**
748      *
749      */
750     virtual unsigned short compareDocumentPosition(const Node *other) = 0;
752     /**
753      *
754      */
755     virtual DOMString getTextContext() throw(DOMException) = 0;
758     /**
759      *
760      */
761     virtual void setTextContext(const DOMString &val) throw(DOMException) = 0;
764     /**
765      *
766      */
767     virtual DOMString lookupPrefix(const DOMString &namespaceURI) =0;
770     /**
771      *
772      */
773     virtual bool isDefaultNamespace(const DOMString &namespaceURI) =0;
776     /**
777      *
778      */
779     virtual DOMString lookupNamespaceURI(const DOMString &prefix) =0;
782     /**
783      *
784      */
785     virtual bool isEqualNode(const Node *node) =0;
789     /**
790      *
791      */
792     virtual DOMObject *getFeature(const DOMString &feature,
793                                  const DOMString &version) =0;
795     /**
796      *
797      */
798     virtual DOMUserData *setUserData(const DOMString &key,
799                                      const DOMUserData *data,
800                                      const UserDataHandler *handler) =0;
803     /**
804      *
805      */
806     virtual DOMUserData *getUserData(const DOMString &namespaceURI) =0;
808     //##################
809     //# Non-API methods
810     //##################
813     /**
814      *
815      */
816     virtual ~Node() {}
821 };
825 /*#########################################################################
826 ## NodeList
827 #########################################################################*/
829 /**
830  *
831  */
832 class NodeList
834 public:
835     /**
836      *
837      */
838     virtual Node *item(unsigned long index)
839         {
840         if (index>=nodes.size())
841             return NULL;
842         return nodes[index];
843         }
845     /**
846      *
847      */
848     virtual unsigned long getLength()
849         {
850         return (unsigned long) nodes.size();
851         }
853     //##################
854     //# Non-API methods
855     //##################
858     /**
859      *
860      */
861     NodeList() {}
863     /**
864      *
865      */
866     NodeList(const NodeList &other)
867         {
868         nodes = other.nodes;
869         }
871     /**
872      *
873      */
874     NodeList &operator=(const NodeList &other)
875         {
876         nodes = other.nodes;
877         return *this;
878         }
880     /**
881      *
882      */
883     virtual ~NodeList() {}
885 protected:
887 friend class NodeImpl;
888 friend class ElementImpl;
890     /*
891      *
892      */
893     virtual void add(const Node *node)
894         {
895         nodes.push_back((Node *)node);
896         }
898 protected:
900     std::vector<Node *> nodes;
902 };
907 /*#########################################################################
908 ## NamedNodeMap
909 #########################################################################*/
911 class NamedNodeMapEntry
913 public:
914     NamedNodeMapEntry(const DOMString &theNamespaceURI,
915                       const DOMString &theName,
916                       const Node      *theNode)
917         {
918         namespaceURI = theNamespaceURI;
919         name         = theName;
920         node         = (Node *)theNode;
921         }
922     NamedNodeMapEntry(const NamedNodeMapEntry &other)
923         {
924         assign(other);
925         }
926     NamedNodeMapEntry &operator=(const NamedNodeMapEntry &other)
927         {
928         assign(other);
929         return *this;
930         }
931     virtual ~NamedNodeMapEntry()
932         {
933         }
934     void assign(const NamedNodeMapEntry &other)
935         {
936         namespaceURI = other.namespaceURI;
937         name         = other.name;
938         node         = other.node;
939         }
940     DOMString namespaceURI;
941     DOMString name;
942     Node      *node;
943 };
945 /**
946  *
947  */
948 class NamedNodeMap
950 public:
952     /**
953      *
954      */
955     virtual Node *getNamedItem(const DOMString& name)
956         {
957         std::vector<NamedNodeMapEntry>::iterator iter;
958         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
959             {
960             if (iter->name == name)
961                 {
962                 Node *node = iter->node;
963                 return node;
964                 }
965             }
966         return NULL;
967         }
969     /**
970      *
971      */
972     virtual Node *setNamedItem(Node *arg) throw(DOMException)
973         {
974         if (!arg)
975             return NULL;
976         DOMString namespaceURI = arg->getNamespaceURI();
977         DOMString name         = arg->getNodeName();
978         std::vector<NamedNodeMapEntry>::iterator iter;
979         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
980             {
981             if (iter->name == name)
982                 {
983                 Node *node = iter->node;
984                 iter->node = arg;
985                 return node;
986                 }
987             }
988         NamedNodeMapEntry entry(namespaceURI, name, arg);
989         entries.push_back(entry);
990         return arg;
991         }
994     /**
995      *
996      */
997     virtual Node *removeNamedItem(const DOMString& name) throw(DOMException)
998         {
999         std::vector<NamedNodeMapEntry>::iterator iter;
1000         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1001             {
1002             if (iter->name == name)
1003                 {
1004                 Node *node = iter->node;
1005                 entries.erase(iter);
1006                 return node;
1007                 }
1008             }
1009         return NULL;
1010         }
1012     /**
1013      *
1014      */
1015     virtual Node *item(unsigned long index)
1016         {
1017         if (index>=entries.size())
1018             return NULL;
1019         return entries[index].node;
1020         }
1022     /**
1023      *
1024      */
1025     virtual unsigned long getLength()
1026         {
1027         return (unsigned long)entries.size();
1028         }
1030     /**
1031      *
1032      */
1033     virtual Node *getNamedItemNS(const DOMString& namespaceURI,
1034                                  const DOMString& localName)
1035         {
1036         std::vector<NamedNodeMapEntry>::iterator iter;
1037         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1038             {
1039             if (iter->namespaceURI == namespaceURI && iter->name == localName)
1040                 {
1041                 Node *node = iter->node;
1042                 return node;
1043                 }
1044             }
1045         return NULL;
1046         }
1048     /**
1049      *
1050      */
1051     virtual Node *setNamedItemNS(Node *arg) throw(DOMException)
1052         {
1053         if (!arg)
1054             return NULL;
1055         DOMString namespaceURI = arg->getNamespaceURI();
1056         DOMString name         = arg->getNodeName();
1057         std::vector<NamedNodeMapEntry>::iterator iter;
1058         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1059             {
1060             if (iter->namespaceURI == namespaceURI && iter->name == name)
1061                 {
1062                 Node *node = iter->node;
1063                 iter->node = arg;
1064                 return node;
1065                 }
1066             }
1067         NamedNodeMapEntry entry(namespaceURI, name, arg);
1068         entries.push_back(entry);
1069         return arg;
1070         }
1072     /**
1073      *
1074      */
1075     virtual Node *removeNamedItemNS(const DOMString& namespaceURI,
1076                                     const DOMString& localName)
1077                                     throw(DOMException)
1078         {
1079         std::vector<NamedNodeMapEntry>::iterator iter;
1080         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1081             {
1082             if (iter->namespaceURI == namespaceURI && iter->name == localName)
1083                 {
1084                 Node *node = iter->node;
1085                 entries.erase(iter);
1086                 return node;
1087                 }
1088             }
1089         return NULL;
1090         }
1092     //##################
1093     //# Non-API methods
1094     //##################
1096     /**
1097      *
1098      */
1099     NamedNodeMap() {}
1102     /**
1103      *
1104      */
1105     NamedNodeMap(const NamedNodeMap &other)
1106         {
1107         entries = other.entries;
1108         }
1110     /**
1111      *
1112      */
1113     NamedNodeMap &operator=(const NamedNodeMap &other)
1114         {
1115         entries = other.entries;
1116         return *this;
1117         }
1120     /**
1121      *
1122      */
1123     virtual ~NamedNodeMap() {}
1125 protected:
1127     std::vector<NamedNodeMapEntry> entries;
1129 };
1134 /*#########################################################################
1135 ## CharacterData
1136 #########################################################################*/
1138 /**
1139  *
1140  */
1141 class CharacterData : virtual public Node
1143 public:
1145     /**
1146      *
1147      */
1148     virtual DOMString getData() throw(DOMException) = 0;
1150     /**
1151      *
1152      */
1153     virtual void setData(const DOMString& val) throw(DOMException) = 0;
1155     /**
1156      *
1157      */
1158     virtual unsigned long getLength() = 0;
1160     /**
1161      *
1162      */
1163     virtual DOMString substringData(unsigned long offset,
1164                             unsigned long count)
1165                             throw(DOMException) = 0;
1167     /**
1168      *
1169      */
1170     virtual void appendData(const DOMString& arg) throw(DOMException) = 0;
1172     /**
1173      *
1174      */
1175     virtual void insertData(unsigned long offset,
1176                     const DOMString& arg)
1177                     throw(DOMException) = 0;
1179     /**
1180      *
1181      */
1182     virtual void deleteData(unsigned long offset,
1183                     unsigned long count)
1184                     throw(DOMException) = 0;
1186     /**
1187      *
1188      */
1189     virtual void  replaceData(unsigned long offset,
1190                       unsigned long count,
1191                       const DOMString& arg)
1192                       throw(DOMException) = 0;
1195     //##################
1196     //# Non-API methods
1197     //##################
1200     /**
1201      *
1202      */
1203     virtual ~CharacterData() {}
1205 };
1211 /*#########################################################################
1212 ## Attr
1213 #########################################################################*/
1215 /**
1216  *
1217  */
1218 class Attr : virtual public Node
1220 public:
1222     /**
1223      *
1224      */
1225     virtual DOMString getName() = 0;
1227     /**
1228      *
1229      */
1230     virtual bool getSpecified() = 0;
1232     /**
1233      *
1234      */
1235     virtual DOMString getValue() = 0;
1237     /**
1238      *
1239      */
1240     virtual void setValue(const DOMString& val) throw(DOMException) = 0;
1242     /**
1243      *
1244      */
1245     virtual Element *getOwnerElement() = 0;
1248     /**
1249      *
1250      */
1251     virtual TypeInfo *getSchemaTypeInfo() = 0;
1254     /**
1255      *
1256      */
1257     virtual bool getIsId() = 0;
1259     //##################
1260     //# Non-API methods
1261     //##################
1264     /**
1265      *
1266      */
1267     virtual ~Attr() {}
1269 };
1275 /*#########################################################################
1276 ## Element
1277 #########################################################################*/
1279 /**
1280  *
1281  */
1282 class Element : virtual public Node
1284 public:
1287     /**
1288      *
1289      */
1290     virtual DOMString getTagName() = 0;
1292     /**
1293      *
1294      */
1295     virtual DOMString getAttribute(const DOMString& name) = 0;
1297     /**
1298      *
1299      */
1300     virtual void setAttribute(const DOMString& name,
1301                       const DOMString& value)
1302                       throw(DOMException) = 0;
1304     /**
1305      *
1306      */
1307     virtual void removeAttribute(const DOMString& name)
1308                          throw(DOMException) = 0;
1310     /**
1311      *
1312      */
1313     virtual Attr *getAttributeNode(const DOMString& name) = 0;
1315     /**
1316      *
1317      */
1318     virtual Attr *setAttributeNode(Attr *newAttr)
1319                           throw(DOMException) = 0;
1321     /**
1322      *
1323      */
1324     virtual Attr *removeAttributeNode(Attr *oldAttr)
1325                              throw(DOMException) = 0;
1327     /**
1328      *
1329      */
1330     virtual NodeList getElementsByTagName(const DOMString& name) = 0;
1332     /**
1333      *
1334      */
1335     virtual DOMString getAttributeNS(const DOMString& namespaceURI,
1336                              const DOMString& localName) = 0;
1338     /**
1339      *
1340      */
1341     virtual void setAttributeNS(const DOMString& namespaceURI,
1342                         const DOMString& qualifiedName,
1343                         const DOMString& value)
1344                         throw(DOMException) = 0;
1346     /**
1347      *
1348      */
1349     virtual void removeAttributeNS(const DOMString& namespaceURI,
1350                            const DOMString& localName)
1351                            throw(DOMException) = 0;
1353     /**
1354      *
1355      */
1356     virtual Attr *getAttributeNodeNS(const DOMString& namespaceURI,
1357                             const DOMString& localName) = 0;
1359     /**
1360      *
1361      */
1362     virtual Attr *setAttributeNodeNS(Attr *newAttr)
1363                             throw(DOMException) = 0;
1365     /**
1366      *
1367      */
1368     virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI,
1369                                     const DOMString& localName) = 0;
1371     /**
1372      *
1373      */
1374     virtual bool hasAttribute(const DOMString& name) = 0;
1376     /**
1377      *
1378      */
1379     virtual bool hasAttributeNS(const DOMString& namespaceURI,
1380                         const DOMString& localName) = 0;
1382     /**
1383      *
1384      */
1385     virtual TypeInfo *getSchemaTypeInto() = 0;
1388     /**
1389      *
1390      */
1391     virtual void setIdAttribute(const DOMString &name,
1392                                 bool isId) throw (DOMException) = 0;
1394     /**
1395      *
1396      */
1397     virtual void setIdAttributeNS(const DOMString &namespaceURI,
1398                                   const DOMString &localName,
1399                                   bool isId) throw (DOMException) = 0;
1401     /**
1402      *
1403      */
1404     virtual void setIdAttributeNode(const Attr *idAttr,
1405                                     bool isId) throw (DOMException) = 0;
1407     //##################
1408     //# Non-API methods
1409     //##################
1411     /**
1412      *
1413      */
1414     virtual ~Element() {}
1416 };
1422 /*#########################################################################
1423 ## Text
1424 #########################################################################*/
1426 /**
1427  *
1428  */
1429 class Text : virtual public CharacterData
1431 public:
1433     /**
1434      *
1435      */
1436     virtual Text *splitText(unsigned long offset)
1437                     throw(DOMException) = 0;
1439     /**
1440      *
1441      */
1442     virtual bool getIsElementContentWhitespace()= 0;
1444     /**
1445      *
1446      */
1447     virtual DOMString getWholeText() = 0;
1450     /**
1451      *
1452      */
1453     virtual Text *replaceWholeText(const DOMString &content)
1454                                  throw(DOMException) = 0;
1456     //##################
1457     //# Non-API methods
1458     //##################
1461     /**
1462      *
1463      */
1464     virtual ~Text() {}
1466 };
1470 /*#########################################################################
1471 ## Comment
1472 #########################################################################*/
1474 /**
1475  *
1476  */
1477 class Comment : virtual public CharacterData
1479 public:
1481     //##################
1482     //# Non-API methods
1483     //##################
1486     /**
1487      *
1488      */
1489     virtual ~Comment() {}
1492 };
1496 /*#########################################################################
1497 ## TypeInfo
1498 #########################################################################*/
1500 /**
1501  *
1502  */
1503 class TypeInfo
1505 public:
1507     /**
1508      *
1509      */
1510     virtual DOMString getTypeName() =0;
1512     /**
1513      *
1514      */
1515     virtual DOMString getTypeNamespace() =0;
1517     typedef enum
1518         {
1519         DERIVATION_RESTRICTION = 0x00000001,
1520         DERIVATION_EXTENSION   = 0x00000002,
1521         DERIVATION_UNION       = 0x00000004,
1522         DERIVATION_LIST        = 0x00000008
1523         } DerivationMethod;
1526     /**
1527      *
1528      */
1529     virtual bool isDerivedFrom(const DOMString &typeNamespaceArg,
1530                                const DOMString &typeNameArg,
1531                                DerivationMethod derivationMethod) =0;
1533     //##################
1534     //# Non-API methods
1535     //##################
1538     /**
1539      *
1540      */
1541     virtual ~TypeInfo() {}
1543 };
1548 /*#########################################################################
1549 ## UserDataHandler
1550 #########################################################################*/
1552 /**
1553  *
1554  */
1555 class UserDataHandler
1557 public:
1559     typedef enum
1560         {
1561         NODE_CLONED     = 1,
1562         NODE_IMPORTED   = 2,
1563         NODE_DELETED    = 3,
1564         NODE_RENAMED    = 4,
1565         NODE_ADOPTED    = 5
1566         } OperationType;
1569     /**
1570      *
1571      */
1572     virtual  void handle(unsigned short operation,
1573                          const DOMString &key,
1574                          const DOMUserData *data,
1575                          const Node *src,
1576                          const Node *dst) =0;
1578     //##################
1579     //# Non-API methods
1580     //##################
1583     /**
1584      *
1585      */
1586     virtual ~UserDataHandler() {}
1588 };
1591 /*#########################################################################
1592 ## DOMError
1593 #########################################################################*/
1595 /**
1596  *
1597  */
1598 class DOMError
1600 public:
1602     typedef enum
1603         {
1604         DOMERROR_SEVERITY_WARNING     = 1,
1605         DOMERROR_SEVERITY_ERROR       = 2,
1606         DOMERROR_SEVERITY_FATAL_ERROR = 3
1607         } ErrorSeverity;
1610     /**
1611      *
1612      */
1613     virtual unsigned short getSeverity() =0;
1615     /**
1616      *
1617      */
1618     virtual DOMString getMessage() =0;
1620     /**
1621      *
1622      */
1623     virtual DOMString getType() =0;
1625     /**
1626      *
1627      */
1628     virtual DOMObject *getRelatedException() =0;
1630     /**
1631      *
1632      */
1633     virtual DOMObject *getRelatedData() =0;
1635     /**
1636      *
1637      */
1638     virtual DOMLocator *getLocation() =0;
1641     //##################
1642     //# Non-API methods
1643     //##################
1646     /**
1647      *
1648      */
1649     virtual ~DOMError() {}
1651 };
1654 /*#########################################################################
1655 ## DOMErrorHandler
1656 #########################################################################*/
1658 /**
1659  *
1660  */
1661 class DOMErrorHandler
1663 public:
1664     /**
1665      *
1666      */
1667     virtual bool handleError(const DOMError *error) =0;
1669     //##################
1670     //# Non-API methods
1671     //##################
1674     /**
1675      *
1676      */
1677     virtual ~DOMErrorHandler() {}
1679 };
1683 /*#########################################################################
1684 ## DOMLocator
1685 #########################################################################*/
1687 /**
1688  *
1689  */
1690 class DOMLocator
1692 public:
1694     /**
1695      *
1696      */
1697     virtual long getLineNumber() =0;
1699     /**
1700      *
1701      */
1702     virtual long getColumnNumber() =0;
1704     /**
1705      *
1706      */
1707     virtual long getByteOffset() =0;
1709     /**
1710      *
1711      */
1712     virtual long getUtf16Offset() =0;
1715     /**
1716      *
1717      */
1718     virtual Node *getRelatedNode() =0;
1721     /**
1722      *
1723      */
1724     virtual DOMString getUri() =0;
1726     //##################
1727     //# Non-API methods
1728     //##################
1730     /**
1731      *
1732      */
1733     virtual ~DOMLocator() {}
1734 };
1737 /*#########################################################################
1738 ## DOMConfiguration
1739 #########################################################################*/
1741 /**
1742  *
1743  */
1744 class DOMConfiguration
1746 public:
1748     /**
1749      *
1750      */
1751     virtual void setParameter(const DOMString &name,
1752                               const DOMUserData *value) throw (DOMException) =0;
1754     /**
1755      *
1756      */
1757     virtual DOMUserData *getParameter(const DOMString &name)
1758                                       throw (DOMException) =0;
1760     /**
1761      *
1762      */
1763     virtual bool canSetParameter(const DOMString &name,
1764                                  const DOMUserData *data) =0;
1766     /**
1767      *
1768      */
1769     virtual DOMStringList *getParameterNames() =0;
1771     //##################
1772     //# Non-API methods
1773     //##################
1776     /**
1777      *
1778      */
1779     virtual ~DOMConfiguration() {}
1781 };
1788 /*#########################################################################
1789 ## CDATASection
1790 #########################################################################*/
1791 /**
1792  *
1793  */
1794 class CDATASection : virtual public Text
1796 public:
1798     //##################
1799     //# Non-API methods
1800     //##################
1803     /**
1804      *
1805      */
1806     virtual ~CDATASection() {}
1808 };
1813 /*#########################################################################
1814 ## DocumentType
1815 #########################################################################*/
1817 /**
1818  *
1819  */
1820 class DocumentType : virtual public Node
1822 public:
1824     /**
1825      *
1826      */
1827     virtual DOMString getName() = 0;
1829     /**
1830      *
1831      */
1832     virtual NamedNodeMap getEntities() = 0;
1834     /**
1835      *
1836      */
1837     virtual NamedNodeMap getNotations() = 0;
1839     /**
1840      *
1841      */
1842     virtual DOMString getPublicId() = 0;
1844     /**
1845      *
1846      */
1847     virtual DOMString getSystemId() = 0;
1849     /**
1850      *
1851      */
1852     virtual DOMString getInternalSubset() = 0;
1854     //##################
1855     //# Non-API methods
1856     //##################
1858     /**
1859      *
1860      */
1861     virtual ~DocumentType() {}
1863 };
1869 /*#########################################################################
1870 ## Notation
1871 #########################################################################*/
1873 /**
1874  *
1875  */
1876 class Notation : virtual public Node
1878 public:
1880     /**
1881      *
1882      */
1883     virtual DOMString getPublicId() = 0;
1885     /**
1886      *
1887      */
1888     virtual DOMString getSystemId() = 0;
1890     //##################
1891     //# Non-API methods
1892     //##################
1895     /**
1896      *
1897      */
1898     virtual ~Notation() {}
1899 };
1906 /*#########################################################################
1907 ## Entity
1908 #########################################################################*/
1910 /**
1911  *
1912  */
1913 class Entity : virtual public Node
1915 public:
1917     /**
1918      *
1919      */
1920     virtual DOMString getPublicId() = 0;
1922     /**
1923      *
1924      */
1925     virtual DOMString getSystemId() = 0;
1927     /**
1928      *
1929      */
1930     virtual DOMString getNotationName() = 0;
1932     /**
1933      *
1934      */
1935     virtual DOMString getInputEncoding() = 0;
1937     /**
1938      *
1939      */
1940     virtual DOMString getXmlEncoding() = 0;
1942     /**
1943      *
1944      */
1945     virtual DOMString getXmlVersion() = 0;
1947     //##################
1948     //# Non-API methods
1949     //##################
1952     /**
1953      *
1954      */
1955     virtual ~Entity() {}
1956 };
1962 /*#########################################################################
1963 ## EntityReference
1964 #########################################################################*/
1965 /**
1966  *
1967  */
1968 class EntityReference : virtual public Node
1970 public:
1973     //##################
1974     //# Non-API methods
1975     //##################
1977     /**
1978      *
1979      */
1980     virtual ~EntityReference() {}
1981 };
1987 /*#########################################################################
1988 ## ProcessingInstruction
1989 #########################################################################*/
1991 /**
1992  *
1993  */
1994 class ProcessingInstruction : virtual public Node
1996 public:
1998     /**
1999      *
2000      */
2001     virtual DOMString getTarget() = 0;
2003     /**
2004      *
2005      */
2006     virtual DOMString getData() = 0;
2008     /**
2009      *
2010      */
2011    virtual void setData(const DOMString& val) throw(DOMException) = 0;
2013     //##################
2014     //# Non-API methods
2015     //##################
2018     /**
2019      *
2020      */
2021     virtual ~ProcessingInstruction() {}
2023 };
2029 /*#########################################################################
2030 ## DocumentFragment
2031 #########################################################################*/
2032 /**
2033  *
2034  */
2035 class DocumentFragment : virtual public Node
2037 public:
2039     //##################
2040     //# Non-API methods
2041     //##################
2044     /**
2045      *
2046      */
2047     virtual ~DocumentFragment() {}
2048 };
2055 /*#########################################################################
2056 ## Document
2057 #########################################################################*/
2059 /**
2060  *
2061  */
2062 class Document : virtual public Node
2064 public:
2066     /**
2067      *
2068      */
2069     virtual DocumentType *getDoctype() = 0;
2071     /**
2072      *
2073      */
2074     virtual DOMImplementation *getImplementation() = 0;
2076     /**
2077      *
2078      */
2079     virtual Element *getDocumentElement() = 0;
2081     /**
2082      *
2083      */
2084     virtual Element *createElement(const DOMString& tagName)
2085                            throw(DOMException) = 0;
2087     /**
2088      *
2089      */
2090     virtual DocumentFragment *createDocumentFragment() = 0;
2092     /**
2093      *
2094      */
2095     virtual Text *createTextNode(const DOMString& data) = 0;
2097     /**
2098      *
2099      */
2100     virtual Comment  *createComment(const DOMString& data) = 0;
2102     /**
2103      *
2104      */
2105     virtual CDATASection *createCDATASection(const DOMString& data)
2106                                      throw(DOMException) = 0;
2108     /**
2109      *
2110      */
2111     virtual ProcessingInstruction *createProcessingInstruction(const DOMString& target,
2112                                                        const DOMString& data)
2113                                                        throw(DOMException) = 0;
2115     /**
2116      *
2117      */
2118     virtual Attr *createAttribute(const DOMString& name)
2119                           throw(DOMException) = 0;
2121     /**
2122      *
2123      */
2124     virtual EntityReference *createEntityReference(const DOMString& name)
2125                                            throw(DOMException) = 0;
2127     /**
2128      *
2129      */
2130     virtual NodeList getElementsByTagName(const DOMString& tagname) = 0;
2133     /**
2134      *
2135      */
2136     virtual Node *importNode(const Node *importedNode,
2137                      bool deep)
2138                      throw(DOMException) = 0;
2140     /**
2141      *
2142      */
2143     virtual Element *createElementNS(const DOMString& namespaceURI,
2144                              const DOMString& qualifiedName)
2145                              throw(DOMException) = 0;
2147     /**
2148      *
2149      */
2150     virtual Attr *createAttributeNS(const DOMString& namespaceURI,
2151                             const DOMString& qualifiedName)
2152                             throw(DOMException) = 0;
2154     /**
2155      *
2156      */
2157     virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI,
2158                                      const DOMString& localName) = 0;
2160     /**
2161      *
2162      */
2163     virtual Element *getElementById(const DOMString& elementId) = 0;
2166     /**
2167      *
2168      */
2169     virtual DOMString getInputEncoding() = 0;
2172     /**
2173      *
2174      */
2175     virtual DOMString getXmlEncoding() = 0;
2177     /**
2178      *
2179      */
2180     virtual bool getXmlStandalone() = 0;
2182     /**
2183      *
2184      */
2185     virtual void setXmlStandalone(bool val) throw (DOMException) = 0;
2187     /**
2188      *
2189      */
2190     virtual DOMString getXmlVersion() = 0;
2192     /**
2193      *
2194      */
2195     virtual void setXmlVersion(const DOMString &version) throw (DOMException) = 0;
2197     /**
2198      *
2199      */
2200     virtual bool getStrictErrorChecking() = 0;
2202     /**
2203      *
2204      */
2205     virtual void setStrictErrorChecking(bool val) = 0;
2208     /**
2209      *
2210      */
2211     virtual DOMString getDocumentURI() = 0;
2213     /**
2214      *
2215      */
2216     virtual void setDocumentURI(const DOMString &uri) = 0;
2218     /**
2219      *
2220      */
2221     virtual Node *adoptNode(const Node *source) throw (DOMException) = 0;
2223     /**
2224      *
2225      */
2226     virtual DOMConfiguration *getDomConfig() = 0;
2228     /**
2229      *
2230      */
2231     virtual void normalizeDocument() = 0;
2233     /**
2234      *
2235      */
2236     virtual Node *renameNode(const Node *n,
2237                              const DOMString &namespaceURI,
2238                              const DOMString &qualifiedName)
2239                              throw (DOMException) = 0;
2242     //##################
2243     //# Non-API methods
2244     //##################
2246     /**
2247      *
2248      */
2249     virtual ~Document() {}
2251 };
2263 }  //namespace dom
2264 }  //namespace w3c
2265 }  //namespace org
2268 #endif // __DOM_H__
2271 /*#########################################################################
2272 ## E N D    O F    F I L E
2273 #########################################################################*/