1#if defined(ZIP_SUPPORT)
2#include "filamzip.h"
3#endif // ZIP_SUPPORT
4
5/******************************************************************/
6/* Dual XML implementation base classes defines. */
7/******************************************************************/
8#if !defined(BASE_BUFFER_SIZE)
9enum ElementType { // libxml2
10 XML_ELEMENT_NODE = 1,
11 XML_ATTRIBUTE_NODE = 2,
12 XML_TEXT_NODE = 3,
13 XML_CDATA_SECTION_NODE = 4,
14 XML_ENTITY_REF_NODE = 5,
15 XML_ENTITY_NODE = 6,
16 XML_PI_NODE = 7,
17 XML_COMMENT_NODE = 8,
18 XML_DOCUMENT_NODE = 9,
19 XML_DOCUMENT_TYPE_NODE = 10,
20 XML_DOCUMENT_FRAG_NODE = 11,
21 XML_NOTATION_NODE = 12,
22 XML_HTML_DOCUMENT_NODE = 13,
23 XML_DTD_NODE = 14,
24 XML_ELEMENT_DECL = 15,
25 XML_ATTRIBUTE_DECL = 16,
26 XML_ENTITY_DECL = 17,
27 XML_NAMESPACE_DECL = 18,
28 XML_XINCLUDE_START = 19,
29 XML_XINCLUDE_END = 20,
30 XML_DOCB_DOCUMENT_NODE = 21};
31#endif // !BASE_BUFFER_SIZE
32
33//#if !defined(NODE_TYPE_LIST)
34#ifdef NOT_USED
35enum NodeType { // MS DOM
36 NODE_ELEMENT = 1,
37 NODE_ATTRIBUTE = 2,
38 NODE_TEXT = 3,
39 NODE_CDATA_SECTION = 4,
40 NODE_ENTITY_REFERENCE = 5,
41 NODE_ENTITY = 6,
42 NODE_PROCESSING_INSTRUCTION = 7,
43 NODE_COMMENT = 8,
44 NODE_DOCUMENT = 9,
45 NODE_DOCUMENT_TYPE = 10,
46 NODE_DOCUMENT_FRAGMENT = 11,
47 NODE_NOTATION = 12};
48#endif // !NODE_TYPE_LIST
49
50typedef class XMLDOCUMENT *PXDOC; // Document
51typedef class XMLNODE *PXNODE; // Node (Element)
52typedef class XMLNODELIST *PXLIST; // Node list
53typedef class XMLATTRIBUTE *PXATTR; // Attribute
54
55typedef struct _ns {
56 struct _ns *Next;
57 char *Prefix;
58 char *Uri;
59 } NS, *PNS;
60
61PXDOC GetLibxmlDoc(PGLOBAL g, char *nsl, char *nsdf,
62 char *enc, PFBLOCK fp = NULL);
63PXDOC GetDomDoc(PGLOBAL g, char *nsl, char *nsdf,
64 char *enc, PFBLOCK fp = NULL);
65
66/******************************************************************/
67/* Declaration of XML document. */
68/******************************************************************/
69class XMLDOCUMENT : public BLOCK {
70 friend class XML2NODE;
71 friend class DOMNODE;
72 public:
73 // Properties
74 virtual short GetDocType(void) = 0;
75 virtual void *GetDocPtr(void) = 0;
76 virtual void SetNofree(bool b) = 0;
77
78 // Methods
79 virtual bool Initialize(PGLOBAL, PCSZ, bool) = 0;
80 virtual bool ParseFile(PGLOBAL, char *) = 0;
81 virtual bool NewDoc(PGLOBAL, PCSZ) = 0;
82 virtual void AddComment(PGLOBAL, char *) = 0;
83 virtual PXNODE GetRoot(PGLOBAL) = 0;
84 virtual PXNODE NewRoot(PGLOBAL, char *) = 0;
85 virtual PXNODE NewPnode(PGLOBAL, char * = NULL) = 0;
86 virtual PXATTR NewPattr(PGLOBAL) = 0;
87 virtual PXLIST NewPlist(PGLOBAL) = 0;
88 virtual int DumpDoc(PGLOBAL, char *) = 0;
89 virtual void CloseDoc(PGLOBAL, PFBLOCK) = 0;
90 virtual PFBLOCK LinkXblock(PGLOBAL, MODE, int, char *) = 0;
91
92 protected:
93 // Constructor
94 XMLDOCUMENT(char *nsl, char *nsdf, char *enc);
95
96 // Utility
97 bool MakeNSlist(PGLOBAL g);
98 bool InitZip(PGLOBAL g, PCSZ entry);
99 char *GetMemDoc(PGLOBAL g, char *fn);
100 void CloseZip(void);
101
102 // Members
103#if defined(ZIP_SUPPORT)
104 UNZIPUTL *zip; /* Used for zipped file */
105#else // !ZIP_SUPPORT
106 bool zip; /* Always false */
107#endif // !ZIP_SUPPORT
108 PNS Namespaces; /* To the namespaces */
109 char *Encoding; /* The document encoding */
110 char *Nslist; /* Namespace list */
111 char *DefNs; /* Default namespace */
112}; // end of class XMLDOCUMENT
113
114/******************************************************************/
115/* Declaration of XML node. */
116/******************************************************************/
117class XMLNODE : public BLOCK {
118 public:
119 // Properties
120 virtual char *GetName(PGLOBAL) = 0;
121 virtual int GetType(void) = 0;
122 virtual PXNODE GetNext(PGLOBAL) = 0;
123 virtual PXNODE GetChild(PGLOBAL) = 0;
124 virtual int GetLen(void) {return Len;}
125
126 // Methods
127 virtual RCODE GetContent(PGLOBAL, char *, int) = 0;
128 virtual bool SetContent(PGLOBAL, char *, int) = 0;
129 virtual PXNODE Clone(PGLOBAL, PXNODE) = 0;
130 virtual PXLIST GetChildElements(PGLOBAL, char * = NULL, PXLIST = NULL) = 0;
131 virtual PXLIST SelectNodes(PGLOBAL, char *, PXLIST = NULL) = 0;
132 virtual PXNODE SelectSingleNode(PGLOBAL, char *, PXNODE = NULL) = 0;
133 virtual PXATTR GetAttribute(PGLOBAL, char *, PXATTR = NULL) = 0;
134 virtual PXNODE AddChildNode(PGLOBAL, PCSZ, PXNODE = NULL) = 0;
135 virtual PXATTR AddProperty(PGLOBAL, char *, PXATTR = NULL) = 0;
136 virtual void AddText(PGLOBAL, PCSZ) = 0;
137 virtual void DeleteChild(PGLOBAL, PXNODE) = 0;
138
139 protected:
140 PXNODE NewChild(PXNODE ncp);
141 void Delete(PXNODE dnp);
142 char *BufAlloc(PGLOBAL g, const char *p, int n);
143
144 // Constructor
145 XMLNODE(PXDOC dp);
146
147 // Members
148 PXDOC Doc;
149 PXNODE Next;
150 PXNODE Children;
151 char *Buf;
152 int Len;
153}; // end of class XMLNODE
154
155/******************************************************************/
156/* Declaration of XML node list. */
157/******************************************************************/
158class XMLNODELIST : public BLOCK {
159 public:
160 // Properties
161 virtual int GetLength(void) = 0;
162 virtual PXNODE GetItem(PGLOBAL, int, PXNODE = NULL) = 0;
163 virtual bool DropItem(PGLOBAL, int) = 0;
164
165 protected:
166 // Constructor
167 XMLNODELIST(PXDOC dp) {Doc = dp;}
168
169 // Members
170 PXDOC Doc;
171}; // end of class XMLNODELIST
172
173/******************************************************************/
174/* Declaration of XML attribute. */
175/******************************************************************/
176class XMLATTRIBUTE : public BLOCK {
177 public:
178 // Properties
179 virtual char *GetName(PGLOBAL) = 0;
180 virtual PXATTR GetNext(PGLOBAL) = 0;
181
182 // Methods
183 virtual RCODE GetText(PGLOBAL, char *, int) = 0;
184 virtual bool SetText(PGLOBAL, char *, int) = 0;
185
186 protected:
187 // Constructor
188 XMLATTRIBUTE(PXDOC dp) {Doc = dp;}
189
190 // Members
191 PXDOC Doc;
192}; // end of class XMLATTRIBUTE
193
194
195