00001 /* 00002 * $Id: dsDocument.h,v 1.6 2003/08/27 15:40:41 dsamersoff Exp $ 00003 */ 00004 #ifndef dsDocument_h 00005 #define dsDocument_h 00006 00007 #include <dsNode.h> 00008 00009 #include <dsAttr.h> 00010 #include <dsCDATASection.h> 00011 #include <dsComment.h> 00012 #include <dsDocumentFragment.h> 00013 #include <dsDocumentType.h> 00014 #include <dsElement.h> 00015 #include <dsEntity.h> 00016 #include <dsEntityReference.h> 00017 #include <dsProcessingInstruction.h> 00018 #include <dsText.h> 00019 00020 #include <dsDOMImplementation.h> 00021 #include <dsXMLParser.h> 00022 00023 class dsDocument : public dsNode 00024 { 00025 public: 00026 dsDocumentType *doctype(); 00027 dsDOMImplementation *implementation(); 00028 dsElement *documentElement(); 00029 00030 dsElement *createElement(DOMString tagName); 00031 dsDocumentFragment *createDocumentFragment(); 00032 dsText *createTextNode(DOMString data); 00033 dsComment *createComment(DOMString data); 00034 dsCDATASection *createCDATASection(DOMString data); 00035 dsProcessingInstruction *createProcessingInstruction(DOMString target, DOMString data); 00036 dsProcessingInstruction *createProcessingInstruction(DOMString target); 00037 dsAttr *createAttribute(DOMString name); 00038 dsEntityReference *createEntityReference(DOMString name); 00039 00040 00041 dsNodeList *getElementsByTagName(DOMString tagname); 00042 dsElement *getElementById(DOMString elementId); 00043 00044 dsNode *importNode(dsNode importeddsNode, bool deep); 00045 00046 dsElement *createElementNS(DOMString namespaceURI, DOMString qualifiedName); 00047 dsAttr *createAttributeNS(DOMString namespaceURI, DOMString qualifiedName); 00048 dsNodeList *getElementsByTagNameNS(DOMString namespaceURI, DOMString localName); 00049 00050 protected: 00051 /* internals */ 00052 dsXMLParser *_pr; 00053 bool _read_only; 00054 00055 public: 00056 /* extensions */ 00057 00058 bool isReadOnly(){ return _read_only; } 00059 00063 void setContent(std::istream &is, bool readOnly = false); 00064 00068 void writeContent(std::ostream& os); 00069 00074 void createDocumentHeader(char *version, char *encoding); 00075 00076 /* return first direct child of given type with given tagname 00077 * EMPTY_NODE means that any types should be returned 00078 */ 00079 dsNode *findChild(const DOMString tag, dsNode *root, dsNodeTypes type = EMPTY_NODE); 00080 00081 /* return text child belonged root 00082 */ 00083 dsNode *textChild(dsNode *root); 00084 00085 00086 dsDocument(); 00087 ~dsDocument(); 00088 00089 friend class dsAttr; // to deal with namespaces 00090 00091 00092 }; 00093 00094 00095 00096 00097 #endif