Code

limit the smallest exponent in transforms; anything smaller is written as 0
[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     virtual ~DOMStringList() {}
268 protected:
270     /**
271      *
272      */
273     virtual void add(const DOMString &str)
274         {
275         strings.push_back(str);
276         }
278     std::vector<DOMString>strings;
280 };
284 /*#########################################################################
285 ## NameList
286 #########################################################################*/
287 class NamePair
289 public:
290     NamePair(const DOMString &theNamespaceURI, const DOMString &theName)
291         {
292         namespaceURI = theNamespaceURI;
293         name         = theName;
294         }
295     NamePair(const NamePair &other)
296         {
297         namespaceURI = other.namespaceURI;
298         name         = other.name;
299         }
300     virtual ~NamePair() {}
302     DOMString namespaceURI;
303     DOMString name;
304 };
308 class NameList
310 public:
312     /**
313      *
314      */
315     virtual DOMString getName(unsigned long index)
316         {
317         if (index>=namePairs.size())
318             return "";
319         return namePairs[index].name;
320         }
322     /**
323      *
324      */
325     virtual DOMString getNamespaceURI(unsigned long index)
326         {
327         if (index>=namePairs.size())
328             return "";
329         return namePairs[index].namespaceURI;
330         }
332     /**
333      *
334      */
335     virtual unsigned long getLength()
336         {
337         return (unsigned long)namePairs.size();
338         }
340     /**
341      *
342      */
343     virtual bool contains(const DOMString &name)
344         {
345         for (unsigned int i=0; i<namePairs.size() ; i++)
346             {
347             if (namePairs[i].name == name )
348                 return true;
349             }
350         return false;
351         }
353     /**
354      *
355      */
356     virtual bool containsNS(const DOMString namespaceURI,const DOMString &name)
357         {
358         for (unsigned int i=0; i<namePairs.size() ; i++)
359             {
360             if (namePairs[i].namespaceURI == namespaceURI ||
361                 namePairs[i].name         == name           )
362                 return true;
363             }
364         return false;
365         }
368     //##################
369     //# Non-API methods
370     //##################
372     /**
373      *
374      */
375     NameList() {}
377     /**
378      *
379      */
380     NameList(const NameList &other)
381         {
382         namePairs = other.namePairs;
383         }
385     /**
386      *
387      */
388     virtual ~NameList() {}
389 protected:
391     std::vector<NamePair> namePairs;
393 };
395 /*#########################################################################
396 ## DOMImplementationList
397 #########################################################################*/
399 class DOMImplementationList
401 public:
403     /**
404      *
405      */
406     virtual DOMImplementation *getDOMImplementation(unsigned long index)
407         {
408         if (index >implementations.size())
409             return NULL;
410         return implementations[index];
411         }
413     /**
414      *
415      */
416     virtual unsigned long getLength()
417         {
418         return (unsigned long) implementations.size();
419         }
424     //##################
425     //# Non-API methods
426     //##################
428     /**
429      *
430      */
431     DOMImplementationList() {}
434     /**
435      *
436      */
437     DOMImplementationList(const DOMImplementationList &other)
438         {
439         implementations = other.implementations;
440         }
442     /**
443      *
444      */
445     virtual ~DOMImplementationList() {}
447 protected:
449     std::vector<DOMImplementation *>implementations;
451 };
454 /*#########################################################################
455 ## DOMImplementationSource
456 #########################################################################*/
458 class DOMImplementationSource
460 public:
462     /**
463      *
464      */
465     virtual DOMImplementation *getDOMImplementation(const DOMString &features) = 0;
467     /**
468      *
469      */
470     virtual DOMImplementationList getDOMImplementationList(const DOMString &features) = 0;
472     //##################
473     //# Non-API methods
474     //##################
476     /**
477      *
478      */
479     virtual ~DOMImplementationSource() {}
481 };
487 /*#########################################################################
488 ## DOMImplementation
489 #########################################################################*/
490 /**
491  *
492  */
493 class DOMImplementation
495 public:
496     /**
497      *
498      */
499     virtual bool hasFeature(const DOMString& feature, const DOMString& version) = 0;
502     /**
503      *
504      */
505     virtual DocumentType *createDocumentType(const DOMString& qualifiedName,
506                                      const DOMString& publicId,
507                                      const DOMString& systemId)
508                                      throw(DOMException) = 0;
510     /**
511      *
512      */
513     virtual Document *createDocument(const DOMString& namespaceURI,
514                              const DOMString& qualifiedName,
515                              DocumentType *doctype)
516                              throw(DOMException) = 0;
517     /**
518      *
519      */
520     virtual DOMObject *getFeature(const DOMString& feature,
521                              const DOMString& version) = 0;
524     //##################
525     //# Non-API methods
526     //##################
528     /**
529      *
530      */
531     virtual ~DOMImplementation() {}
533 };
538 /*#########################################################################
539 ## Node
540 #########################################################################*/
542 /**
543  *
544  */
545 class Node
547 public:
549     typedef enum
550         {
551         ELEMENT_NODE                   = 1,
552         ATTRIBUTE_NODE                 = 2,
553         TEXT_NODE                      = 3,
554         CDATA_SECTION_NODE             = 4,
555         ENTITY_REFERENCE_NODE          = 5,
556         ENTITY_NODE                    = 6,
557         PROCESSING_INSTRUCTION_NODE    = 7,
558         COMMENT_NODE                   = 8,
559         DOCUMENT_NODE                  = 9,
560         DOCUMENT_TYPE_NODE             = 10,
561         DOCUMENT_FRAGMENT_NODE         = 11,
562         NOTATION_NODE                  = 12
563         } NodeType;
565     /**
566      *
567      */
568     virtual DOMString getNodeName() = 0;
570     /**
571      *
572      */
573     virtual DOMString getNodeValue() throw (DOMException) = 0;
575     /**
576      *
577      */
578     virtual void setNodeValue(const DOMString& val) throw (DOMException) = 0;
580     /**
581      *
582      */
583     virtual unsigned short getNodeType() = 0;
585     /**
586      *
587      */
588     virtual Node *getParentNode() = 0;
590     /**
591      *
592      */
593     virtual NodeList getChildNodes() = 0;
595     /**
596      *
597      */
598     virtual Node *getFirstChild() = 0;
600     /**
601      *
602      */
603     virtual Node *getLastChild() = 0;
605     /**
606      *
607      */
608     virtual Node *getPreviousSibling() = 0;
610     /**
611      *
612      */
613     virtual Node *getNextSibling() = 0;
615     /**
616      *
617      */
618     virtual NamedNodeMap &getAttributes() = 0;
621     /**
622      *
623      */
624     virtual Document *getOwnerDocument() = 0;
626     /**
627      *
628      */
629     virtual Node *insertBefore(const Node *newChild,
630                        const Node *refChild)
631                        throw(DOMException) = 0;
633     /**
634      *
635      */
636     virtual Node *replaceChild(const Node *newChild,
637                        const Node *oldChild)
638                        throw(DOMException) = 0;
640     /**
641      *
642      */
643     virtual Node *removeChild(const Node *oldChild)
644                       throw(DOMException) = 0;
646     /**
647      *
648      */
649     virtual Node *appendChild(const Node *newChild)
650                       throw(DOMException) = 0;
652     /**
653      *
654      */
655     virtual bool hasChildNodes() = 0;
657     /**
658      *
659      */
660     virtual Node *cloneNode(bool deep) = 0;
662     /**
663      *
664      */
665     virtual void normalize() = 0;
667     /**
668      *
669      */
670     virtual bool isSupported(const DOMString& feature,
671                      const DOMString& version) = 0;
673     /**
674      *
675      */
676     virtual DOMString getNamespaceURI() = 0;
678     /**
679      *
680      */
681     virtual DOMString getPrefix() = 0;
683     /**
684      *
685      */
686     virtual void setPrefix(const DOMString& val) throw(DOMException) = 0;
688     /**
689      *
690      */
691     virtual DOMString getLocalName() = 0;
693     /**
694      *
695      */
696     virtual bool hasAttributes() = 0;
698     /**
699      *
700      */
701     virtual DOMString getBaseURI() = 0;
703     typedef enum
704         {
705         DOCUMENT_POSITION_DISCONNECTED            = 0x01,
706         DOCUMENT_POSITION_PRECEDING               = 0x02,
707         DOCUMENT_POSITION_FOLLOWING               = 0x04,
708         DOCUMENT_POSITION_CONTAINS                = 0x08,
709         DOCUMENT_POSITION_CONTAINED_BY            = 0x10,
710         DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20
711         } DocumentPosition;
714     /**
715      *
716      */
717     virtual unsigned short compareDocumentPosition(const Node *other) = 0;
719     /**
720      *
721      */
722     virtual DOMString getTextContext() throw(DOMException) = 0;
725     /**
726      *
727      */
728     virtual void setTextContext(const DOMString &val) throw(DOMException) = 0;
731     /**
732      *
733      */
734     virtual DOMString lookupPrefix(const DOMString &namespaceURI) =0;
737     /**
738      *
739      */
740     virtual bool isDefaultNamespace(const DOMString &namespaceURI) =0;
743     /**
744      *
745      */
746     virtual DOMString lookupNamespaceURI(const DOMString &prefix) =0;
749     /**
750      *
751      */
752     virtual bool isEqualNode(const Node *node) =0;
756     /**
757      *
758      */
759     virtual DOMObject *getFeature(const DOMString &feature,
760                                  const DOMString &version) =0;
762     /**
763      *
764      */
765     virtual DOMUserData *setUserData(const DOMString &key,
766                                      const DOMUserData *data,
767                                      const UserDataHandler *handler) =0;
770     /**
771      *
772      */
773     virtual DOMUserData *getUserData(const DOMString &namespaceURI) =0;
775     //##################
776     //# Non-API methods
777     //##################
780     /**
781      *
782      */
783     virtual ~Node() {}
788 };
792 /*#########################################################################
793 ## NodeList
794 #########################################################################*/
796 /**
797  *
798  */
799 class NodeList
801 public:
802     /**
803      *
804      */
805     virtual Node *item(unsigned long index)
806         {
807         if (index>=nodes.size())
808             return NULL;
809         return nodes[index];
810         }
812     /**
813      *
814      */
815     virtual unsigned long getLength()
816         {
817         return (unsigned long) nodes.size();
818         }
820     //##################
821     //# Non-API methods
822     //##################
825     /**
826      *
827      */
828     NodeList() {}
830     /**
831      *
832      */
833     NodeList(const NodeList &other)
834         {
835         nodes = other.nodes;
836         }
838     /**
839      *
840      */
841     NodeList &operator=(const NodeList &other)
842         {
843         nodes = other.nodes;
844         return *this;
845         }
847     /**
848      *
849      */
850     virtual ~NodeList() {}
852 protected:
854 friend class NodeImpl;
855 friend class ElementImpl;
857     /*
858      *
859      */
860     virtual void add(const Node *node)
861         {
862         nodes.push_back((Node *)node);
863         }
865 protected:
867     std::vector<Node *> nodes;
869 };
874 /*#########################################################################
875 ## NamedNodeMap
876 #########################################################################*/
878 class NamedNodeMapEntry
880 public:
881     NamedNodeMapEntry(const DOMString &theNamespaceURI,
882                       const DOMString &theName,
883                       const Node      *theNode)
884         {
885         namespaceURI = theNamespaceURI;
886         name         = theName;
887         node         = (Node *)theNode;
888         }
889     NamedNodeMapEntry(const NamedNodeMapEntry &other)
890         {
891         namespaceURI = other.namespaceURI;
892         name         = other.name;
893         node         = other.node;
894         }
895     virtual ~NamedNodeMapEntry()
896         {
897         }
898     DOMString namespaceURI;
899     DOMString name;
900     Node      *node;
901 };
903 /**
904  *
905  */
906 class NamedNodeMap
908 public:
910     /**
911      *
912      */
913     virtual Node *getNamedItem(const DOMString& name)
914         {
915         std::vector<NamedNodeMapEntry>::iterator iter;
916         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
917             {
918             if (iter->name == name)
919                 {
920                 Node *node = iter->node;
921                 return node;
922                 }
923             }
924         return NULL;
925         }
927     /**
928      *
929      */
930     virtual Node *setNamedItem(Node *arg) throw(DOMException)
931         {
932         if (!arg)
933             return NULL;
934         DOMString namespaceURI = arg->getNamespaceURI();
935         DOMString name         = arg->getNodeName();
936         std::vector<NamedNodeMapEntry>::iterator iter;
937         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
938             {
939             if (iter->name == name)
940                 {
941                 Node *node = iter->node;
942                 iter->node = arg;
943                 return node;
944                 }
945             }
946         NamedNodeMapEntry entry(namespaceURI, name, arg);
947         entries.push_back(entry);
948         return arg;
949         }
952     /**
953      *
954      */
955     virtual Node *removeNamedItem(const DOMString& name) throw(DOMException)
956         {
957         std::vector<NamedNodeMapEntry>::iterator iter;
958         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
959             {
960             if (iter->name == name)
961                 {
962                 Node *node = iter->node;
963                 entries.erase(iter);
964                 return node;
965                 }
966             }
967         return NULL;
968         }
970     /**
971      *
972      */
973     virtual Node *item(unsigned long index)
974         {
975         if (index>=entries.size())
976             return NULL;
977         return entries[index].node;
978         }
980     /**
981      *
982      */
983     virtual unsigned long getLength()
984         {
985         return (unsigned long)entries.size();
986         }
988     /**
989      *
990      */
991     virtual Node *getNamedItemNS(const DOMString& namespaceURI,
992                                  const DOMString& localName)
993         {
994         std::vector<NamedNodeMapEntry>::iterator iter;
995         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
996             {
997             if (iter->namespaceURI == namespaceURI && iter->name == localName)
998                 {
999                 Node *node = iter->node;
1000                 return node;
1001                 }
1002             }
1003         return NULL;
1004         }
1006     /**
1007      *
1008      */
1009     virtual Node *setNamedItemNS(Node *arg) throw(DOMException)
1010         {
1011         if (!arg)
1012             return NULL;
1013         DOMString namespaceURI = arg->getNamespaceURI();
1014         DOMString name         = arg->getNodeName();
1015         std::vector<NamedNodeMapEntry>::iterator iter;
1016         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1017             {
1018             if (iter->namespaceURI == namespaceURI && iter->name == name)
1019                 {
1020                 Node *node = iter->node;
1021                 iter->node = arg;
1022                 return node;
1023                 }
1024             }
1025         NamedNodeMapEntry entry(namespaceURI, name, arg);
1026         entries.push_back(entry);
1027         return arg;
1028         }
1030     /**
1031      *
1032      */
1033     virtual Node *removeNamedItemNS(const DOMString& namespaceURI,
1034                                     const DOMString& localName)
1035                                     throw(DOMException)
1036         {
1037         std::vector<NamedNodeMapEntry>::iterator iter;
1038         for (iter = entries.begin() ; iter!=entries.end() ; iter++)
1039             {
1040             if (iter->namespaceURI == namespaceURI && iter->name == localName)
1041                 {
1042                 Node *node = iter->node;
1043                 entries.erase(iter);
1044                 return node;
1045                 }
1046             }
1047         return NULL;
1048         }
1050     //##################
1051     //# Non-API methods
1052     //##################
1054     /**
1055      *
1056      */
1057     NamedNodeMap() {}
1060     /**
1061      *
1062      */
1063     NamedNodeMap(const NamedNodeMap &other)
1064         {
1065         entries = other.entries;
1066         }
1069     /**
1070      *
1071      */
1072     virtual ~NamedNodeMap() {}
1074 protected:
1076     std::vector<NamedNodeMapEntry> entries;
1078 };
1083 /*#########################################################################
1084 ## CharacterData
1085 #########################################################################*/
1087 /**
1088  *
1089  */
1090 class CharacterData : virtual public Node
1092 public:
1094     /**
1095      *
1096      */
1097     virtual DOMString getData() throw(DOMException) = 0;
1099     /**
1100      *
1101      */
1102     virtual void setData(const DOMString& val) throw(DOMException) = 0;
1104     /**
1105      *
1106      */
1107     virtual unsigned long getLength() = 0;
1109     /**
1110      *
1111      */
1112     virtual DOMString substringData(unsigned long offset,
1113                             unsigned long count)
1114                             throw(DOMException) = 0;
1116     /**
1117      *
1118      */
1119     virtual void appendData(const DOMString& arg) throw(DOMException) = 0;
1121     /**
1122      *
1123      */
1124     virtual void insertData(unsigned long offset,
1125                     const DOMString& arg)
1126                     throw(DOMException) = 0;
1128     /**
1129      *
1130      */
1131     virtual void deleteData(unsigned long offset,
1132                     unsigned long count)
1133                     throw(DOMException) = 0;
1135     /**
1136      *
1137      */
1138     virtual void  replaceData(unsigned long offset,
1139                       unsigned long count,
1140                       const DOMString& arg)
1141                       throw(DOMException) = 0;
1144     //##################
1145     //# Non-API methods
1146     //##################
1149     /**
1150      *
1151      */
1152     virtual ~CharacterData() {}
1154 };
1160 /*#########################################################################
1161 ## Attr
1162 #########################################################################*/
1164 /**
1165  *
1166  */
1167 class Attr : virtual public Node
1169 public:
1171     /**
1172      *
1173      */
1174     virtual DOMString getName() = 0;
1176     /**
1177      *
1178      */
1179     virtual bool getSpecified() = 0;
1181     /**
1182      *
1183      */
1184     virtual DOMString getValue() = 0;
1186     /**
1187      *
1188      */
1189     virtual void setValue(const DOMString& val) throw(DOMException) = 0;
1191     /**
1192      *
1193      */
1194     virtual Element *getOwnerElement() = 0;
1197     /**
1198      *
1199      */
1200     virtual TypeInfo *getSchemaTypeInfo() = 0;
1203     /**
1204      *
1205      */
1206     virtual bool getIsId() = 0;
1208     //##################
1209     //# Non-API methods
1210     //##################
1213     /**
1214      *
1215      */
1216     virtual ~Attr() {}
1218 };
1224 /*#########################################################################
1225 ## Element
1226 #########################################################################*/
1228 /**
1229  *
1230  */
1231 class Element : virtual public Node
1233 public:
1236     /**
1237      *
1238      */
1239     virtual DOMString getTagName() = 0;
1241     /**
1242      *
1243      */
1244     virtual DOMString getAttribute(const DOMString& name) = 0;
1246     /**
1247      *
1248      */
1249     virtual void setAttribute(const DOMString& name,
1250                       const DOMString& value)
1251                       throw(DOMException) = 0;
1253     /**
1254      *
1255      */
1256     virtual void removeAttribute(const DOMString& name)
1257                          throw(DOMException) = 0;
1259     /**
1260      *
1261      */
1262     virtual Attr *getAttributeNode(const DOMString& name) = 0;
1264     /**
1265      *
1266      */
1267     virtual Attr *setAttributeNode(Attr *newAttr)
1268                           throw(DOMException) = 0;
1270     /**
1271      *
1272      */
1273     virtual Attr *removeAttributeNode(Attr *oldAttr)
1274                              throw(DOMException) = 0;
1276     /**
1277      *
1278      */
1279     virtual NodeList getElementsByTagName(const DOMString& name) = 0;
1281     /**
1282      *
1283      */
1284     virtual DOMString getAttributeNS(const DOMString& namespaceURI,
1285                              const DOMString& localName) = 0;
1287     /**
1288      *
1289      */
1290     virtual void setAttributeNS(const DOMString& namespaceURI,
1291                         const DOMString& qualifiedName,
1292                         const DOMString& value)
1293                         throw(DOMException) = 0;
1295     /**
1296      *
1297      */
1298     virtual void removeAttributeNS(const DOMString& namespaceURI,
1299                            const DOMString& localName)
1300                            throw(DOMException) = 0;
1302     /**
1303      *
1304      */
1305     virtual Attr *getAttributeNodeNS(const DOMString& namespaceURI,
1306                             const DOMString& localName) = 0;
1308     /**
1309      *
1310      */
1311     virtual Attr *setAttributeNodeNS(Attr *newAttr)
1312                             throw(DOMException) = 0;
1314     /**
1315      *
1316      */
1317     virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI,
1318                                     const DOMString& localName) = 0;
1320     /**
1321      *
1322      */
1323     virtual bool hasAttribute(const DOMString& name) = 0;
1325     /**
1326      *
1327      */
1328     virtual bool hasAttributeNS(const DOMString& namespaceURI,
1329                         const DOMString& localName) = 0;
1331     /**
1332      *
1333      */
1334     virtual TypeInfo *getSchemaTypeInto() = 0;
1337     /**
1338      *
1339      */
1340     virtual void setIdAttribute(const DOMString &name,
1341                                 bool isId) throw (DOMException) = 0;
1343     /**
1344      *
1345      */
1346     virtual void setIdAttributeNS(const DOMString &namespaceURI,
1347                                   const DOMString &localName,
1348                                   bool isId) throw (DOMException) = 0;
1350     /**
1351      *
1352      */
1353     virtual void setIdAttributeNode(const Attr *idAttr,
1354                                     bool isId) throw (DOMException) = 0;
1356     //##################
1357     //# Non-API methods
1358     //##################
1360     /**
1361      *
1362      */
1363     virtual ~Element() {}
1365 };
1371 /*#########################################################################
1372 ## Text
1373 #########################################################################*/
1375 /**
1376  *
1377  */
1378 class Text : virtual public CharacterData
1380 public:
1382     /**
1383      *
1384      */
1385     virtual Text *splitText(unsigned long offset)
1386                     throw(DOMException) = 0;
1388     /**
1389      *
1390      */
1391     virtual bool getIsElementContentWhitespace()= 0;
1393     /**
1394      *
1395      */
1396     virtual DOMString getWholeText() = 0;
1399     /**
1400      *
1401      */
1402     virtual Text *replaceWholeText(const DOMString &content)
1403                                  throw(DOMException) = 0;
1405     //##################
1406     //# Non-API methods
1407     //##################
1410     /**
1411      *
1412      */
1413     virtual ~Text() {}
1415 };
1419 /*#########################################################################
1420 ## Comment
1421 #########################################################################*/
1423 /**
1424  *
1425  */
1426 class Comment : virtual public CharacterData
1428 public:
1430     //##################
1431     //# Non-API methods
1432     //##################
1435     /**
1436      *
1437      */
1438     virtual ~Comment() {}
1441 };
1445 /*#########################################################################
1446 ## TypeInfo
1447 #########################################################################*/
1449 /**
1450  *
1451  */
1452 class TypeInfo
1454 public:
1456     /**
1457      *
1458      */
1459     virtual DOMString getTypeName() =0;
1461     /**
1462      *
1463      */
1464     virtual DOMString getTypeNamespace() =0;
1466     typedef enum
1467         {
1468         DERIVATION_RESTRICTION = 0x00000001,
1469         DERIVATION_EXTENSION   = 0x00000002,
1470         DERIVATION_UNION       = 0x00000004,
1471         DERIVATION_LIST        = 0x00000008
1472         } DerivationMethod;
1475     /**
1476      *
1477      */
1478     virtual bool isDerivedFrom(const DOMString &typeNamespaceArg,
1479                                const DOMString &typeNameArg,
1480                                DerivationMethod derivationMethod) =0;
1482     //##################
1483     //# Non-API methods
1484     //##################
1487     /**
1488      *
1489      */
1490     virtual ~TypeInfo() {}
1492 };
1497 /*#########################################################################
1498 ## UserDataHandler
1499 #########################################################################*/
1501 /**
1502  *
1503  */
1504 class UserDataHandler
1506 public:
1508     typedef enum
1509         {
1510         NODE_CLONED     = 1,
1511         NODE_IMPORTED   = 2,
1512         NODE_DELETED    = 3,
1513         NODE_RENAMED    = 4,
1514         NODE_ADOPTED    = 5
1515         } OperationType;
1518     /**
1519      *
1520      */
1521     virtual  void handle(unsigned short operation,
1522                          const DOMString &key,
1523                          const DOMUserData *data,
1524                          const Node *src,
1525                          const Node *dst) =0;
1527     //##################
1528     //# Non-API methods
1529     //##################
1532     /**
1533      *
1534      */
1535     virtual ~UserDataHandler() {}
1537 };
1540 /*#########################################################################
1541 ## DOMError
1542 #########################################################################*/
1544 /**
1545  *
1546  */
1547 class DOMError
1549 public:
1551     typedef enum
1552         {
1553         DOMERROR_SEVERITY_WARNING     = 1,
1554         DOMERROR_SEVERITY_ERROR       = 2,
1555         DOMERROR_SEVERITY_FATAL_ERROR = 3
1556         } ErrorSeverity;
1559     /**
1560      *
1561      */
1562     virtual unsigned short getSeverity() =0;
1564     /**
1565      *
1566      */
1567     virtual DOMString getMessage() =0;
1569     /**
1570      *
1571      */
1572     virtual DOMString getType() =0;
1574     /**
1575      *
1576      */
1577     virtual DOMObject *getRelatedException() =0;
1579     /**
1580      *
1581      */
1582     virtual DOMObject *getRelatedData() =0;
1584     /**
1585      *
1586      */
1587     virtual DOMLocator *getLocation() =0;
1590     //##################
1591     //# Non-API methods
1592     //##################
1595     /**
1596      *
1597      */
1598     virtual ~DOMError() {}
1600 };
1603 /*#########################################################################
1604 ## DOMErrorHandler
1605 #########################################################################*/
1607 /**
1608  *
1609  */
1610 class DOMErrorHandler
1612 public:
1613     /**
1614      *
1615      */
1616     virtual bool handleError(const DOMError *error) =0;
1618     //##################
1619     //# Non-API methods
1620     //##################
1623     /**
1624      *
1625      */
1626     virtual ~DOMErrorHandler() {}
1628 };
1632 /*#########################################################################
1633 ## DOMLocator
1634 #########################################################################*/
1636 /**
1637  *
1638  */
1639 class DOMLocator
1641 public:
1643     /**
1644      *
1645      */
1646     virtual long getLineNumber() =0;
1648     /**
1649      *
1650      */
1651     virtual long getColumnNumber() =0;
1653     /**
1654      *
1655      */
1656     virtual long getByteOffset() =0;
1658     /**
1659      *
1660      */
1661     virtual long getUtf16Offset() =0;
1664     /**
1665      *
1666      */
1667     virtual Node *getRelatedNode() =0;
1670     /**
1671      *
1672      */
1673     virtual DOMString getUri() =0;
1675     //##################
1676     //# Non-API methods
1677     //##################
1679     /**
1680      *
1681      */
1682     virtual ~DOMLocator() {}
1683 };
1686 /*#########################################################################
1687 ## DOMConfiguration
1688 #########################################################################*/
1690 /**
1691  *
1692  */
1693 class DOMConfiguration
1695 public:
1697     /**
1698      *
1699      */
1700     virtual void setParameter(const DOMString &name,
1701                               const DOMUserData *value) throw (DOMException) =0;
1703     /**
1704      *
1705      */
1706     virtual DOMUserData *getParameter(const DOMString &name)
1707                                       throw (DOMException) =0;
1709     /**
1710      *
1711      */
1712     virtual bool canSetParameter(const DOMString &name,
1713                                  const DOMUserData *data) =0;
1715     /**
1716      *
1717      */
1718     virtual DOMStringList *getParameterNames() =0;
1720     //##################
1721     //# Non-API methods
1722     //##################
1725     /**
1726      *
1727      */
1728     virtual ~DOMConfiguration() {}
1730 };
1737 /*#########################################################################
1738 ## CDATASection
1739 #########################################################################*/
1740 /**
1741  *
1742  */
1743 class CDATASection : virtual public Text
1745 public:
1747     //##################
1748     //# Non-API methods
1749     //##################
1752     /**
1753      *
1754      */
1755     virtual ~CDATASection() {}
1757 };
1762 /*#########################################################################
1763 ## DocumentType
1764 #########################################################################*/
1766 /**
1767  *
1768  */
1769 class DocumentType : virtual public Node
1771 public:
1773     /**
1774      *
1775      */
1776     virtual DOMString getName() = 0;
1778     /**
1779      *
1780      */
1781     virtual NamedNodeMap getEntities() = 0;
1783     /**
1784      *
1785      */
1786     virtual NamedNodeMap getNotations() = 0;
1788     /**
1789      *
1790      */
1791     virtual DOMString getPublicId() = 0;
1793     /**
1794      *
1795      */
1796     virtual DOMString getSystemId() = 0;
1798     /**
1799      *
1800      */
1801     virtual DOMString getInternalSubset() = 0;
1803     //##################
1804     //# Non-API methods
1805     //##################
1807     /**
1808      *
1809      */
1810     virtual ~DocumentType() {}
1812 };
1818 /*#########################################################################
1819 ## Notation
1820 #########################################################################*/
1822 /**
1823  *
1824  */
1825 class Notation : virtual public Node
1827 public:
1829     /**
1830      *
1831      */
1832     virtual DOMString getPublicId() = 0;
1834     /**
1835      *
1836      */
1837     virtual DOMString getSystemId() = 0;
1839     //##################
1840     //# Non-API methods
1841     //##################
1844     /**
1845      *
1846      */
1847     virtual ~Notation() {}
1848 };
1855 /*#########################################################################
1856 ## Entity
1857 #########################################################################*/
1859 /**
1860  *
1861  */
1862 class Entity : virtual public Node
1864 public:
1866     /**
1867      *
1868      */
1869     virtual DOMString getPublicId() = 0;
1871     /**
1872      *
1873      */
1874     virtual DOMString getSystemId() = 0;
1876     /**
1877      *
1878      */
1879     virtual DOMString getNotationName() = 0;
1881     /**
1882      *
1883      */
1884     virtual DOMString getInputEncoding() = 0;
1886     /**
1887      *
1888      */
1889     virtual DOMString getXmlEncoding() = 0;
1891     /**
1892      *
1893      */
1894     virtual DOMString getXmlVersion() = 0;
1896     //##################
1897     //# Non-API methods
1898     //##################
1901     /**
1902      *
1903      */
1904     virtual ~Entity() {}
1905 };
1911 /*#########################################################################
1912 ## EntityReference
1913 #########################################################################*/
1914 /**
1915  *
1916  */
1917 class EntityReference : virtual public Node
1919 public:
1922     //##################
1923     //# Non-API methods
1924     //##################
1926     /**
1927      *
1928      */
1929     virtual ~EntityReference() {}
1930 };
1936 /*#########################################################################
1937 ## ProcessingInstruction
1938 #########################################################################*/
1940 /**
1941  *
1942  */
1943 class ProcessingInstruction : virtual public Node
1945 public:
1947     /**
1948      *
1949      */
1950     virtual DOMString getTarget() = 0;
1952     /**
1953      *
1954      */
1955     virtual DOMString getData() = 0;
1957     /**
1958      *
1959      */
1960    virtual void setData(const DOMString& val) throw(DOMException) = 0;
1962     //##################
1963     //# Non-API methods
1964     //##################
1967     /**
1968      *
1969      */
1970     virtual ~ProcessingInstruction() {}
1972 };
1978 /*#########################################################################
1979 ## DocumentFragment
1980 #########################################################################*/
1981 /**
1982  *
1983  */
1984 class DocumentFragment : virtual public Node
1986 public:
1988     //##################
1989     //# Non-API methods
1990     //##################
1993     /**
1994      *
1995      */
1996     virtual ~DocumentFragment() {}
1997 };
2004 /*#########################################################################
2005 ## Document
2006 #########################################################################*/
2008 /**
2009  *
2010  */
2011 class Document : virtual public Node
2013 public:
2015     /**
2016      *
2017      */
2018     virtual DocumentType *getDoctype() = 0;
2020     /**
2021      *
2022      */
2023     virtual DOMImplementation *getImplementation() = 0;
2025     /**
2026      *
2027      */
2028     virtual Element *getDocumentElement() = 0;
2030     /**
2031      *
2032      */
2033     virtual Element *createElement(const DOMString& tagName)
2034                            throw(DOMException) = 0;
2036     /**
2037      *
2038      */
2039     virtual DocumentFragment *createDocumentFragment() = 0;
2041     /**
2042      *
2043      */
2044     virtual Text *createTextNode(const DOMString& data) = 0;
2046     /**
2047      *
2048      */
2049     virtual Comment  *createComment(const DOMString& data) = 0;
2051     /**
2052      *
2053      */
2054     virtual CDATASection *createCDATASection(const DOMString& data)
2055                                      throw(DOMException) = 0;
2057     /**
2058      *
2059      */
2060     virtual ProcessingInstruction *createProcessingInstruction(const DOMString& target,
2061                                                        const DOMString& data)
2062                                                        throw(DOMException) = 0;
2064     /**
2065      *
2066      */
2067     virtual Attr *createAttribute(const DOMString& name)
2068                           throw(DOMException) = 0;
2070     /**
2071      *
2072      */
2073     virtual EntityReference *createEntityReference(const DOMString& name)
2074                                            throw(DOMException) = 0;
2076     /**
2077      *
2078      */
2079     virtual NodeList getElementsByTagName(const DOMString& tagname) = 0;
2082     /**
2083      *
2084      */
2085     virtual Node *importNode(const Node *importedNode,
2086                      bool deep)
2087                      throw(DOMException) = 0;
2089     /**
2090      *
2091      */
2092     virtual Element *createElementNS(const DOMString& namespaceURI,
2093                              const DOMString& qualifiedName)
2094                              throw(DOMException) = 0;
2096     /**
2097      *
2098      */
2099     virtual Attr *createAttributeNS(const DOMString& namespaceURI,
2100                             const DOMString& qualifiedName)
2101                             throw(DOMException) = 0;
2103     /**
2104      *
2105      */
2106     virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI,
2107                                      const DOMString& localName) = 0;
2109     /**
2110      *
2111      */
2112     virtual Element *getElementById(const DOMString& elementId) = 0;
2115     /**
2116      *
2117      */
2118     virtual DOMString getInputEncoding() = 0;
2121     /**
2122      *
2123      */
2124     virtual DOMString getXmlEncoding() = 0;
2126     /**
2127      *
2128      */
2129     virtual bool getXmlStandalone() = 0;
2131     /**
2132      *
2133      */
2134     virtual void setXmlStandalone(bool val) throw (DOMException) = 0;
2136     /**
2137      *
2138      */
2139     virtual DOMString getXmlVersion() = 0;
2141     /**
2142      *
2143      */
2144     virtual void setXmlVersion(const DOMString &version) throw (DOMException) = 0;
2146     /**
2147      *
2148      */
2149     virtual bool getStrictErrorChecking() = 0;
2151     /**
2152      *
2153      */
2154     virtual void setStrictErrorChecking(bool val) = 0;
2157     /**
2158      *
2159      */
2160     virtual DOMString getDocumentURI() = 0;
2162     /**
2163      *
2164      */
2165     virtual void setDocumentURI(const DOMString &uri) = 0;
2167     /**
2168      *
2169      */
2170     virtual Node *adoptNode(const Node *source) throw (DOMException) = 0;
2172     /**
2173      *
2174      */
2175     virtual DOMConfiguration *getDomConfig() = 0;
2177     /**
2178      *
2179      */
2180     virtual void normalizeDocument() = 0;
2182     /**
2183      *
2184      */
2185     virtual Node *renameNode(const Node *n,
2186                              const DOMString &namespaceURI,
2187                              const DOMString &qualifiedName)
2188                              throw (DOMException) = 0;
2191     //##################
2192     //# Non-API methods
2193     //##################
2195     /**
2196      *
2197      */
2198     virtual ~Document() {}
2200 };
2212 }  //namespace dom
2213 }  //namespace w3c
2214 }  //namespace org
2217 #endif // __DOM_H__
2220 /*#########################################################################
2221 ## E N D    O F    F I L E
2222 #########################################################################*/