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

Last change on this file since 85 was 84, checked in by umoeller, 24 years ago

Many misc updates.

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