source: trunk/include/helpers/xml.h@ 114

Last change on this file since 114 was 98, checked in by umoeller, 24 years ago

Misc updates.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 30.5 KB
Line 
1
2/*
3 *@@sourcefile xml.h:
4 * header file for xml.c (XML parsing).
5 *
6 * See remarks there.
7 *
8 *@@added V0.9.6 (2000-10-29) [umoeller]
9 *@@include #include <os2.h>
10 *@@include #include "expat\expat.h" // must come before xml.h
11 *@@include #include "helpers\linklist.h"
12 *@@include #include "helpers\tree.h"
13 *@@include #include "helpers\xstring.h"
14 *@@include #include "helpers\xml.h"
15 */
16
17#if __cplusplus
18extern "C" {
19#endif
20
21#ifndef XML_HEADER_INCLUDED
22 #define XML_HEADER_INCLUDED
23
24 // define some basic things to make this work even with standard C
25 #if (!defined OS2_INCLUDED) && (!defined _OS2_H) && (!defined __SIMPLES_DEFINED) // changed V0.9.0 (99-10-22) [umoeller]
26 typedef unsigned long BOOL;
27 typedef unsigned long ULONG;
28 typedef unsigned char *PSZ;
29 #define TRUE (BOOL)1
30 #define FALSE (BOOL)0
31
32 #ifdef __IBMCPP__ // added V0.9.0 (99-10-22) [umoeller]
33 #define APIENTRY _System
34 #endif
35
36 #define __SIMPLES_DEFINED
37 #endif
38
39 /* ******************************************************************
40 *
41 * Error handling
42 *
43 ********************************************************************/
44
45 // ERROR_XML_FIRST is defined in expat\expat.h;
46 // the range up to ERROR_XML_FIRST + 24 is used
47 // by expat
48
49// START MATCHING ERROR MESSAGES (xmlDescribeError)
50 // validity errors:
51 #define ERROR_DOM_UNDECLARED_ELEMENT (ERROR_XML_FIRST + 24)
52 // invalidity: element is undeclared
53 #define ERROR_DOM_ROOT_ELEMENT_MISNAMED (ERROR_XML_FIRST + 25)
54 #define ERROR_DOM_INVALID_ROOT_ELEMENT (ERROR_XML_FIRST + 26)
55 #define ERROR_DOM_INVALID_SUBELEMENT (ERROR_XML_FIRST + 27)
56 // subelement may not appear in its parent element
57 #define ERROR_DOM_DUPLICATE_ELEMENT_DECL (ERROR_XML_FIRST + 28)
58 // more than one declaration for an element type
59 #define ERROR_DOM_DUPLICATE_ATTRIBUTE_DECL (ERROR_XML_FIRST + 29)
60 // more than one declaration for an attribute type
61 #define ERROR_DOM_UNDECLARED_ATTRIBUTE (ERROR_XML_FIRST + 30)
62 #define ERROR_ELEMENT_CANNOT_HAVE_CONTENT (ERROR_XML_FIRST + 31)
63 // element was declared "empty" and contains text anyway,
64 // or was declared "children" and contains something other
65 // than whitespace
66 #define ERROR_DOM_INVALID_ATTRIB_VALUE (ERROR_XML_FIRST + 32)
67 #define ERROR_DOM_REQUIRED_ATTRIBUTE_MISSING (ERROR_XML_FIRST + 33)
68 #define ERROR_DOM_SUBELEMENT_IN_EMPTY_ELEMENT (ERROR_XML_FIRST + 34)
69// END MATCHING ERROR MESSAGES (xmlDescribeError)
70
71 // error categories:
72 #define ERROR_DOM_PARSING (ERROR_XML_FIRST + 35)
73 #define ERROR_DOM_VALIDITY (ERROR_XML_FIRST + 36)
74
75 // additional DOM errors
76 #define ERROR_DOM_NODETYPE_NOT_SUPPORTED (ERROR_XML_FIRST + 37)
77 // invalid node type in xmlCreateDomNode
78 #define ERROR_DOM_NO_DOCUMENT (ERROR_XML_FIRST + 38)
79 // cannot find document node
80 #define ERROR_DOM_NO_ELEMENT (ERROR_XML_FIRST + 39)
81 #define ERROR_DOM_DUPLICATE_DOCTYPE (ERROR_XML_FIRST + 40)
82 #define ERROR_DOM_DOCTYPE_ROOT_NAMES_MISMATCH (ERROR_XML_FIRST + 41)
83 // DOCTYPE is given and root element name does not match doctype name
84 #define ERROR_DOM_INTEGRITY (ERROR_XML_FIRST + 42)
85 #define ERROR_DOM_DUPLICATE_ATTRIBUTE (ERROR_XML_FIRST + 43)
86
87 #define ERROR_DOM_VALIDATE_INVALID_ELEMENT (ERROR_XML_FIRST + 44)
88 #define ERROR_DOM_ELEMENT_DECL_OUTSIDE_DOCTYPE (ERROR_XML_FIRST + 45)
89 #define ERROR_DOM_ATTLIST_DECL_OUTSIDE_DOCTYPE (ERROR_XML_FIRST + 46)
90
91 #define ERROR_DOM_INCOMPLETE_ENCODING_MAP (ERROR_XML_FIRST + 47)
92 // callback to UnknownEncodingHandler has provided
93 // an incomplete encoding map V0.9.14 (2001-08-09) [umoeller]
94
95 #define ERROR_DOM_INVALID_EXTERNAL_HANDLER (ERROR_XML_FIRST + 48)
96
97 const char* xmlDescribeError(int code);
98
99 /* ******************************************************************
100 *
101 * Most basic node management
102 *
103 ********************************************************************/
104
105 // content model node types:
106 typedef enum _NODEBASETYPE
107 {
108 TYPE_UNKNOWN,
109
110 DOMNODE_ELEMENT, // node is a DOM ELEMENT
111 DOMNODE_ATTRIBUTE, // node is a DOM ATTRIBUTE
112 DOMNODE_TEXT, // node is a DOM TEXT node
113 // DOMNODE_CDATA_SECTION 4
114 // DOMNODE_ENTITY_REFERENCE 5
115 // DOMNODE_ENTITY 6
116 DOMNODE_PROCESSING_INSTRUCTION, // node is a DOM PI
117 DOMNODE_COMMENT, // node is a DOM COMMENT
118 DOMNODE_DOCUMENT, // node is a DOM document
119 DOMNODE_DOCUMENT_TYPE, // node is a DOM DOCUMENTTYPE
120 // #define DOMNODE_DOCUMENT_FRAGMENT 11
121 // #define DOMNODE_NOTATION 12
122
123 // the following are all CMELEMENTPARTICLE nodes
124 ELEMENTPARTICLE_EMPTY,
125 ELEMENTPARTICLE_ANY,
126 ELEMENTPARTICLE_MIXED,
127 ELEMENTPARTICLE_CHOICE,
128 ELEMENTPARTICLE_SEQ,
129 ELEMENTPARTICLE_NAME,
130
131 ATTRIBUTE_DECLARATION_BASE, // node is a CMATTRIBUTEDECLBASE
132 ATTRIBUTE_DECLARATION, // node is a CMATTRIBUTEDECL
133 ATTRIBUTE_DECLARATION_ENUM // node is a plain NODEBASE, part of an attr value enum
134 } NODEBASETYPE;
135
136 /*
137 *@@ NODEBASE:
138 * root class of all nodes used in the
139 * DOM tree.
140 *
141 * The first item is a TREE to make this insertable
142 * into string maps via the functions in tree.c.
143 *
144 * A NODEBASE is also the first member of a DOMNODE
145 * so this is effectively a simulation of inheritance
146 * in plain C... DOMNODE inherits from NODEBASE,
147 * and some other types inherit from DOMNODE.
148 *
149 * This contains the node name, which is also used
150 * by the DOMNODE's (e.g. for element names).
151 * However, only DOMNODE defines the node value
152 * string.
153 *
154 *@@added V0.9.9 (2001-02-14) [umoeller]
155 */
156
157 typedef struct _NODEBASE
158 {
159 TREE Tree; // tree.c
160 // ulKey simply points to the strNodeName
161 // member always V0.9.13 (2001-06-27) [umoeller]
162
163 NODEBASETYPE ulNodeType; // class type; this is precious,
164 // all xml* functions make assumptions
165 // from this value
166
167 XSTRING strNodeName;
168 // node name;
169 // -- for the various DOMNODE_* items, see _DOMNODE;
170 // -- for CMELEMENTPARTICLE nodes, this is the particle's name
171 // -- for CMELEMENTDECLNODE nodes, element name being declared
172 // -- for CMATTRIBUTEDECLBASE nodes, name of element to which this
173 // attrib decl belongs
174 // -- for CMATTRIBUTEDECL nodes, name of attribute;
175 // -- for ATTRIBUTE_DECLARATION_ENUM, attribute value in the
176 // possible values list.
177
178 } NODEBASE, *PNODEBASE;
179
180 /* ******************************************************************
181 *
182 * DOM level 1
183 *
184 ********************************************************************/
185
186 /*
187 *@@ DOMNODE:
188 * this represents one @DOM node in an @XML document.
189 *
190 * The document itself is represented by a node with the
191 * DOMNODE_DOCUMENT type, which is the root of a tree as
192 * shown with xmlParse.
193 *
194 * The contents of the members vary according
195 * to ulNodeType (0 specifies that the field does not
196 * apply to that type).
197 *
198 * The first member of a DOMNODE is a NODEBASE to allow
199 * inserting these things in a tree. NODEBASE.ulNodeType
200 * _always_ specifies the various types that are using
201 * that structure to allow for type-safety (if we watch out).
202 * This is for faking inheritance.
203 *
204 * Note that we also implement specialized sub-structures of
205 * DOMNODE, whose first member is the DOMNODE (and therefore
206 * a NODEBASE as well):
207 *
208 * -- DOCUMENT nodes are given a _DOMDOCUMENTNODE structure.
209 *
210 * -- DOCTYPE nodes are given a _DOMDOCTYPENODE structure.
211 *
212 * Overview of member fields usage:
213 +
214 + ulNodeType | strNodeName | strNodeValue | llChildren | AttributesMap
215 + (NODEBASE) | (NODEBASE) | (DOMNODE) | (DOMNODE) | (DOMNODE)
216 + =======================================================================
217 + | | | |
218 + DOCUMENT | name from | 0 | 1 root | 0
219 + | DOCTYPE or | | ELEMENT |
220 + | NULL | | |
221 + | | | |
222 + --------------+-------------+--------------+------------+--------------
223 + | | | |
224 + ELEMENT | tag name | 0 | ELEMENT | ATTRIBUTE
225 + | | | nodes | nodes
226 + | | | |
227 + --------------+-------------+--------------+------------+--------------
228 + | | | |
229 + ATTRIBUTE | attribute | attribute | 0 | 0
230 + | name | value | |
231 + | | | |
232 + --------------+-------------+--------------+------------+--------------
233 + | | | |
234 + TEXT | 0 | text | 0 | 0
235 + | | contents | |
236 + | | | |
237 + --------------+-------------+--------------+------------+--------------
238 + | | | |
239 + COMMENT | 0 | comment | 0 | 0
240 + | | contents | |
241 + | | | |
242 + --------------+-------------+--------------+------------+--------------
243 + | | | |
244 + PI | PI target | PI data | 0 | 0
245 + | | | |
246 + | | | |
247 + --------------+-------------+--------------+------------+--------------
248 + | | | |
249 + DOCTYPE | doctype | | 0 | 0
250 + | name | | |
251 + | | | |
252 +
253 * The xwphelpers implementation does not implement CDATA sections,
254 * for which we have no need because @expat properly converts these
255 * into plain @content.
256 *
257 * In addition, W3C DOM specifies that the "node name" members contain
258 * "#document", "#text", and "#comment" strings for DOCUMENT,
259 * TEXT, and COMMENT nodes, respectively. I see no point in this other
260 * than consuming memory, so these fields are empty with this implementation.
261 */
262
263 typedef struct _DOMNODE
264 {
265 NODEBASE NodeBase;
266
267 PXSTRING pstrNodeValue; // ptr is NULL if none
268
269 struct _DOMNODE *pParentNode;
270 // the parent node;
271 // NULL for DOCUMENT, DOCUMENT_FRAGMENT.
272 // The DOM spec says that attribs have no parent,
273 // but even though the attribute is not added to
274 // the "children" list of an element (but to the
275 // attributes map instead), we specify the element
276 // as the attribute's parent here.
277
278 struct _DOMNODE *pDocumentNode;
279 // the document node, unless this is a DOCUMENT in itself.
280
281 LINKLIST llChildren; // of DOMNODE* pointers, no auto-free
282
283 TREE *AttributesMap; // of DOMNODE* pointers
284
285 } DOMNODE, *PDOMNODE;
286
287 /*
288 *@@ DOMDOCTYPENODE:
289 * specific _DOMNODE replacement structure which
290 * is used for DOCTYPE nodes.
291 *
292 * The DOMDOCTYPENODE is special (other than having
293 * extra fields) in that it is stored both in
294 * the document node's children list and in its
295 * pDocType field.
296 *
297 * DOMNODE.pstrNodeName is set to the name in the
298 * DOCTYPE statement by xmlCreateDocumentTypeNode,
299 * or is NULL if there's no DOCTYPE.
300 *
301 *@@added V0.9.9 (2001-02-14) [umoeller]
302 */
303
304 typedef struct _DOMDOCTYPENODE
305 {
306 DOMNODE DomNode;
307
308 XSTRING strPublicID;
309 XSTRING strSystemID;
310
311 BOOL fHasInternalSubset;
312
313 TREE *ElementDeclsTree;
314 // tree with pointers to _CMELEMENTDECLNODE nodes
315
316 TREE *AttribDeclBasesTree;
317 // tree with pointers to _CMATTRIBUTEDECLBASE nodes
318
319 } DOMDOCTYPENODE, *PDOMDOCTYPENODE;
320
321 /*
322 *@@ DOMDOCUMENTNODE:
323 * specific _DOMNODE replacement structure which
324 * is used for DOCUMENT nodes.
325 *
326 *@@added V0.9.9 (2001-02-14) [umoeller]
327 */
328
329 typedef struct _DOMDOCUMENTNODE
330 {
331 DOMNODE DomNode;
332
333 PDOMDOCTYPENODE pDocType;
334 // != NULL if DOCTYPE was found
335
336 } DOMDOCUMENTNODE, *PDOMDOCUMENTNODE;
337
338 APIRET xmlCreateDomNode(PDOMNODE pParentNode,
339 NODEBASETYPE ulNodeType,
340 const char *pcszNodeName,
341 ULONG ulNodeNameLength,
342 PDOMNODE *ppNew);
343
344 VOID xmlDeleteNode(PNODEBASE pNode);
345
346 /* ******************************************************************
347 *
348 * Specific DOM node constructors
349 *
350 ********************************************************************/
351
352 APIRET xmlCreateElementNode(PDOMNODE pParent,
353 const char *pcszElement,
354 PDOMNODE *ppNew);
355
356 APIRET xmlCreateAttributeNode(PDOMNODE pElement,
357 const char *pcszName,
358 const char *pcszValue,
359 PDOMNODE *ppNew);
360
361 APIRET xmlCreateTextNode(PDOMNODE pParent,
362 const char *pcszText,
363 ULONG ulLength,
364 PDOMNODE *ppNew);
365
366 APIRET xmlCreateCommentNode(PDOMNODE pParent,
367 const char *pcszText,
368 PDOMNODE *ppNew);
369
370 APIRET xmlCreatePINode(PDOMNODE pParent,
371 const char *pcszTarget,
372 const char *pcszData,
373 PDOMNODE *ppNew);
374
375 APIRET xmlCreateDocumentTypeNode(PDOMDOCUMENTNODE pDocumentNode,
376 const char *pcszDoctypeName,
377 const char *pcszSysid,
378 const char *pcszPubid,
379 int fHasInternalSubset,
380 PDOMDOCTYPENODE *ppNew);
381
382 /* ******************************************************************
383 *
384 * DOM level 3 content models
385 *
386 ********************************************************************/
387
388 // data types (XML schemes):
389 #define STRING_DATATYPE 1
390 #define BOOLEAN_DATATYPE 2
391 #define FLOAT_DATATYPE 3
392 #define DOUBLE_DATATYPE 4
393 #define LONG_DATATYPE 5
394 #define INT_DATATYPE 6
395 #define SHORT_DATATYPE 7
396 #define BYTE_DATATYPE 8
397
398 /*
399 *@@ CMELEMENTPARTICLE:
400 * element declaration particle in a
401 * _CMELEMENTDECLNODE.
402 *
403 * One of these structures is a full
404 * (non-pointer) member in _CMELEMENTDECLNODE.
405 * This struct in turn has a linked list with
406 * possible subnodes. See _CMELEMENTDECLNODE.
407 *
408 *@@added V0.9.9 (2001-02-16) [umoeller]
409 */
410
411 typedef struct _CMELEMENTPARTICLE
412 {
413 NODEBASE NodeBase; // has TREE* as first item in turn
414 // NODEBASE.ulNodeType may be one of these:
415 // -- ELEMENTPARTICLE_EMPTY:
416 // ulRepeater will be XML_CQUANT_NONE, rest is NULL
417 // -- ELEMENTPARTICLE_ANY:
418 // ulRepeater will be XML_CQUANT_NONE, rest is NULL
419 // -- ELEMENTPARTICLE_MIXED:
420 // mixed content (with PCDATA); if the list contains
421 // something, the element may have PCDATA and sub-elements
422 // mixed
423 // -- ELEMENTPARTICLE_CHOICE:
424 // list is a choicelist
425 // -- ELEMENTPARTICLE_SEQ:
426 // list is a seqlist
427 // -- ELEMENTPARTICLE_NAME:
428 // used for terminal particles in a parent particle's
429 // list, which finally specifies the name of a sub-particle.
430 // This can never appear in a root particle.
431
432 ULONG ulRepeater;
433 // one of:
434 // -- XML_CQUANT_NONE --> all fields below are NULL
435 // -- XML_CQUANT_OPT, question mark
436 // -- XML_CQUANT_REP, asterisk
437 // -- XML_CQUANT_PLUS plus sign
438
439 struct _CMELEMENTPARTICLE *pParentParticle; // or NULL if this is in the
440 // CMELEMENTDECLNODE
441
442 PLINKLIST pllSubNodes;
443 // linked list of sub-CMELEMENTPARTICLE structs
444 // (for mixed, choice, seq types);
445 // if NULL, there's no sub-CMELEMENTPARTICLE
446
447 } CMELEMENTPARTICLE, *PCMELEMENTPARTICLE;
448
449 /*
450 *@@ CMELEMENTDECLNODE:
451 * representation of an @element_declaration within a
452 * _DOMDOCTYPENODE (a document @DTD).
453 *
454 * This is complicated because element declarations
455 * are complicated with nested lists and content
456 * particles. For this, we introduce the representation
457 * of a _CMELEMENTPARTICLE, which is contained in the
458 * "Particle" member.
459 *
460 * For minimal memory consumption, the _CMELEMENTDECLNODE
461 * is an _CMELEMENTPARTICLE with extra fields, while the
462 * list in _CMELEMENTPARTICLE points to plain
463 * _CMELEMENTPARTICLE structs only.
464 *
465 * For the "root" element declaration in the DTD,
466 * Particle.NODEBASE.ulNodeType will always be one of the following:
467 *
468 * -- ELEMENTPARTICLE_EMPTY: element must be empty.
469 *
470 * -- ELEMENTPARTICLE_ANY: element can have any content.
471 *
472 * -- ELEMENTPARTICLE_CHOICE: _CMELEMENTPARTICLE has a choicelist with
473 * more _CMELEMENTPARTICLE structs.
474 *
475 * -- ELEMENTPARTICLE_SEQ: _CMELEMENTPARTICLE has a seqlist with
476 * more _CMELEMENTPARTICLE structs.
477 *
478 * -- ELEMENTPARTICLE_MIXED: element can have mixed content including #PCDATA.
479 * If there is no content particle list, then the element may
480 * ONLY have PCDATA. If there's a content particle list, then the
481 * element may have both sub-elements and PCDATA. Oh my.
482 *
483 *@@added V0.9.9 (2001-02-14) [umoeller]
484 */
485
486 typedef struct _CMELEMENTDECLNODE
487 {
488 CMELEMENTPARTICLE Particle;
489 // root particle for this element decl; this may contain
490 // sub-particles...
491 // this has a NODEBASE as first member, which has TREE* as
492 // first item in turn
493
494 TREE *ParticleNamesTree;
495 // tree sorted by element names with all sub-particles,
496 // no matter how deeply nested; this is just for quickly
497 // checking if an element name is allowed as a sub-element
498 // at all. Tree items are _CMELEMENTPARTICLE nodes.
499
500 } CMELEMENTDECLNODE, *PCMELEMENTDECLNODE;
501
502 typedef enum _ATTRIBCONSTRAINT
503 {
504 CMAT_IMPLIED,
505 CMAT_REQUIRED,
506 CMAT_DEFAULT_VALUE,
507 CMAT_FIXED_VALUE
508 } ATTRIBCONSTRAINT;
509
510 typedef enum _ATTRIBTYPE
511 {
512 CMAT_CDATA,
513 CMAT_ID,
514 CMAT_IDREF,
515 CMAT_IDREFS,
516 CMAT_ENTITY,
517 CMAT_ENTITIES,
518 CMAT_NMTOKEN,
519 CMAT_NMTOKENS,
520 CMAT_ENUM
521 } ATTRIBTYPE;
522
523 /*
524 *@@ CMATTRIBUTEDECL:
525 * single attribute declaration within the attribute
526 * declarations tree in _CMATTRIBUTEDECLBASE.
527 *
528 *@@added V0.9.9 (2001-02-16) [umoeller]
529 */
530
531 typedef struct _CMATTRIBUTEDECL
532 {
533 NODEBASE NodeBase; // has TREE* as first item in turn
534 // NodeBase.strName is attribute name
535
536 ATTRIBTYPE ulAttrType;
537 // one of:
538 // -- CMAT_CDATA
539 // -- CMAT_ID
540 // -- CMAT_IDREF
541 // -- CMAT_IDREFS
542 // -- CMAT_ENTITY
543 // -- CMAT_ENTITIES
544 // -- CMAT_NMTOKEN
545 // -- CMAT_NMTOKENS
546 // -- CMAT_ENUM: pllEnum lists the allowed values.
547 TREE *ValuesTree;
548 // enumeration of allowed values, if CMAT_ENUM;
549 // tree entries are plain NODEBASEs with
550 // ATTRIBUTE_DECLARATION_ENUM type
551
552 ATTRIBCONSTRAINT ulConstraint;
553 // one of:
554 // -- CMAT_IMPLIED: attrib can have any value.
555 // -- CMAT_REQUIRED: attrib must be specified.
556 // -- CMAT_DEFAULT_VALUE: attrib is optional and has default
557 // value as in pstrDefaultValue.
558 // -- CMAT_FIXED_VALUE: attrib is optional, but must have
559 // fixed value as in pstrDefaultValue.
560 PXSTRING pstrDefaultValue;
561 // default value of this attribute; NULL with implied or required
562
563 } CMATTRIBUTEDECL, *PCMATTRIBUTEDECL;
564
565 /*
566 *@@ CMATTRIBUTEDECLBASE:
567 * representation of an @attribute_declaration.
568 *
569 * I'd love to have stored the attribute declarations with
570 * the element specifications, but the XML spec says that
571 * attribute declarations are allowed even if no element
572 * declaration exists for the element to which the attribute
573 * belongs. Now, whatever this is good for... anyway, this
574 * forces us to do a second tree in the _DOMDOCTYPENODE node
575 * according to attribute's element names.
576 *
577 *@@added V0.9.9 (2001-02-14) [umoeller]
578 */
579
580 typedef struct _CMATTRIBUTEDECLBASE
581 {
582 NODEBASE NodeBase; // has TREE* as first item in turn
583 // NodeBase.strName is element name
584
585 TREE *AttribDeclsTree;
586 // root of tree with CMATTRIBUTEDECL;
587
588 } CMATTRIBUTEDECLBASE, *PCMATTRIBUTEDECLBASE;
589
590 /*
591 *@@ CMENTITYDECLNODE:
592 *
593 * See @entity_declaration.
594 *
595 *@@added V0.9.9 (2001-02-14) [umoeller]
596 */
597
598 typedef struct _CMENTITYDECLNODE
599 {
600 NODEBASE NodeBase;
601 } CMENTITYDECLNODE, *PCMENTITYDECLNODE;
602
603 /*
604 *@@ CMNOTATIONDECLNODE:
605 *
606 * See @notation_declaration.
607 *
608 *@@added V0.9.9 (2001-02-14) [umoeller]
609 */
610
611 typedef struct _CMNOTATIONDECLNODE
612 {
613 NODEBASE NodeBase;
614 } CMNOTATIONDECLNODE, *PCMNOTATIONDECLNODE;
615
616 APIRET xmlCreateElementDecl(const char *pcszName,
617 PXMLCONTENT pModel,
618 PCMELEMENTDECLNODE *ppNew);
619
620 /* ******************************************************************
621 *
622 * DOM parser APIs
623 *
624 ********************************************************************/
625
626 typedef struct _XMLDOM *PXMLDOM;
627
628 typedef int APIENTRY FNGETCPDATA(PXMLDOM pDom, ULONG ulCP, int *piMap);
629 typedef FNGETCPDATA *PFNGETCPDATA;
630
631 typedef APIRET APIENTRY FNEXTERNALHANDLER(PXMLDOM pDom,
632 XML_Parser pSubParser,
633 const char *pcszSystemID,
634 const char *pcszPublicID);
635 typedef FNEXTERNALHANDLER *PFNEXTERNALHANDLER;
636
637 /*
638 *@@ XMLDOM:
639 * DOM instance returned by xmlCreateDOM.
640 *
641 *@@added V0.9.9 (2001-02-14) [umoeller]
642 */
643
644 typedef struct _XMLDOM
645 {
646 /*
647 * Public fields (should be read only)
648 */
649
650 PDOMDOCUMENTNODE pDocumentNode;
651 // document node (contains all the elements)
652
653 PDOMDOCTYPENODE pDocTypeNode;
654 // != NULL only if the document has a DOCTYPE
655
656 // error handling
657 APIRET arcDOM; // validation errors etc.;
658 // if != 0, this has a detailed
659 // expat or DOM error code
660 BOOL fInvalid; // TRUE if validation failed
661 // (parser error otherwise)
662
663 const char *pcszErrorDescription; // error description
664 PXSTRING pxstrSystemID; // system ID of external entity
665 // where error occured, or NULL
666 // if in main document
667 ULONG ulErrorLine; // line where error occured
668 ULONG ulErrorColumn; // column where error occured
669 PXSTRING pxstrFailingNode; // element or attribute name
670 // or NULL
671
672 /*
673 * Private fields (for xml* functions)
674 */
675
676 // params copied from xmlCreateDOM
677 ULONG flParserFlags;
678 PFNGETCPDATA pfnGetCPData;
679 PFNEXTERNALHANDLER pfnExternalHandler;
680 PVOID pvCallbackUser;
681
682 XML_Parser pParser;
683 // expat parser instance
684
685 LINKLIST llElementStack;
686 // stack for maintaining the current items;
687 // these point to DOMSTACKITEMs (auto-free)
688
689 PDOMNODE pLastWasTextNode;
690
691 PCMATTRIBUTEDECLBASE pAttListDeclCache;
692 // cache for attribute declarations according
693 // to attdecl element name
694 } XMLDOM;
695
696 #define DF_PARSECOMMENTS 0x0001
697 #define DF_PARSEDTD 0x0002
698 #define DF_FAIL_IF_NO_DTD 0x0004
699 #define DF_DROP_WHITESPACE 0x0008
700
701 APIRET xmlCreateDOM(ULONG flParserFlags,
702 PFNGETCPDATA pfnGetCPData,
703 PFNEXTERNALHANDLER pfnExternalHandler,
704 PVOID pvCallbackUser,
705 PXMLDOM *ppDom);
706
707 APIRET xmlParse(PXMLDOM pDom,
708 const char *pcszBuf,
709 ULONG cb,
710 BOOL fIsLast);
711
712 APIRET xmlFreeDOM(PXMLDOM pDom);
713
714 /* ******************************************************************
715 *
716 * DOM lookup
717 *
718 ********************************************************************/
719
720 PCMELEMENTDECLNODE xmlFindElementDecl(PXMLDOM pDom,
721 const XSTRING *pcszElementName);
722
723 PCMATTRIBUTEDECLBASE xmlFindAttribDeclBase(PXMLDOM pDom,
724 const XSTRING *pstrElementName);
725
726 PCMATTRIBUTEDECL xmlFindAttribDecl(PXMLDOM pDom,
727 const XSTRING *pstrElementName,
728 const XSTRING *pstrAttribName,
729 PCMATTRIBUTEDECLBASE *ppAttribDeclBase);
730
731 PDOMNODE xmlGetRootElement(PXMLDOM pDom);
732
733 PDOMNODE xmlGetFirstChild(PDOMNODE pDomNode);
734
735 PDOMNODE xmlGetLastChild(PDOMNODE pDomNode);
736
737 PDOMNODE xmlGetFirstText(PDOMNODE pElement);
738
739 PLINKLIST xmlGetElementsByTagName(PDOMNODE pParent,
740 const char *pcszName);
741
742 const XSTRING* xmlGetAttribute(PDOMNODE pElement,
743 const char *pcszAttribName);
744
745 /* ******************************************************************
746 *
747 * DOM build
748 *
749 ********************************************************************/
750
751 APIRET xmlCreateDocument(const char *pcszRootElementName,
752 PDOMDOCUMENTNODE *ppDocument,
753 PDOMNODE *ppRootElement);
754
755 APIRET xmlWriteDocument(PDOMDOCUMENTNODE pDocument,
756 const char *pcszEncoding,
757 const char *pcszDoctype,
758 PXSTRING pxstr);
759#endif
760
761#if __cplusplus
762}
763#endif
764
Note: See TracBrowser for help on using the repository browser.