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

Last change on this file since 346 was 265, checked in by pr, 21 years ago

Fixed spelling errors.

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