-
Notifications
You must be signed in to change notification settings - Fork 1
/
parsexsd.h
69 lines (54 loc) · 1.59 KB
/
parsexsd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* parsexsd.h : Walk the xsd tree as provided by libxml
*
*
* Copyright (c) 2018 Ram Gopalkrisha [email protected] */
#ifndef XML2JSON_XSD_H
#define XML2JSON_XSD_H
#endif
#define LIBXML_SCHEMAS_ENABLED
#include <libxml/xmlschemastypes.h>
#include <libxml/schemasInternals.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <errno.h>
#ifdef __cplusplus
extern "C" {
#endif
/*prototypes */
xmlChar* getMinOccurs(xmlNodePtr node);
xmlChar* getMaxOccurs(xmlNodePtr node);
extern void print_array_elements(void);
xmlChar* getElementName(xmlNodePtr node);
xmlChar* getSchemaName(xmlNodePtr node);
xmlChar* getComplexTypeName(xmlNodePtr node);
xmlChar* getType(xmlNodePtr node);
extern int walkXsdSchema(xmlNodePtr root);
extern void xsdschemafree(void);
int buildArrayTree(xmlChar* complexName, xmlChar* elemName, xmlChar* minO,
xmlChar* maxO, xmlChar* type);
/* Array type - based on the min/max combinations following are the outcomes */
enum arraytype {
SINGLE_ELEMENT,
OPTIONAL_OR_ARRAY,
MANDATORY_AND_ARRAY,
};
/* Struct to hold elements which are defined as arrays from XSD
*
* TODO: For now it's in a struct - the primary reason for this is not to walk
* the XSD for each element with in XML, find a better way of internal
* representation
*/
struct xmlArrayDef {
xmlChar* complexName;
xmlChar* elemName;
xmlChar* type;
long minOccurs;
int maxOccurs;
enum arraytype isArray;
struct xmlArrayDef *next;
};
typedef struct xmlArrayDef *xmlArrayDefPtr;
#ifdef __cplusplus
}
#endif