Code

Add new rearranged /dom directory
[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) 2005 Bob Jamison
16  *
17  *  This library is free software; you can redistribute it and/or
18  *  modify it under the terms of the GNU Lesser General Public
19  *  License as published by the Free Software Foundation; either
20  *  version 2.1 of the License, or (at your option) any later version.
21  *
22  *  This library is distributed in the hope that it will be useful,
23  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
24  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25  *  Lesser General Public License for more details.
26  *
27  *  You should have received a copy of the GNU Lesser General Public
28  *  License along with this library; if not, write to the Free Software
29  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
30  */
32 #include <string>
33 #include <vector>
35 #define OWN_STRING
37 #ifdef OWN_STRING
38 #include "domstring.h"
39 #else
40 #include <glibmm.h>
41 typedef Glib::ustring DOMString
42 #endif
44 #define XMLNSNAME "http://www.w3.org/2000/xmlns/"
46 namespace org
47 {
48 namespace w3c
49 {
50 namespace dom
51 {
55 #ifndef OWN_STRING
56 typedef unsigned short XMLCh;
57 typedef std::string DOMString;
58 #endif
60 /**
61  *
62  */
63 typedef unsigned long long DOMTimeStamp;
65 /**
66  *
67  */
68 typedef void DOMUserData;
70 /**
71  *
72  */
73 typedef void DOMObject;
76 class DOMException;
77 class DOMStringList;
78 class NameList;
79 class DOMImplementationList;
80 class DOMImplementationSource;
81 class DOMImplementation;
82 class Node;
83 class NodeList;
84 class NamedNodeMap;
85 class CharacterData;
86 class Attr;
87 class Element;
88 class Text;
89 class Comment;
90 class TypeInfo;
91 class UserDataHandler;
92 class DOMError;
93 class DOMErrorHandler;
94 class DOMLocator;
95 class DOMConfiguration;
96 class CDATASection;
97 class DocumentType;
98 class Notation;
99 class Entity;
100 class EntityReference;
101 class ProcessingInstruction;
102 class DocumentFragment;
103 class Document;
106 /**
107  * NOTE: We were originally intending to split ALL specifications into
108  * interface and implementation.   After consideration, though, it behooves
109  * us to simplify things by implementing the base exception and
110  * container classes directly:
111  *
112  * DOMException
113  * DOMStringList
114  * NameList
115  * DOMImplementationList
116  * DOMImplementationSource
117  * DOMImplementation
118  * NodeList
119  * NamedNodeMap
120  */
123 /*#########################################################################
124 ## DOMException
125 #########################################################################*/
126 /**
127  *  This is the only non-interface class
128  */
129 class DOMException
132 public:
134     DOMException(const DOMString &reasonMsg)
135         { msg = reasonMsg; }
137     DOMException(short theCode)
138         {
139         code = theCode;
140         }
142     virtual ~DOMException() throw()
143        {}
145     /**
146      *
147      */
148     unsigned short code;
150     /**
151      *
152      */
153     DOMString msg;
155     /**
156      * Get a string, translated from the code.
157      * Like std::exception. Not in spec.
158      */
159     const char *what()
160         { return (const char *)msg.c_str(); }
164 };
169 /**
170  * ExceptionCode
171  */
172 typedef enum
174         INDEX_SIZE_ERR                 = 1,
175         DOMSTRING_SIZE_ERR             = 2,
176         HIERARCHY_REQUEST_ERR          = 3,
177         WRONG_DOCUMENT_ERR             = 4,
178         INVALID_CHARACTER_ERR          = 5,
179         NO_DATA_ALLOWED_ERR            = 6,
180         NO_MODIFICATION_ALLOWED_ERR    = 7,
181         NOT_FOUND_ERR                  = 8,
182         NOT_SUPPORTED_ERR              = 9,
183         INUSE_ATTRIBUTE_ERR            = 10,
184         INVALID_STATE_ERR              = 11,
185         SYNTAX_ERR                     = 12,
186         INVALID_MODIFICATION_ERR       = 13,
187         NAMESPACE_ERR                  = 14,
188         INVALID_ACCESS_ERR             = 15,
189         VALIDATION_ERR                 = 16,
190         TYPE_MISMATCH_ERR              = 17
191 } ExceptionCode;
194 /*#########################################################################
195 ## DOMStringList
196 #########################################################################*/
198 class DOMStringList
200 public:
202     /**
203      *
204      */
205     virtual DOMString item(unsigned long index)
206         {
207         if (index>=strings.size())
208             return "";
209         return strings[index];
210         }
212     /**
213      *
214      */
215     virtual unsigned long getLength()
216         {
217         return (unsigned long) strings.size();
218         }
220     /**
221      *
222      */
223     virtual bool contains(const DOMString &str)
224         {
225         for (unsigned int i=0; i<strings.size() ; i++)
226             {
227             if (strings[i] == str)
228                 return true;
229             }
230         return false;
231         }
234     //##################
235     //# Non-API methods
236     //##################
238     /**
239      *
240      */
241     DOMStringList() {}
244     /**
245      *
246      */
247     DOMStringList(const DOMStringList &other)
248         {
249         strings = other.strings;
250         }
252     /**
253      *
254      */
255     virtual ~DOMStringList() {}
258 protected:
260     /**
261      *
262      */
263     virtual void add(const DOMString &str)
264         {
265         strings.push_back(str);
266         }
268     std::vector<DOMString>strings;
270 };
274 /*#########################################################################
275 ## NameList
276 #########################################################################*/
277 class NamePair
279 public:
280     NamePair(const DOMString &theNamespaceURI, const DOMString &theName)
281         {
282         namespaceURI = theNamespaceURI;
283         name         = theName;
284         }
285     NamePair(const NamePair &other)
286         {
287         namespaceURI = other.namespaceURI;
288         name         = other.name;
289         }
290     virtual ~NamePair() {}
292     DOMString namespaceURI;
293     DOMString name;
294 };
298 class NameList
300 public:
302     /**
303      *
304      */
305     virtual DOMString getName(unsigned long index)
306         {
307         if (index>=namePairs.size())
308             return "";
309         return namePairs[index].name;
310         }
312     /**
313      *
314      */
315     virtual DOMString getNamespaceURI(unsigned long index)
316         {
317         if (index>=namePairs.size())
318             return "";
319         return namePairs[index].namespaceURI;
320         }
322     /**
323      *
324      */
325     virtual unsigned long getLength()
326         {
327         return (unsigned long)namePairs.size();
328         }
330     /**
331      *
332      */
333     virtual bool contains(const DOMString &name)
334         {
335         for (unsigned int i=0; i<namePairs.size() ; i++)
336             {
337             if (namePairs[i].name == name )
338                 return true;
339             }
340         return false;
341         }
343     /**
344      *
345      */
346     virtual bool containsNS(const DOMString namespaceURI,const DOMString &name)
347         {
348         for (unsigned int i=0; i<namePairs.size() ; i++)
349             {
350             if (namePairs[i].namespaceURI == namespaceURI ||
351                 namePairs[i].name         == name           )
352                 return true;
353             }
354         return false;
355         }
358     //##################
359     //# Non-API methods
360     //##################
362     /**
363      *
364      */
365     NameList() {}
367     /**
368      *
369      */
370     NameList(const NameList &other)
371         {
372         namePairs = other.namePairs;
373         }
375     /**
376      *
377      */
378     virtual ~NameList() {}
379 protected:
381     std::vector<NamePair> namePairs;
383 };
385 /*#########################################################################
386 ## DOMImplementationList
387 #########################################################################*/
389 class DOMImplementationList
391 public:
393     /**
394      *
395      */
396     virtual DOMImplementation *getDOMImplementation(unsigned long index)
397         {
398         if (index >implementations.size())
399             return NULL;
400         return implementations[index];
401         }
403     /**
404      *
405      */
406     virtual unsigned long getLength()
407         {
408         return (unsigned long) implementations.size();
409         }
414     //##################
415     //# Non-API methods
416     //##################
418     /**
419      *
420      */
421     DOMImplementationList() {}
424     /**
425      *
426      */
427     DOMImplementationList(const DOMImplementationList &other)
428         {
429         implementations = other.implementations;
430         }
432     /**
433      *
434      */
435     virtual ~DOMImplementationList() {}
437 protected:
439     std::vector<DOMImplementation *>implementations;
441 };
444 /*#########################################################################
445 ## DOMImplementationSource
446 #########################################################################*/
448 class DOMImplementationSource
450 public:
452     /**
453      *
454      */
455     virtual DOMImplementation *getDOMImplementation(const DOMString &features) = 0;
457     /**
458      *
459      */
460     virtual DOMImplementationList getDOMImplementationList(const DOMString &features) = 0;
462     //##################
463     //# Non-API methods
464     //##################
466     /**
467      *
468      */
469     virtual ~DOMImplementationSource() {}
471 };
477 /*#########################################################################
478 ## DOMImplementation
479 #########################################################################*/
480 /**
481  *
482  */
483 class DOMImplementation
485 public:
486     /**
487      *
488      */
489     virtual bool hasFeature(const DOMString& feature, const DOMString& version) = 0;
492     /**
493      *
494      */
495     virtual DocumentType *createDocumentType(const DOMString& qualifiedName,
496                                      const DOMString& publicId,
497                                      const DOMString& systemId)
498                                      throw(DOMException) = 0;
500     /**
501      *
502      */
503     virtual Document *createDocument(const DOMString& namespaceURI,
504                              const DOMString& qualifiedName,
505                              DocumentType *doctype)
506                              throw(DOMException) = 0;
507     /**
508      *
509      */
510     virtual DOMObject *getFeature(const DOMString& feature,
511                              const DOMString& version) = 0;
514     //##################
515     //# Non-API methods
516     //##################
518     /**
519      *
520      */
521     virtual ~DOMImplementation() {}
523 };
528 /*#########################################################################
529 ## Node
530 #########################################################################*/
532 /**
533  *
534  */
535 class Node
537 public:
539     typedef enum
540         {
541         ELEMENT_NODE                   = 1,
542         ATTRIBUTE_NODE                 = 2,
543         TEXT_NODE                      = 3,
544         CDATA_SECTION_NODE             = 4,
545         ENTITY_REFERENCE_NODE          = 5,
546         ENTITY_NODE                    = 6,
547         PROCESSING_INSTRUCTION_NODE    = 7,
548         COMMENT_NODE                   = 8,
549         DOCUMENT_NODE                  = 9,
550         DOCUMENT_TYPE_NODE             = 10,
551         DOCUMENT_FRAGMENT_NODE         = 11,
552         NOTATION_NODE                  = 12
553         } NodeType;
555     /**
556      *
557      */
558     virtual DOMString getNodeName() = 0;
560     /**
561      *
562      */
563     virtual DOMString getNodeValue() throw (DOMException) = 0;
565     /**
566      *
567      */
568     virtual void setNodeValue(const DOMString& val) throw (DOMException) = 0;
570     /**
571      *
572      */
573     virtual unsigned short getNodeType() = 0;
575     /**
576      *
577      */
578     virtual Node *getParentNode() = 0;
580     /**
581      *
582      */
583     virtual NodeList getChildNodes() = 0;
585     /**
586      *
587      */
588     virtual Node *getFirstChild() = 0;
590     /**
591      *
592      */
593     virtual Node *getLastChild() = 0;
595     /**
596      *
597      */
598     virtual Node *getPreviousSibling() = 0;
600     /**
601      *
602      */
603     virtual Node *getNextSibling() = 0;
605     /**
606      *
607      */
608     virtual NamedNodeMap &getAttributes() = 0;
611     /**
612      *
613      */
614     virtual Document *getOwnerDocument() = 0;
616     /**
617      *
618      */
619     virtual Node *insertBefore(const Node *newChild,
620                        const Node *refChild)
621                        throw(DOMException) = 0;
623     /**
624      *
625      */
626     virtual Node *replaceChild(const Node *newChild,
627                        const Node *oldChild)
628                        throw(DOMException) = 0;
630     /**
631      *
632      */
633     virtual Node *removeChild(const Node *oldChild)
634                       throw(DOMException) = 0;
636     /**
637      *
638      */
639     virtual Node *appendChild(const Node *newChild)
640                       throw(DOMException) = 0;
642     /**
643      *
644      */
645     virtual bool hasChildNodes() = 0;
647     /**
648      *
649      */
650     virtual Node *cloneNode(bool deep) = 0;
652     /**
653      *
654      */
655     virtual void normalize() = 0;
657     /**
658      *
659      */
660     virtual bool isSupported(const DOMString& feature,
661                      const DOMString& version) = 0;
663     /**
664      *
665      */
666     virtual DOMString getNamespaceURI() = 0;
668     /**
669      *
670      */
671     virtual DOMString getPrefix() = 0;
673     /**
674      *
675      */
676     virtual void setPrefix(const DOMString& val) throw(DOMException) = 0;
678     /**
679      *
680      */
681     virtual DOMString getLocalName() = 0;
683     /**
684      *
685      */
686     virtual bool hasAttributes() = 0;
688     /**
689      *
690      */
691     virtual DOMString getBaseURI() = 0;
693     typedef enum
694         {
695         DOCUMENT_POSITION_DISCONNECTED            = 0x01,
696         DOCUMENT_POSITION_PRECEDING               = 0x02,
697         DOCUMENT_POSITION_FOLLOWING               = 0x04,
698         DOCUMENT_POSITION_CONTAINS                = 0x08,
699         DOCUMENT_POSITION_CONTAINED_BY            = 0x10,
700         DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20
701         } DocumentPosition;
704     /**
705      *
706      */
707     virtual unsigned short compareDocumentPosition(const Node *other) = 0;
709     /**
710      *
711      */
712     virtual DOMString getTextContext() throw(DOMException) = 0;
715     /**
716      *
717      */
718     virtual void setTextContext(const DOMString &val) throw(DOMException) = 0;
721     /**
722      *
723      */
724     virtual DOMString lookupPrefix(const DOMString &namespaceURI) =0;
727     /**
728      *
729      */
730     virtual bool isDefaultNamespace(const DOMString &namespaceURI) =0;
733     /**
734      *
735      */
736     virtual DOMString lookupNamespaceURI(const DOMString &prefix) =0;
739     /**
740      *
741      */
742     virtual bool isEqualNode(const Node *node) =0;
746     /**
747      *
748      */
749     virtual DOMObject *getFeature(const DOMString &feature,
750                                  const DOMString &version) =0;
752     /**
753      *
754      */
755     virtual DOMUserData *setUserData(const DOMString &key,
756                                      const DOMUserData *data,
757                                      const UserDataHandler *handler) =0;
760     /**
761      *
762      */
763     virtual DOMUserData *getUserData(const DOMString &namespaceURI) =0;
765     //##################
766     //# Non-API methods
767     //##################
770     /**
771      *
772      */
773     virtual ~Node() {}
778 };
782 /*#########################################################################
783 ## NodeList
784 #########################################################################*/
786 /**
787  *
788  */
789 class NodeList
791 public:
792     /**
793      *
794      */
795     virtual Node *item(unsigned long index)
796         {
797         if (index>=nodes.size())
798             return NULL;
799         return nodes[index];
800         }
802     /**
803      *
804      */
805     virtual unsigned long getLength()
806         {
807         return (unsigned long) nodes.size();
808         }
810     //##################
811     //# Non-API methods
812     //##################
815     /**
816      *
817      */
818     NodeList() {}
820     /**
821      *
822      */
823     NodeList(const NodeList &other)
824         {
825         nodes = other.nodes;
826         }
828     /**
829      *
830      */
831     virtual ~NodeList() {}
833 protected:
835 friend class NodeImpl;
836 friend class ElementImpl;
838     /*
839      *
840      */
841     virtual void add(const Node *node)
842         {
843         nodes.push_back((Node *)node);
844         }
846 protected:
848     std::vector<Node *> nodes;
850 };
855 /*#########################################################################
856 ## NamedNodeMap
857 #########################################################################*/
859 class NamedNodeMapEntry
861 public:
862     NamedNodeMapEntry(const DOMString &theNamespaceURI,
863                       const DOMString &theName,
864                       const Node      *theNode)
865         {
866         namespaceURI = theNamespaceURI;
867         name         = theName;
868         node         = (Node *)theNode;
869         }
870     NamedNodeMapEntry(const NamedNodeMapEntry &other)
871         {
872         namespaceURI = other.namespaceURI;
873         name         = other.name;
874         node         = other.node;
875         }
876     virtual ~NamedNodeMapEntry()
877         {
878         }
879     DOMString namespaceURI;
880     DOMString name;
881     Node      *node;
882 };
884 /**
885  *
886  */
887 class NamedNodeMap
889 public:
891     /**
892      *
893      */
894     virtual Node *getNamedItem(const DOMString& name)
895         {
896         std::vector<NamedNodeMapEntry>::iterator iter;
897         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
898             {
899             if (iter->name == name)
900                 {
901                 Node *node = iter->node;
902                 return node;
903                 }
904             }
905         return NULL;
906         }
908     /**
909      *
910      */
911     virtual Node *setNamedItem(Node *arg) throw(DOMException)
912         {
913         if (!arg)
914             return NULL;
915         DOMString namespaceURI = arg->getNamespaceURI();
916         DOMString name         = arg->getNodeName();
917         std::vector<NamedNodeMapEntry>::iterator iter;
918         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
919             {
920             if (iter->name == name)
921                 {
922                 Node *node = iter->node;
923                 iter->node = arg;
924                 return node;
925                 }
926             }
927         NamedNodeMapEntry entry(namespaceURI, name, arg);
928         entries.push_back(entry);
929         return arg;
930         }
933     /**
934      *
935      */
936     virtual Node *removeNamedItem(const DOMString& name) throw(DOMException)
937         {
938         std::vector<NamedNodeMapEntry>::iterator iter;
939         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
940             {
941             if (iter->name == name)
942                 {
943                 Node *node = iter->node;
944                 entries.erase(iter);
945                 return node;
946                 }
947             }
948         return NULL;
949         }
951     /**
952      *
953      */
954     virtual Node *item(unsigned long index)
955         {
956         if (index>=entries.size())
957             return NULL;
958         return entries[index].node;
959         }
961     /**
962      *
963      */
964     virtual unsigned long getLength()
965         {
966         return (unsigned long)entries.size();
967         }
969     /**
970      *
971      */
972     virtual Node *getNamedItemNS(const DOMString& namespaceURI,
973                                  const DOMString& localName)
974         {
975         std::vector<NamedNodeMapEntry>::iterator iter;
976         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
977             {
978             if (iter->namespaceURI == namespaceURI && iter->name == localName)
979                 {
980                 Node *node = iter->node;
981                 return node;
982                 }
983             }
984         return NULL;
985         }
987     /**
988      *
989      */
990     virtual Node *setNamedItemNS(Node *arg) throw(DOMException)
991         {
992         if (!arg)
993             return NULL;
994         DOMString namespaceURI = arg->getNamespaceURI();
995         DOMString name         = arg->getNodeName();
996         std::vector<NamedNodeMapEntry>::iterator iter;
997         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
998             {
999             if (iter->namespaceURI == namespaceURI && iter->name == name)
1000                 {
1001                 Node *node = iter->node;
1002                 iter->node = arg;
1003                 return node;
1004                 }
1005             }
1006         NamedNodeMapEntry entry(namespaceURI, name, arg);
1007         entries.push_back(entry);
1008         return arg;
1009         }
1011     /**
1012      *
1013      */
1014     virtual Node *removeNamedItemNS(const DOMString& namespaceURI,
1015                                     const DOMString& localName)
1016                                     throw(DOMException)
1017         {
1018         std::vector<NamedNodeMapEntry>::iterator iter;
1019         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1020             {
1021             if (iter->namespaceURI == namespaceURI && iter->name == localName)
1022                 {
1023                 Node *node = iter->node;
1024                 entries.erase(iter);
1025                 return node;
1026                 }
1027             }
1028         return NULL;
1029         }
1031     //##################
1032     //# Non-API methods
1033     //##################
1035     /**
1036      *
1037      */
1038     NamedNodeMap() {}
1041     /**
1042      *
1043      */
1044     NamedNodeMap(const NamedNodeMap &other)
1045         {
1046         entries = other.entries;
1047         }
1050     /**
1051      *
1052      */
1053     virtual ~NamedNodeMap() {}
1055 protected:
1057     std::vector<NamedNodeMapEntry> entries;
1059 };
1064 /*#########################################################################
1065 ## CharacterData
1066 #########################################################################*/
1068 /**
1069  *
1070  */
1071 class CharacterData : virtual public Node
1073 public:
1075     /**
1076      *
1077      */
1078     virtual DOMString getData() throw(DOMException) = 0;
1080     /**
1081      *
1082      */
1083     virtual void setData(const DOMString& val) throw(DOMException) = 0;
1085     /**
1086      *
1087      */
1088     virtual unsigned long getLength() = 0;
1090     /**
1091      *
1092      */
1093     virtual DOMString substringData(unsigned long offset,
1094                             unsigned long count)
1095                             throw(DOMException) = 0;
1097     /**
1098      *
1099      */
1100     virtual void appendData(const DOMString& arg) throw(DOMException) = 0;
1102     /**
1103      *
1104      */
1105     virtual void insertData(unsigned long offset,
1106                     const DOMString& arg)
1107                     throw(DOMException) = 0;
1109     /**
1110      *
1111      */
1112     virtual void deleteData(unsigned long offset,
1113                     unsigned long count)
1114                     throw(DOMException) = 0;
1116     /**
1117      *
1118      */
1119     virtual void  replaceData(unsigned long offset,
1120                       unsigned long count,
1121                       const DOMString& arg)
1122                       throw(DOMException) = 0;
1125     //##################
1126     //# Non-API methods
1127     //##################
1130     /**
1131      *
1132      */
1133     virtual ~CharacterData() {}
1135 };
1141 /*#########################################################################
1142 ## Attr
1143 #########################################################################*/
1145 /**
1146  *
1147  */
1148 class Attr : virtual public Node
1150 public:
1152     /**
1153      *
1154      */
1155     virtual DOMString getName() = 0;
1157     /**
1158      *
1159      */
1160     virtual bool getSpecified() = 0;
1162     /**
1163      *
1164      */
1165     virtual DOMString getValue() = 0;
1167     /**
1168      *
1169      */
1170     virtual void setValue(const DOMString& val) throw(DOMException) = 0;
1172     /**
1173      *
1174      */
1175     virtual Element *getOwnerElement() = 0;
1178     /**
1179      *
1180      */
1181     virtual TypeInfo *getSchemaTypeInfo() = 0;
1184     /**
1185      *
1186      */
1187     virtual bool getIsId() = 0;
1189     //##################
1190     //# Non-API methods
1191     //##################
1194     /**
1195      *
1196      */
1197     virtual ~Attr() {}
1199 };
1205 /*#########################################################################
1206 ## Element
1207 #########################################################################*/
1209 /**
1210  *
1211  */
1212 class Element : virtual public Node
1214 public:
1217     /**
1218      *
1219      */
1220     virtual DOMString getTagName() = 0;
1222     /**
1223      *
1224      */
1225     virtual DOMString getAttribute(const DOMString& name) = 0;
1227     /**
1228      *
1229      */
1230     virtual void setAttribute(const DOMString& name,
1231                       const DOMString& value)
1232                       throw(DOMException) = 0;
1234     /**
1235      *
1236      */
1237     virtual void removeAttribute(const DOMString& name)
1238                          throw(DOMException) = 0;
1240     /**
1241      *
1242      */
1243     virtual Attr *getAttributeNode(const DOMString& name) = 0;
1245     /**
1246      *
1247      */
1248     virtual Attr *setAttributeNode(Attr *newAttr)
1249                           throw(DOMException) = 0;
1251     /**
1252      *
1253      */
1254     virtual Attr *removeAttributeNode(Attr *oldAttr)
1255                              throw(DOMException) = 0;
1257     /**
1258      *
1259      */
1260     virtual NodeList getElementsByTagName(const DOMString& name) = 0;
1262     /**
1263      *
1264      */
1265     virtual DOMString getAttributeNS(const DOMString& namespaceURI,
1266                              const DOMString& localName) = 0;
1268     /**
1269      *
1270      */
1271     virtual void setAttributeNS(const DOMString& namespaceURI,
1272                         const DOMString& qualifiedName,
1273                         const DOMString& value)
1274                         throw(DOMException) = 0;
1276     /**
1277      *
1278      */
1279     virtual void removeAttributeNS(const DOMString& namespaceURI,
1280                            const DOMString& localName)
1281                            throw(DOMException) = 0;
1283     /**
1284      *
1285      */
1286     virtual Attr *getAttributeNodeNS(const DOMString& namespaceURI,
1287                             const DOMString& localName) = 0;
1289     /**
1290      *
1291      */
1292     virtual Attr *setAttributeNodeNS(Attr *newAttr)
1293                             throw(DOMException) = 0;
1295     /**
1296      *
1297      */
1298     virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI,
1299                                     const DOMString& localName) = 0;
1301     /**
1302      *
1303      */
1304     virtual bool hasAttribute(const DOMString& name) = 0;
1306     /**
1307      *
1308      */
1309     virtual bool hasAttributeNS(const DOMString& namespaceURI,
1310                         const DOMString& localName) = 0;
1312     /**
1313      *
1314      */
1315     virtual TypeInfo *getSchemaTypeInto() = 0;
1318     /**
1319      *
1320      */
1321     virtual void setIdAttribute(const DOMString &name,
1322                                 bool isId) throw (DOMException) = 0;
1324     /**
1325      *
1326      */
1327     virtual void setIdAttributeNS(const DOMString &namespaceURI,
1328                                   const DOMString &localName,
1329                                   bool isId) throw (DOMException) = 0;
1331     /**
1332      *
1333      */
1334     virtual void setIdAttributeNode(const Attr *idAttr,
1335                                     bool isId) throw (DOMException) = 0;
1337     //##################
1338     //# Non-API methods
1339     //##################
1341     /**
1342      *
1343      */
1344     virtual ~Element() {}
1346 };
1352 /*#########################################################################
1353 ## Text
1354 #########################################################################*/
1356 /**
1357  *
1358  */
1359 class Text : virtual public CharacterData
1361 public:
1363     /**
1364      *
1365      */
1366     virtual Text *splitText(unsigned long offset)
1367                     throw(DOMException) = 0;
1369     /**
1370      *
1371      */
1372     virtual bool getIsElementContentWhitespace()= 0;
1374     /**
1375      *
1376      */
1377     virtual DOMString getWholeText() = 0;
1380     /**
1381      *
1382      */
1383     virtual Text *replaceWholeText(const DOMString &content)
1384                                  throw(DOMException) = 0;
1386     //##################
1387     //# Non-API methods
1388     //##################
1391     /**
1392      *
1393      */
1394     virtual ~Text() {}
1396 };
1400 /*#########################################################################
1401 ## Comment
1402 #########################################################################*/
1404 /**
1405  *
1406  */
1407 class Comment : virtual public CharacterData
1409 public:
1411     //##################
1412     //# Non-API methods
1413     //##################
1416     /**
1417      *
1418      */
1419     virtual ~Comment() {}
1422 };
1426 /*#########################################################################
1427 ## TypeInfo
1428 #########################################################################*/
1430 /**
1431  *
1432  */
1433 class TypeInfo
1435 public:
1437     /**
1438      *
1439      */
1440     virtual DOMString getTypeName() =0;
1442     /**
1443      *
1444      */
1445     virtual DOMString getTypeNamespace() =0;
1447     typedef enum
1448         {
1449         DERIVATION_RESTRICTION = 0x00000001,
1450         DERIVATION_EXTENSION   = 0x00000002,
1451         DERIVATION_UNION       = 0x00000004,
1452         DERIVATION_LIST        = 0x00000008
1453         } DerivationMethod;
1456     /**
1457      *
1458      */
1459     virtual bool isDerivedFrom(const DOMString &typeNamespaceArg,
1460                                const DOMString &typeNameArg,
1461                                DerivationMethod derivationMethod) =0;
1463     //##################
1464     //# Non-API methods
1465     //##################
1468     /**
1469      *
1470      */
1471     virtual ~TypeInfo() {}
1473 };
1478 /*#########################################################################
1479 ## UserDataHandler
1480 #########################################################################*/
1482 /**
1483  *
1484  */
1485 class UserDataHandler
1487 public:
1489     typedef enum
1490         {
1491         NODE_CLONED     = 1,
1492         NODE_IMPORTED   = 2,
1493         NODE_DELETED    = 3,
1494         NODE_RENAMED    = 4,
1495         NODE_ADOPTED    = 5
1496         } OperationType;
1499     /**
1500      *
1501      */
1502     virtual  void handle(unsigned short operation,
1503                          const DOMString &key,
1504                          const DOMUserData *data,
1505                          const Node *src,
1506                          const Node *dst) =0;
1508     //##################
1509     //# Non-API methods
1510     //##################
1513     /**
1514      *
1515      */
1516     virtual ~UserDataHandler() {}
1518 };
1521 /*#########################################################################
1522 ## DOMError
1523 #########################################################################*/
1525 /**
1526  *
1527  */
1528 class DOMError
1530 public:
1532     typedef enum
1533         {
1534         SEVERITY_WARNING     = 1,
1535         SEVERITY_ERROR       = 2,
1536         SEVERITY_FATAL_ERROR = 3
1537         } ErrorSeverity;
1540     /**
1541      *
1542      */
1543     virtual unsigned short getSeverity() =0;
1545     /**
1546      *
1547      */
1548     virtual DOMString getMessage() =0;
1550     /**
1551      *
1552      */
1553     virtual DOMString getType() =0;
1555     /**
1556      *
1557      */
1558     virtual DOMObject *getRelatedException() =0;
1560     /**
1561      *
1562      */
1563     virtual DOMObject *getRelatedData() =0;
1565     /**
1566      *
1567      */
1568     virtual DOMLocator *getLocation() =0;
1571     //##################
1572     //# Non-API methods
1573     //##################
1576     /**
1577      *
1578      */
1579     virtual ~DOMError() {}
1581 };
1584 /*#########################################################################
1585 ## DOMErrorHandler
1586 #########################################################################*/
1588 /**
1589  *
1590  */
1591 class DOMErrorHandler
1593 public:
1594     /**
1595      *
1596      */
1597     virtual bool handleError(const DOMError *error) =0;
1599     //##################
1600     //# Non-API methods
1601     //##################
1604     /**
1605      *
1606      */
1607     virtual ~DOMErrorHandler() {}
1609 };
1613 /*#########################################################################
1614 ## DOMLocator
1615 #########################################################################*/
1617 /**
1618  *
1619  */
1620 class DOMLocator
1622 public:
1624     /**
1625      *
1626      */
1627     virtual long getLineNumber() =0;
1629     /**
1630      *
1631      */
1632     virtual long getColumnNumber() =0;
1634     /**
1635      *
1636      */
1637     virtual long getByteOffset() =0;
1639     /**
1640      *
1641      */
1642     virtual long getUtf16Offset() =0;
1645     /**
1646      *
1647      */
1648     virtual Node *getRelatedNode() =0;
1651     /**
1652      *
1653      */
1654     virtual DOMString getUri() =0;
1656     //##################
1657     //# Non-API methods
1658     //##################
1660     /**
1661      *
1662      */
1663     virtual ~DOMLocator() {}
1664 };
1667 /*#########################################################################
1668 ## DOMConfiguration
1669 #########################################################################*/
1671 /**
1672  *
1673  */
1674 class DOMConfiguration
1676 public:
1678     /**
1679      *
1680      */
1681     virtual void setParameter(const DOMString &name,
1682                               const DOMUserData *value) throw (DOMException) =0;
1684     /**
1685      *
1686      */
1687     virtual DOMUserData *getParameter(const DOMString &name)
1688                                       throw (DOMException) =0;
1690     /**
1691      *
1692      */
1693     virtual bool canSetParameter(const DOMString &name,
1694                                  const DOMUserData *data) =0;
1696     /**
1697      *
1698      */
1699     virtual DOMStringList *getParameterNames() =0;
1701     //##################
1702     //# Non-API methods
1703     //##################
1706     /**
1707      *
1708      */
1709     virtual ~DOMConfiguration() {}
1711 };
1718 /*#########################################################################
1719 ## CDATASection
1720 #########################################################################*/
1721 /**
1722  *
1723  */
1724 class CDATASection : virtual public Text
1726 public:
1728     //##################
1729     //# Non-API methods
1730     //##################
1733     /**
1734      *
1735      */
1736     virtual ~CDATASection() {}
1738 };
1743 /*#########################################################################
1744 ## DocumentType
1745 #########################################################################*/
1747 /**
1748  *
1749  */
1750 class DocumentType : virtual public Node
1752 public:
1754     /**
1755      *
1756      */
1757     virtual DOMString getName() = 0;
1759     /**
1760      *
1761      */
1762     virtual NamedNodeMap getEntities() = 0;
1764     /**
1765      *
1766      */
1767     virtual NamedNodeMap getNotations() = 0;
1769     /**
1770      *
1771      */
1772     virtual DOMString getPublicId() = 0;
1774     /**
1775      *
1776      */
1777     virtual DOMString getSystemId() = 0;
1779     /**
1780      *
1781      */
1782     virtual DOMString getInternalSubset() = 0;
1784     //##################
1785     //# Non-API methods
1786     //##################
1788     /**
1789      *
1790      */
1791     virtual ~DocumentType() {}
1793 };
1799 /*#########################################################################
1800 ## Notation
1801 #########################################################################*/
1803 /**
1804  *
1805  */
1806 class Notation : virtual public Node
1808 public:
1810     /**
1811      *
1812      */
1813     virtual DOMString getPublicId() = 0;
1815     /**
1816      *
1817      */
1818     virtual DOMString getSystemId() = 0;
1820     //##################
1821     //# Non-API methods
1822     //##################
1825     /**
1826      *
1827      */
1828     virtual ~Notation() {}
1829 };
1836 /*#########################################################################
1837 ## Entity
1838 #########################################################################*/
1840 /**
1841  *
1842  */
1843 class Entity : virtual public Node
1845 public:
1847     /**
1848      *
1849      */
1850     virtual DOMString getPublicId() = 0;
1852     /**
1853      *
1854      */
1855     virtual DOMString getSystemId() = 0;
1857     /**
1858      *
1859      */
1860     virtual DOMString getNotationName() = 0;
1862     /**
1863      *
1864      */
1865     virtual DOMString getInputEncoding() = 0;
1867     /**
1868      *
1869      */
1870     virtual DOMString getXmlEncoding() = 0;
1872     /**
1873      *
1874      */
1875     virtual DOMString getXmlVersion() = 0;
1877     //##################
1878     //# Non-API methods
1879     //##################
1882     /**
1883      *
1884      */
1885     virtual ~Entity() {}
1886 };
1892 /*#########################################################################
1893 ## EntityReference
1894 #########################################################################*/
1895 /**
1896  *
1897  */
1898 class EntityReference : virtual public Node
1900 public:
1903     //##################
1904     //# Non-API methods
1905     //##################
1907     /**
1908      *
1909      */
1910     virtual ~EntityReference() {}
1911 };
1917 /*#########################################################################
1918 ## ProcessingInstruction
1919 #########################################################################*/
1921 /**
1922  *
1923  */
1924 class ProcessingInstruction : virtual public Node
1926 public:
1928     /**
1929      *
1930      */
1931     virtual DOMString getTarget() = 0;
1933     /**
1934      *
1935      */
1936     virtual DOMString getData() = 0;
1938     /**
1939      *
1940      */
1941    virtual void setData(const DOMString& val) throw(DOMException) = 0;
1943     //##################
1944     //# Non-API methods
1945     //##################
1948     /**
1949      *
1950      */
1951     virtual ~ProcessingInstruction() {}
1953 };
1959 /*#########################################################################
1960 ## DocumentFragment
1961 #########################################################################*/
1962 /**
1963  *
1964  */
1965 class DocumentFragment : virtual public Node
1967 public:
1969     //##################
1970     //# Non-API methods
1971     //##################
1974     /**
1975      *
1976      */
1977     virtual ~DocumentFragment() {}
1978 };
1985 /*#########################################################################
1986 ## Document
1987 #########################################################################*/
1989 /**
1990  *
1991  */
1992 class Document : virtual public Node
1994 public:
1996     /**
1997      *
1998      */
1999     virtual DocumentType *getDoctype() = 0;
2001     /**
2002      *
2003      */
2004     virtual DOMImplementation *getImplementation() = 0;
2006     /**
2007      *
2008      */
2009     virtual Element *getDocumentElement() = 0;
2011     /**
2012      *
2013      */
2014     virtual Element *createElement(const DOMString& tagName)
2015                            throw(DOMException) = 0;
2017     /**
2018      *
2019      */
2020     virtual DocumentFragment *createDocumentFragment() = 0;
2022     /**
2023      *
2024      */
2025     virtual Text *createTextNode(const DOMString& data) = 0;
2027     /**
2028      *
2029      */
2030     virtual Comment  *createComment(const DOMString& data) = 0;
2032     /**
2033      *
2034      */
2035     virtual CDATASection *createCDATASection(const DOMString& data)
2036                                      throw(DOMException) = 0;
2038     /**
2039      *
2040      */
2041     virtual ProcessingInstruction *createProcessingInstruction(const DOMString& target,
2042                                                        const DOMString& data)
2043                                                        throw(DOMException) = 0;
2045     /**
2046      *
2047      */
2048     virtual Attr *createAttribute(const DOMString& name)
2049                           throw(DOMException) = 0;
2051     /**
2052      *
2053      */
2054     virtual EntityReference *createEntityReference(const DOMString& name)
2055                                            throw(DOMException) = 0;
2057     /**
2058      *
2059      */
2060     virtual NodeList getElementsByTagName(const DOMString& tagname) = 0;
2063     /**
2064      *
2065      */
2066     virtual Node *importNode(const Node *importedNode,
2067                      bool deep)
2068                      throw(DOMException) = 0;
2070     /**
2071      *
2072      */
2073     virtual Element *createElementNS(const DOMString& namespaceURI,
2074                              const DOMString& qualifiedName)
2075                              throw(DOMException) = 0;
2077     /**
2078      *
2079      */
2080     virtual Attr *createAttributeNS(const DOMString& namespaceURI,
2081                             const DOMString& qualifiedName)
2082                             throw(DOMException) = 0;
2084     /**
2085      *
2086      */
2087     virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI,
2088                                      const DOMString& localName) = 0;
2090     /**
2091      *
2092      */
2093     virtual Element *getElementById(const DOMString& elementId) = 0;
2096     /**
2097      *
2098      */
2099     virtual DOMString getInputEncoding() = 0;
2102     /**
2103      *
2104      */
2105     virtual DOMString getXmlEncoding() = 0;
2107     /**
2108      *
2109      */
2110     virtual bool getXmlStandalone() = 0;
2112     /**
2113      *
2114      */
2115     virtual void setXmlStandalone(bool val) throw (DOMException) = 0;
2117     /**
2118      *
2119      */
2120     virtual DOMString getXmlVersion() = 0;
2122     /**
2123      *
2124      */
2125     virtual void setXmlVersion(const DOMString &version) throw (DOMException) = 0;
2127     /**
2128      *
2129      */
2130     virtual bool getStrictErrorChecking() = 0;
2132     /**
2133      *
2134      */
2135     virtual void setStrictErrorChecking(bool val) = 0;
2138     /**
2139      *
2140      */
2141     virtual DOMString getDocumentURI() = 0;
2143     /**
2144      *
2145      */
2146     virtual void setDocumentURI(const DOMString &uri) = 0;
2148     /**
2149      *
2150      */
2151     virtual Node *adoptNode(const Node *source) throw (DOMException) = 0;
2153     /**
2154      *
2155      */
2156     virtual DOMConfiguration *getDomConfig() = 0;
2158     /**
2159      *
2160      */
2161     virtual void normalizeDocument() = 0;
2163     /**
2164      *
2165      */
2166     virtual Node *renameNode(const Node *n,
2167                              const DOMString &namespaceURI,
2168                              const DOMString &qualifiedName)
2169                              throw (DOMException) = 0;
2172     //##################
2173     //# Non-API methods
2174     //##################
2176     /**
2177      *
2178      */
2179     virtual ~Document() {}
2181 };
2193 }  //namespace dom
2194 }  //namespace w3c
2195 }  //namespace org
2198 #endif // __DOM_H__
2201 /*#########################################################################
2202 ## E N D    O F    F I L E
2203 #########################################################################*/