relaxng.h 3.67 KB
Newer Older
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
/*
 * relaxng.h: header for the implementation of the Relax-NG validation
 *
 * See Copyright for the status of this software.
 *
 * daniel@veillard.com
 */

#ifndef __XML_RELAX_NG__
#define __XML_RELAX_NG__

#include <libxml/hash.h>

typedef struct _xmlRelaxNG xmlRelaxNG;
typedef xmlRelaxNG *xmlRelaxNGPtr;


/**
 * A schemas validation context
 */
typedef void (*xmlRelaxNGValidityErrorFunc) (void *ctx, const char *msg, ...);
typedef void (*xmlRelaxNGValidityWarningFunc) (void *ctx, const char *msg, ...);

typedef struct _xmlRelaxNGParserCtxt xmlRelaxNGParserCtxt;
typedef xmlRelaxNGParserCtxt *xmlRelaxNGParserCtxtPtr;

typedef struct _xmlRelaxNGValidCtxt xmlRelaxNGValidCtxt;
typedef xmlRelaxNGValidCtxt *xmlRelaxNGValidCtxtPtr;

30 31 32 33 34 35 36 37 38 39
/*
 * xmlRelaxNGValidErr:
 *
 * List of possible Relax NG validation errors
 */
typedef enum {
    XML_RELAXNG_OK = 0,
    XML_RELAXNG_ERR_MEMORY,
    XML_RELAXNG_ERR_TYPE,
    XML_RELAXNG_ERR_TYPEVAL,
40
    XML_RELAXNG_ERR_DUPID,
41 42 43 44
    XML_RELAXNG_ERR_TYPECMP,
    XML_RELAXNG_ERR_NOSTATE,
    XML_RELAXNG_ERR_NODEFINE,
    XML_RELAXNG_ERR_LISTEXTRA,
45
    XML_RELAXNG_ERR_LISTEMPTY,
46 47 48 49
    XML_RELAXNG_ERR_INTERNODATA,
    XML_RELAXNG_ERR_INTERSEQ,
    XML_RELAXNG_ERR_INTEREXTRA,
    XML_RELAXNG_ERR_ELEMNAME,
50
    XML_RELAXNG_ERR_ATTRNAME,
51
    XML_RELAXNG_ERR_ELEMNONS,
52
    XML_RELAXNG_ERR_ATTRNONS,
53
    XML_RELAXNG_ERR_ELEMWRONGNS,
54
    XML_RELAXNG_ERR_ATTRWRONGNS,
55
    XML_RELAXNG_ERR_ELEMEXTRANS,
56
    XML_RELAXNG_ERR_ATTREXTRANS,
57 58 59 60 61 62 63 64 65 66 67 68 69 70
    XML_RELAXNG_ERR_ELEMNOTEMPTY,
    XML_RELAXNG_ERR_NOELEM,
    XML_RELAXNG_ERR_NOTELEM,
    XML_RELAXNG_ERR_ATTRVALID,
    XML_RELAXNG_ERR_CONTENTVALID,
    XML_RELAXNG_ERR_EXTRACONTENT,
    XML_RELAXNG_ERR_INVALIDATTR,
    XML_RELAXNG_ERR_DATAELEM,
    XML_RELAXNG_ERR_VALELEM,
    XML_RELAXNG_ERR_LISTELEM,
    XML_RELAXNG_ERR_DATATYPE,
    XML_RELAXNG_ERR_VALUE,
    XML_RELAXNG_ERR_LIST,
    XML_RELAXNG_ERR_NOGRAMMAR,
71
    XML_RELAXNG_ERR_EXTRADATA,
72
    XML_RELAXNG_ERR_LACKDATA,
73 74 75
    XML_RELAXNG_ERR_INTERNAL,
    XML_RELAXNG_ERR_ELEMWRONG,
    XML_RELAXNG_ERR_TEXTWRONG
76 77
} xmlRelaxNGValidErr;

78 79 80 81 82 83
/*
 * Interfaces for parsing.
 */
xmlRelaxNGParserCtxtPtr xmlRelaxNGNewParserCtxt	(const char *URL);
xmlRelaxNGParserCtxtPtr xmlRelaxNGNewMemParserCtxt(const char *buffer,
						 int size);
84 85
xmlRelaxNGParserCtxtPtr xmlRelaxNGNewDocParserCtxt(xmlDocPtr doc);

86 87 88 89 90 91 92 93 94
void		xmlRelaxNGFreeParserCtxt	(xmlRelaxNGParserCtxtPtr ctxt);
void		xmlRelaxNGSetParserErrors(xmlRelaxNGParserCtxtPtr ctxt,
					 xmlRelaxNGValidityErrorFunc err,
					 xmlRelaxNGValidityWarningFunc warn,
					 void *ctx);
xmlRelaxNGPtr	xmlRelaxNGParse		(xmlRelaxNGParserCtxtPtr ctxt);
void		xmlRelaxNGFree		(xmlRelaxNGPtr schema);
void		xmlRelaxNGDump		(FILE *output,
					 xmlRelaxNGPtr schema);
95 96
void		xmlRelaxNGDumpTree	(FILE * output,
					 xmlRelaxNGPtr schema);
97 98 99 100 101 102 103 104 105 106
/*
 * Interfaces for validating
 */
void		xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,
					 xmlRelaxNGValidityErrorFunc err,
					 xmlRelaxNGValidityWarningFunc warn,
					 void *ctx);
xmlRelaxNGValidCtxtPtr	xmlRelaxNGNewValidCtxt	(xmlRelaxNGPtr schema);
void			xmlRelaxNGFreeValidCtxt	(xmlRelaxNGValidCtxtPtr ctxt);
int			xmlRelaxNGValidateDoc	(xmlRelaxNGValidCtxtPtr ctxt,
107
					 	 xmlDocPtr doc);
108
void			xmlRelaxNGCleanupTypes	(void);
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
/*
 * Interfaces for progressive validation when possible
 */
int	xmlRelaxNGValidatePushElement	(xmlRelaxNGValidCtxtPtr ctxt,
					 xmlDocPtr doc,
					 xmlNodePtr elem);
int	xmlRelaxNGValidatePushCData	(xmlRelaxNGValidCtxtPtr ctxt,
					 const xmlChar *data,
					 int len);
int	xmlRelaxNGValidatePopElement	(xmlRelaxNGValidCtxtPtr ctxt,
					 xmlDocPtr doc,
					 xmlNodePtr elem);
int	xmlRelaxNGValidateFullElement	(xmlRelaxNGValidCtxtPtr ctxt,
					 xmlDocPtr doc,
					 xmlNodePtr elem);
124
#endif /* __XML_RELAX_NG__ */