Code

Rework Stack class to TokenExecutor, to support an Axis stack
[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     /**
886      *
887      */
888     virtual void clear()
889         {
890         nodes.clear();
891         }
893 protected:
895 friend class NodeImpl;
896 friend class ElementImpl;
898     /*
899      *
900      */
901     virtual void add(const Node *node)
902         {
903         nodes.push_back((Node *)node);
904         }
906 protected:
908     std::vector<Node *> nodes;
910 };
915 /*#########################################################################
916 ## NamedNodeMap
917 #########################################################################*/
919 class NamedNodeMapEntry
921 public:
922     NamedNodeMapEntry(const DOMString &theNamespaceURI,
923                       const DOMString &theName,
924                       const Node      *theNode)
925         {
926         namespaceURI = theNamespaceURI;
927         name         = theName;
928         node         = (Node *)theNode;
929         }
930     NamedNodeMapEntry(const NamedNodeMapEntry &other)
931         {
932         assign(other);
933         }
934     NamedNodeMapEntry &operator=(const NamedNodeMapEntry &other)
935         {
936         assign(other);
937         return *this;
938         }
939     virtual ~NamedNodeMapEntry()
940         {
941         }
942     void assign(const NamedNodeMapEntry &other)
943         {
944         namespaceURI = other.namespaceURI;
945         name         = other.name;
946         node         = other.node;
947         }
948     DOMString namespaceURI;
949     DOMString name;
950     Node      *node;
951 };
953 /**
954  *
955  */
956 class NamedNodeMap
958 public:
960     /**
961      *
962      */
963     virtual Node *getNamedItem(const DOMString& name)
964         {
965         std::vector<NamedNodeMapEntry>::iterator iter;
966         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
967             {
968             if (iter->name == name)
969                 {
970                 Node *node = iter->node;
971                 return node;
972                 }
973             }
974         return NULL;
975         }
977     /**
978      *
979      */
980     virtual Node *setNamedItem(Node *arg) throw(DOMException)
981         {
982         if (!arg)
983             return NULL;
984         DOMString namespaceURI = arg->getNamespaceURI();
985         DOMString name         = arg->getNodeName();
986         std::vector<NamedNodeMapEntry>::iterator iter;
987         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
988             {
989             if (iter->name == name)
990                 {
991                 Node *node = iter->node;
992                 iter->node = arg;
993                 return node;
994                 }
995             }
996         NamedNodeMapEntry entry(namespaceURI, name, arg);
997         entries.push_back(entry);
998         return arg;
999         }
1002     /**
1003      *
1004      */
1005     virtual Node *removeNamedItem(const DOMString& name) throw(DOMException)
1006         {
1007         std::vector<NamedNodeMapEntry>::iterator iter;
1008         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1009             {
1010             if (iter->name == name)
1011                 {
1012                 Node *node = iter->node;
1013                 entries.erase(iter);
1014                 return node;
1015                 }
1016             }
1017         return NULL;
1018         }
1020     /**
1021      *
1022      */
1023     virtual Node *item(unsigned long index)
1024         {
1025         if (index>=entries.size())
1026             return NULL;
1027         return entries[index].node;
1028         }
1030     /**
1031      *
1032      */
1033     virtual unsigned long getLength()
1034         {
1035         return (unsigned long)entries.size();
1036         }
1038     /**
1039      *
1040      */
1041     virtual Node *getNamedItemNS(const DOMString& namespaceURI,
1042                                  const DOMString& localName)
1043         {
1044         std::vector<NamedNodeMapEntry>::iterator iter;
1045         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1046             {
1047             if (iter->namespaceURI == namespaceURI && iter->name == localName)
1048                 {
1049                 Node *node = iter->node;
1050                 return node;
1051                 }
1052             }
1053         return NULL;
1054         }
1056     /**
1057      *
1058      */
1059     virtual Node *setNamedItemNS(Node *arg) throw(DOMException)
1060         {
1061         if (!arg)
1062             return NULL;
1063         DOMString namespaceURI = arg->getNamespaceURI();
1064         DOMString name         = arg->getNodeName();
1065         std::vector<NamedNodeMapEntry>::iterator iter;
1066         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1067             {
1068             if (iter->namespaceURI == namespaceURI && iter->name == name)
1069                 {
1070                 Node *node = iter->node;
1071                 iter->node = arg;
1072                 return node;
1073                 }
1074             }
1075         NamedNodeMapEntry entry(namespaceURI, name, arg);
1076         entries.push_back(entry);
1077         return arg;
1078         }
1080     /**
1081      *
1082      */
1083     virtual Node *removeNamedItemNS(const DOMString& namespaceURI,
1084                                     const DOMString& localName)
1085                                     throw(DOMException)
1086         {
1087         std::vector<NamedNodeMapEntry>::iterator iter;
1088         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1089             {
1090             if (iter->namespaceURI == namespaceURI && iter->name == localName)
1091                 {
1092                 Node *node = iter->node;
1093                 entries.erase(iter);
1094                 return node;
1095                 }
1096             }
1097         return NULL;
1098         }
1100     //##################
1101     //# Non-API methods
1102     //##################
1104     /**
1105      *
1106      */
1107     NamedNodeMap() {}
1110     /**
1111      *
1112      */
1113     NamedNodeMap(const NamedNodeMap &other)
1114         {
1115         entries = other.entries;
1116         }
1118     /**
1119      *
1120      */
1121     NamedNodeMap &operator=(const NamedNodeMap &other)
1122         {
1123         entries = other.entries;
1124         return *this;
1125         }
1128     /**
1129      *
1130      */
1131     virtual ~NamedNodeMap() {}
1133 protected:
1135     std::vector<NamedNodeMapEntry> entries;
1137 };
1142 /*#########################################################################
1143 ## CharacterData
1144 #########################################################################*/
1146 /**
1147  *
1148  */
1149 class CharacterData : virtual public Node
1151 public:
1153     /**
1154      *
1155      */
1156     virtual DOMString getData() throw(DOMException) = 0;
1158     /**
1159      *
1160      */
1161     virtual void setData(const DOMString& val) throw(DOMException) = 0;
1163     /**
1164      *
1165      */
1166     virtual unsigned long getLength() = 0;
1168     /**
1169      *
1170      */
1171     virtual DOMString substringData(unsigned long offset,
1172                             unsigned long count)
1173                             throw(DOMException) = 0;
1175     /**
1176      *
1177      */
1178     virtual void appendData(const DOMString& arg) throw(DOMException) = 0;
1180     /**
1181      *
1182      */
1183     virtual void insertData(unsigned long offset,
1184                     const DOMString& arg)
1185                     throw(DOMException) = 0;
1187     /**
1188      *
1189      */
1190     virtual void deleteData(unsigned long offset,
1191                     unsigned long count)
1192                     throw(DOMException) = 0;
1194     /**
1195      *
1196      */
1197     virtual void  replaceData(unsigned long offset,
1198                       unsigned long count,
1199                       const DOMString& arg)
1200                       throw(DOMException) = 0;
1203     //##################
1204     //# Non-API methods
1205     //##################
1208     /**
1209      *
1210      */
1211     virtual ~CharacterData() {}
1213 };
1219 /*#########################################################################
1220 ## Attr
1221 #########################################################################*/
1223 /**
1224  *
1225  */
1226 class Attr : virtual public Node
1228 public:
1230     /**
1231      *
1232      */
1233     virtual DOMString getName() = 0;
1235     /**
1236      *
1237      */
1238     virtual bool getSpecified() = 0;
1240     /**
1241      *
1242      */
1243     virtual DOMString getValue() = 0;
1245     /**
1246      *
1247      */
1248     virtual void setValue(const DOMString& val) throw(DOMException) = 0;
1250     /**
1251      *
1252      */
1253     virtual Element *getOwnerElement() = 0;
1256     /**
1257      *
1258      */
1259     virtual TypeInfo *getSchemaTypeInfo() = 0;
1262     /**
1263      *
1264      */
1265     virtual bool getIsId() = 0;
1267     //##################
1268     //# Non-API methods
1269     //##################
1272     /**
1273      *
1274      */
1275     virtual ~Attr() {}
1277 };
1283 /*#########################################################################
1284 ## Element
1285 #########################################################################*/
1287 /**
1288  *
1289  */
1290 class Element : virtual public Node
1292 public:
1295     /**
1296      *
1297      */
1298     virtual DOMString getTagName() = 0;
1300     /**
1301      *
1302      */
1303     virtual DOMString getAttribute(const DOMString& name) = 0;
1305     /**
1306      *
1307      */
1308     virtual void setAttribute(const DOMString& name,
1309                       const DOMString& value)
1310                       throw(DOMException) = 0;
1312     /**
1313      *
1314      */
1315     virtual void removeAttribute(const DOMString& name)
1316                          throw(DOMException) = 0;
1318     /**
1319      *
1320      */
1321     virtual Attr *getAttributeNode(const DOMString& name) = 0;
1323     /**
1324      *
1325      */
1326     virtual Attr *setAttributeNode(Attr *newAttr)
1327                           throw(DOMException) = 0;
1329     /**
1330      *
1331      */
1332     virtual Attr *removeAttributeNode(Attr *oldAttr)
1333                              throw(DOMException) = 0;
1335     /**
1336      *
1337      */
1338     virtual NodeList getElementsByTagName(const DOMString& name) = 0;
1340     /**
1341      *
1342      */
1343     virtual DOMString getAttributeNS(const DOMString& namespaceURI,
1344                              const DOMString& localName) = 0;
1346     /**
1347      *
1348      */
1349     virtual void setAttributeNS(const DOMString& namespaceURI,
1350                         const DOMString& qualifiedName,
1351                         const DOMString& value)
1352                         throw(DOMException) = 0;
1354     /**
1355      *
1356      */
1357     virtual void removeAttributeNS(const DOMString& namespaceURI,
1358                            const DOMString& localName)
1359                            throw(DOMException) = 0;
1361     /**
1362      *
1363      */
1364     virtual Attr *getAttributeNodeNS(const DOMString& namespaceURI,
1365                             const DOMString& localName) = 0;
1367     /**
1368      *
1369      */
1370     virtual Attr *setAttributeNodeNS(Attr *newAttr)
1371                             throw(DOMException) = 0;
1373     /**
1374      *
1375      */
1376     virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI,
1377                                     const DOMString& localName) = 0;
1379     /**
1380      *
1381      */
1382     virtual bool hasAttribute(const DOMString& name) = 0;
1384     /**
1385      *
1386      */
1387     virtual bool hasAttributeNS(const DOMString& namespaceURI,
1388                         const DOMString& localName) = 0;
1390     /**
1391      *
1392      */
1393     virtual TypeInfo *getSchemaTypeInto() = 0;
1396     /**
1397      *
1398      */
1399     virtual void setIdAttribute(const DOMString &name,
1400                                 bool isId) throw (DOMException) = 0;
1402     /**
1403      *
1404      */
1405     virtual void setIdAttributeNS(const DOMString &namespaceURI,
1406                                   const DOMString &localName,
1407                                   bool isId) throw (DOMException) = 0;
1409     /**
1410      *
1411      */
1412     virtual void setIdAttributeNode(const Attr *idAttr,
1413                                     bool isId) throw (DOMException) = 0;
1415     //##################
1416     //# Non-API methods
1417     //##################
1419     /**
1420      *
1421      */
1422     virtual ~Element() {}
1424 };
1430 /*#########################################################################
1431 ## Text
1432 #########################################################################*/
1434 /**
1435  *
1436  */
1437 class Text : virtual public CharacterData
1439 public:
1441     /**
1442      *
1443      */
1444     virtual Text *splitText(unsigned long offset)
1445                     throw(DOMException) = 0;
1447     /**
1448      *
1449      */
1450     virtual bool getIsElementContentWhitespace()= 0;
1452     /**
1453      *
1454      */
1455     virtual DOMString getWholeText() = 0;
1458     /**
1459      *
1460      */
1461     virtual Text *replaceWholeText(const DOMString &content)
1462                                  throw(DOMException) = 0;
1464     //##################
1465     //# Non-API methods
1466     //##################
1469     /**
1470      *
1471      */
1472     virtual ~Text() {}
1474 };
1478 /*#########################################################################
1479 ## Comment
1480 #########################################################################*/
1482 /**
1483  *
1484  */
1485 class Comment : virtual public CharacterData
1487 public:
1489     //##################
1490     //# Non-API methods
1491     //##################
1494     /**
1495      *
1496      */
1497     virtual ~Comment() {}
1500 };
1504 /*#########################################################################
1505 ## TypeInfo
1506 #########################################################################*/
1508 /**
1509  *
1510  */
1511 class TypeInfo
1513 public:
1515     /**
1516      *
1517      */
1518     virtual DOMString getTypeName() =0;
1520     /**
1521      *
1522      */
1523     virtual DOMString getTypeNamespace() =0;
1525     typedef enum
1526         {
1527         DERIVATION_RESTRICTION = 0x00000001,
1528         DERIVATION_EXTENSION   = 0x00000002,
1529         DERIVATION_UNION       = 0x00000004,
1530         DERIVATION_LIST        = 0x00000008
1531         } DerivationMethod;
1534     /**
1535      *
1536      */
1537     virtual bool isDerivedFrom(const DOMString &typeNamespaceArg,
1538                                const DOMString &typeNameArg,
1539                                DerivationMethod derivationMethod) =0;
1541     //##################
1542     //# Non-API methods
1543     //##################
1546     /**
1547      *
1548      */
1549     virtual ~TypeInfo() {}
1551 };
1556 /*#########################################################################
1557 ## UserDataHandler
1558 #########################################################################*/
1560 /**
1561  *
1562  */
1563 class UserDataHandler
1565 public:
1567     typedef enum
1568         {
1569         NODE_CLONED     = 1,
1570         NODE_IMPORTED   = 2,
1571         NODE_DELETED    = 3,
1572         NODE_RENAMED    = 4,
1573         NODE_ADOPTED    = 5
1574         } OperationType;
1577     /**
1578      *
1579      */
1580     virtual  void handle(unsigned short operation,
1581                          const DOMString &key,
1582                          const DOMUserData *data,
1583                          const Node *src,
1584                          const Node *dst) =0;
1586     //##################
1587     //# Non-API methods
1588     //##################
1591     /**
1592      *
1593      */
1594     virtual ~UserDataHandler() {}
1596 };
1599 /*#########################################################################
1600 ## DOMError
1601 #########################################################################*/
1603 /**
1604  *
1605  */
1606 class DOMError
1608 public:
1610     typedef enum
1611         {
1612         DOMERROR_SEVERITY_WARNING     = 1,
1613         DOMERROR_SEVERITY_ERROR       = 2,
1614         DOMERROR_SEVERITY_FATAL_ERROR = 3
1615         } ErrorSeverity;
1618     /**
1619      *
1620      */
1621     virtual unsigned short getSeverity() =0;
1623     /**
1624      *
1625      */
1626     virtual DOMString getMessage() =0;
1628     /**
1629      *
1630      */
1631     virtual DOMString getType() =0;
1633     /**
1634      *
1635      */
1636     virtual DOMObject *getRelatedException() =0;
1638     /**
1639      *
1640      */
1641     virtual DOMObject *getRelatedData() =0;
1643     /**
1644      *
1645      */
1646     virtual DOMLocator *getLocation() =0;
1649     //##################
1650     //# Non-API methods
1651     //##################
1654     /**
1655      *
1656      */
1657     virtual ~DOMError() {}
1659 };
1662 /*#########################################################################
1663 ## DOMErrorHandler
1664 #########################################################################*/
1666 /**
1667  *
1668  */
1669 class DOMErrorHandler
1671 public:
1672     /**
1673      *
1674      */
1675     virtual bool handleError(const DOMError *error) =0;
1677     //##################
1678     //# Non-API methods
1679     //##################
1682     /**
1683      *
1684      */
1685     virtual ~DOMErrorHandler() {}
1687 };
1691 /*#########################################################################
1692 ## DOMLocator
1693 #########################################################################*/
1695 /**
1696  *
1697  */
1698 class DOMLocator
1700 public:
1702     /**
1703      *
1704      */
1705     virtual long getLineNumber() =0;
1707     /**
1708      *
1709      */
1710     virtual long getColumnNumber() =0;
1712     /**
1713      *
1714      */
1715     virtual long getByteOffset() =0;
1717     /**
1718      *
1719      */
1720     virtual long getUtf16Offset() =0;
1723     /**
1724      *
1725      */
1726     virtual Node *getRelatedNode() =0;
1729     /**
1730      *
1731      */
1732     virtual DOMString getUri() =0;
1734     //##################
1735     //# Non-API methods
1736     //##################
1738     /**
1739      *
1740      */
1741     virtual ~DOMLocator() {}
1742 };
1745 /*#########################################################################
1746 ## DOMConfiguration
1747 #########################################################################*/
1749 /**
1750  *
1751  */
1752 class DOMConfiguration
1754 public:
1756     /**
1757      *
1758      */
1759     virtual void setParameter(const DOMString &name,
1760                               const DOMUserData *value) throw (DOMException) =0;
1762     /**
1763      *
1764      */
1765     virtual DOMUserData *getParameter(const DOMString &name)
1766                                       throw (DOMException) =0;
1768     /**
1769      *
1770      */
1771     virtual bool canSetParameter(const DOMString &name,
1772                                  const DOMUserData *data) =0;
1774     /**
1775      *
1776      */
1777     virtual DOMStringList *getParameterNames() =0;
1779     //##################
1780     //# Non-API methods
1781     //##################
1784     /**
1785      *
1786      */
1787     virtual ~DOMConfiguration() {}
1789 };
1796 /*#########################################################################
1797 ## CDATASection
1798 #########################################################################*/
1799 /**
1800  *
1801  */
1802 class CDATASection : virtual public Text
1804 public:
1806     //##################
1807     //# Non-API methods
1808     //##################
1811     /**
1812      *
1813      */
1814     virtual ~CDATASection() {}
1816 };
1821 /*#########################################################################
1822 ## DocumentType
1823 #########################################################################*/
1825 /**
1826  *
1827  */
1828 class DocumentType : virtual public Node
1830 public:
1832     /**
1833      *
1834      */
1835     virtual DOMString getName() = 0;
1837     /**
1838      *
1839      */
1840     virtual NamedNodeMap getEntities() = 0;
1842     /**
1843      *
1844      */
1845     virtual NamedNodeMap getNotations() = 0;
1847     /**
1848      *
1849      */
1850     virtual DOMString getPublicId() = 0;
1852     /**
1853      *
1854      */
1855     virtual DOMString getSystemId() = 0;
1857     /**
1858      *
1859      */
1860     virtual DOMString getInternalSubset() = 0;
1862     //##################
1863     //# Non-API methods
1864     //##################
1866     /**
1867      *
1868      */
1869     virtual ~DocumentType() {}
1871 };
1877 /*#########################################################################
1878 ## Notation
1879 #########################################################################*/
1881 /**
1882  *
1883  */
1884 class Notation : virtual public Node
1886 public:
1888     /**
1889      *
1890      */
1891     virtual DOMString getPublicId() = 0;
1893     /**
1894      *
1895      */
1896     virtual DOMString getSystemId() = 0;
1898     //##################
1899     //# Non-API methods
1900     //##################
1903     /**
1904      *
1905      */
1906     virtual ~Notation() {}
1907 };
1914 /*#########################################################################
1915 ## Entity
1916 #########################################################################*/
1918 /**
1919  *
1920  */
1921 class Entity : virtual public Node
1923 public:
1925     /**
1926      *
1927      */
1928     virtual DOMString getPublicId() = 0;
1930     /**
1931      *
1932      */
1933     virtual DOMString getSystemId() = 0;
1935     /**
1936      *
1937      */
1938     virtual DOMString getNotationName() = 0;
1940     /**
1941      *
1942      */
1943     virtual DOMString getInputEncoding() = 0;
1945     /**
1946      *
1947      */
1948     virtual DOMString getXmlEncoding() = 0;
1950     /**
1951      *
1952      */
1953     virtual DOMString getXmlVersion() = 0;
1955     //##################
1956     //# Non-API methods
1957     //##################
1960     /**
1961      *
1962      */
1963     virtual ~Entity() {}
1964 };
1970 /*#########################################################################
1971 ## EntityReference
1972 #########################################################################*/
1973 /**
1974  *
1975  */
1976 class EntityReference : virtual public Node
1978 public:
1981     //##################
1982     //# Non-API methods
1983     //##################
1985     /**
1986      *
1987      */
1988     virtual ~EntityReference() {}
1989 };
1995 /*#########################################################################
1996 ## ProcessingInstruction
1997 #########################################################################*/
1999 /**
2000  *
2001  */
2002 class ProcessingInstruction : virtual public Node
2004 public:
2006     /**
2007      *
2008      */
2009     virtual DOMString getTarget() = 0;
2011     /**
2012      *
2013      */
2014     virtual DOMString getData() = 0;
2016     /**
2017      *
2018      */
2019    virtual void setData(const DOMString& val) throw(DOMException) = 0;
2021     //##################
2022     //# Non-API methods
2023     //##################
2026     /**
2027      *
2028      */
2029     virtual ~ProcessingInstruction() {}
2031 };
2037 /*#########################################################################
2038 ## DocumentFragment
2039 #########################################################################*/
2040 /**
2041  *
2042  */
2043 class DocumentFragment : virtual public Node
2045 public:
2047     //##################
2048     //# Non-API methods
2049     //##################
2052     /**
2053      *
2054      */
2055     virtual ~DocumentFragment() {}
2056 };
2063 /*#########################################################################
2064 ## Document
2065 #########################################################################*/
2067 /**
2068  *
2069  */
2070 class Document : virtual public Node
2072 public:
2074     /**
2075      *
2076      */
2077     virtual DocumentType *getDoctype() = 0;
2079     /**
2080      *
2081      */
2082     virtual DOMImplementation *getImplementation() = 0;
2084     /**
2085      *
2086      */
2087     virtual Element *getDocumentElement() = 0;
2089     /**
2090      *
2091      */
2092     virtual Element *createElement(const DOMString& tagName)
2093                            throw(DOMException) = 0;
2095     /**
2096      *
2097      */
2098     virtual DocumentFragment *createDocumentFragment() = 0;
2100     /**
2101      *
2102      */
2103     virtual Text *createTextNode(const DOMString& data) = 0;
2105     /**
2106      *
2107      */
2108     virtual Comment  *createComment(const DOMString& data) = 0;
2110     /**
2111      *
2112      */
2113     virtual CDATASection *createCDATASection(const DOMString& data)
2114                                      throw(DOMException) = 0;
2116     /**
2117      *
2118      */
2119     virtual ProcessingInstruction *createProcessingInstruction(const DOMString& target,
2120                                                        const DOMString& data)
2121                                                        throw(DOMException) = 0;
2123     /**
2124      *
2125      */
2126     virtual Attr *createAttribute(const DOMString& name)
2127                           throw(DOMException) = 0;
2129     /**
2130      *
2131      */
2132     virtual EntityReference *createEntityReference(const DOMString& name)
2133                                            throw(DOMException) = 0;
2135     /**
2136      *
2137      */
2138     virtual NodeList getElementsByTagName(const DOMString& tagname) = 0;
2141     /**
2142      *
2143      */
2144     virtual Node *importNode(const Node *importedNode,
2145                      bool deep)
2146                      throw(DOMException) = 0;
2148     /**
2149      *
2150      */
2151     virtual Element *createElementNS(const DOMString& namespaceURI,
2152                              const DOMString& qualifiedName)
2153                              throw(DOMException) = 0;
2155     /**
2156      *
2157      */
2158     virtual Attr *createAttributeNS(const DOMString& namespaceURI,
2159                             const DOMString& qualifiedName)
2160                             throw(DOMException) = 0;
2162     /**
2163      *
2164      */
2165     virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI,
2166                                      const DOMString& localName) = 0;
2168     /**
2169      *
2170      */
2171     virtual Element *getElementById(const DOMString& elementId) = 0;
2174     /**
2175      *
2176      */
2177     virtual DOMString getInputEncoding() = 0;
2180     /**
2181      *
2182      */
2183     virtual DOMString getXmlEncoding() = 0;
2185     /**
2186      *
2187      */
2188     virtual bool getXmlStandalone() = 0;
2190     /**
2191      *
2192      */
2193     virtual void setXmlStandalone(bool val) throw (DOMException) = 0;
2195     /**
2196      *
2197      */
2198     virtual DOMString getXmlVersion() = 0;
2200     /**
2201      *
2202      */
2203     virtual void setXmlVersion(const DOMString &version) throw (DOMException) = 0;
2205     /**
2206      *
2207      */
2208     virtual bool getStrictErrorChecking() = 0;
2210     /**
2211      *
2212      */
2213     virtual void setStrictErrorChecking(bool val) = 0;
2216     /**
2217      *
2218      */
2219     virtual DOMString getDocumentURI() = 0;
2221     /**
2222      *
2223      */
2224     virtual void setDocumentURI(const DOMString &uri) = 0;
2226     /**
2227      *
2228      */
2229     virtual Node *adoptNode(const Node *source) throw (DOMException) = 0;
2231     /**
2232      *
2233      */
2234     virtual DOMConfiguration *getDomConfig() = 0;
2236     /**
2237      *
2238      */
2239     virtual void normalizeDocument() = 0;
2241     /**
2242      *
2243      */
2244     virtual Node *renameNode(const Node *n,
2245                              const DOMString &namespaceURI,
2246                              const DOMString &qualifiedName)
2247                              throw (DOMException) = 0;
2250     //##################
2251     //# Non-API methods
2252     //##################
2254     /**
2255      *
2256      */
2257     virtual ~Document() {}
2259 };
2271 }  //namespace dom
2272 }  //namespace w3c
2273 }  //namespace org
2276 #endif // __DOM_H__
2279 /*#########################################################################
2280 ## E N D    O F    F I L E
2281 #########################################################################*/