xmlschemas

xmlschemas —

Synopsis




enum        xmlSchemaValidError;
struct      xmlSchema;
typedef     xmlSchemaPtr;
void        (*xmlSchemaValidityErrorFunc)   (void *ctx,
                                             const char *msg,
                                             ...);
void        (*xmlSchemaValidityWarningFunc) (void *ctx,
                                             const char *msg,
                                             ...);
struct      xmlSchemaParserCtxt;
typedef     xmlSchemaParserCtxtPtr;
struct      xmlSchemaValidCtxt;
typedef     xmlSchemaValidCtxtPtr;
xmlSchemaParserCtxtPtr xmlSchemaNewParserCtxt
                                            (const char *URL);
xmlSchemaParserCtxtPtr xmlSchemaNewMemParserCtxt
                                            (const char *buffer,
                                             int size);
void        xmlSchemaFreeParserCtxt         (xmlSchemaParserCtxtPtr ctxt);
void        xmlSchemaSetParserErrors        (xmlSchemaParserCtxtPtr ctxt,
                                             xmlSchemaValidityErrorFunc err,
                                             xmlSchemaValidityWarningFunc warn,
                                             void *ctx);
xmlSchemaPtr xmlSchemaParse                 (xmlSchemaParserCtxtPtr ctxt);
void        xmlSchemaFree                   (xmlSchemaPtr schema);
void        xmlSchemaDump                   (FILE *output,
                                             xmlSchemaPtr schema);
void        xmlSchemaSetValidErrors         (xmlSchemaValidCtxtPtr ctxt,
                                             xmlSchemaValidityErrorFunc err,
                                             xmlSchemaValidityWarningFunc warn,
                                             void *ctx);
xmlSchemaValidCtxtPtr xmlSchemaNewValidCtxt (xmlSchemaPtr schema);
void        xmlSchemaFreeValidCtxt          (xmlSchemaValidCtxtPtr ctxt);
int         xmlSchemaValidateDoc            (xmlSchemaValidCtxtPtr ctxt,
                                             xmlDocPtr instance);
int         xmlSchemaValidateStream         (xmlSchemaValidCtxtPtr ctxt,
                                             xmlParserInputBufferPtr input,
                                             xmlCharEncoding enc,
                                             xmlSAXHandlerPtr sax,
                                             void *user_data);

Description

Details

enum xmlSchemaValidError

typedef enum {
    XML_SCHEMAS_ERR_OK		= 0,
    XML_SCHEMAS_ERR_NOROOT	= 1,
    XML_SCHEMAS_ERR_UNDECLAREDELEM,
    XML_SCHEMAS_ERR_NOTTOPLEVEL,
    XML_SCHEMAS_ERR_MISSING,
    XML_SCHEMAS_ERR_WRONGELEM,
    XML_SCHEMAS_ERR_NOTYPE,
    XML_SCHEMAS_ERR_NOROLLBACK,
    XML_SCHEMAS_ERR_ISABSTRACT,
    XML_SCHEMAS_ERR_NOTEMPTY,
    XML_SCHEMAS_ERR_ELEMCONT,
    XML_SCHEMAS_ERR_HAVEDEFAULT,
    XML_SCHEMAS_ERR_NOTNILLABLE,
    XML_SCHEMAS_ERR_EXTRACONTENT,
    XML_SCHEMAS_ERR_INVALIDATTR,
    XML_SCHEMAS_ERR_INVALIDELEM,
    XML_SCHEMAS_ERR_NOTDETERMINIST,
    XML_SCHEMAS_ERR_CONSTRUCT,
    XML_SCHEMAS_ERR_INTERNAL,
    XML_SCHEMAS_ERR_NOTSIMPLE,
    XML_SCHEMAS_ERR_ATTRUNKNOWN,
    XML_SCHEMAS_ERR_ATTRINVALID,
    XML_SCHEMAS_ERR_VALUE,
    XML_SCHEMAS_ERR_FACET,
    XML_SCHEMAS_ERR_,
    XML_SCHEMAS_ERR_XXX
} xmlSchemaValidError;


struct xmlSchema

struct xmlSchema {

    xmlChar *name;        /* schema name */
    xmlChar *targetNamespace;     /* the target namespace */
    xmlChar *version;
    xmlChar *id;
    xmlDocPtr doc;
    xmlSchemaAnnotPtr annot;
    int flags;

    xmlHashTablePtr typeDecl;
    xmlHashTablePtr attrDecl;
    xmlHashTablePtr attrgrpDecl;
    xmlHashTablePtr elemDecl;
    xmlHashTablePtr notaDecl;

    xmlHashTablePtr schemasImports;

    void *_private;	/* unused by the library for users or bindings */
    xmlHashTablePtr groupDecl;
};


xmlSchemaPtr

typedef xmlSchema *xmlSchemaPtr;


xmlSchemaValidityErrorFunc ()

void        (*xmlSchemaValidityErrorFunc)   (void *ctx,
                                             const char *msg,
                                             ...);

ctx :
msg :
... :

xmlSchemaValidityWarningFunc ()

void        (*xmlSchemaValidityWarningFunc) (void *ctx,
                                             const char *msg,
                                             ...);

ctx :
msg :
... :

struct xmlSchemaParserCtxt

struct xmlSchemaParserCtxt;


xmlSchemaParserCtxtPtr

typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr;


struct xmlSchemaValidCtxt

struct xmlSchemaValidCtxt;

A Schemas validation context


xmlSchemaValidCtxtPtr

typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;


xmlSchemaNewParserCtxt ()

xmlSchemaParserCtxtPtr xmlSchemaNewParserCtxt
                                            (const char *URL);

Create an XML Schemas parse context for that file/resource expected to contain an XML Schemas file.

URL : the location of the schema
Returns :the parser context or NULL in case of error

xmlSchemaNewMemParserCtxt ()

xmlSchemaParserCtxtPtr xmlSchemaNewMemParserCtxt
                                            (const char *buffer,
                                             int size);

Create an XML Schemas parse context for that memory buffer expected to contain an XML Schemas file.

buffer : a pointer to a char array containing the schemas
size : the size of the array
Returns :the parser context or NULL in case of error

xmlSchemaFreeParserCtxt ()

void        xmlSchemaFreeParserCtxt         (xmlSchemaParserCtxtPtr ctxt);

Free the resources associated to the schema parser context

ctxt : the schema parser context

xmlSchemaSetParserErrors ()

void        xmlSchemaSetParserErrors        (xmlSchemaParserCtxtPtr ctxt,
                                             xmlSchemaValidityErrorFunc err,
                                             xmlSchemaValidityWarningFunc warn,
                                             void *ctx);

Set the callback functions used to handle errors for a validation context

ctxt : a schema validation context
err : the error callback
warn : the warning callback
ctx : contextual data for the callbacks

xmlSchemaParse ()

xmlSchemaPtr xmlSchemaParse                 (xmlSchemaParserCtxtPtr ctxt);

parse a schema definition resource and build an internal XML Shema struture which can be used to validate instances. *WARNING* this interface is highly subject to change

ctxt : a schema validation context
Returns :the internal XML Schema structure built from the resource or NULL in case of error

xmlSchemaFree ()

void        xmlSchemaFree                   (xmlSchemaPtr schema);

Deallocate a Schema structure.

schema : a schema structure

xmlSchemaDump ()

void        xmlSchemaDump                   (FILE *output,
                                             xmlSchemaPtr schema);

Dump a Schema structure.

output : the file output
schema : a schema structure

xmlSchemaSetValidErrors ()

void        xmlSchemaSetValidErrors         (xmlSchemaValidCtxtPtr ctxt,
                                             xmlSchemaValidityErrorFunc err,
                                             xmlSchemaValidityWarningFunc warn,
                                             void *ctx);

Set the error and warning callback informations

ctxt : a schema validation context
err : the error function
warn : the warning function
ctx : the functions context

xmlSchemaNewValidCtxt ()

xmlSchemaValidCtxtPtr xmlSchemaNewValidCtxt (xmlSchemaPtr schema);

Create an XML Schemas validation context based on the given schema

schema : a precompiled XML Schemas
Returns :the validation context or NULL in case of error

xmlSchemaFreeValidCtxt ()

void        xmlSchemaFreeValidCtxt          (xmlSchemaValidCtxtPtr ctxt);

Free the resources associated to the schema validation context

ctxt : the schema validation context

xmlSchemaValidateDoc ()

int         xmlSchemaValidateDoc            (xmlSchemaValidCtxtPtr ctxt,
                                             xmlDocPtr instance);

Validate a document tree in memory.

ctxt : a schema validation context
instance :
Returns :0 if the document is schemas valid, a positive error code number otherwise and -1 in case of internal or API error.

xmlSchemaValidateStream ()

int         xmlSchemaValidateStream         (xmlSchemaValidCtxtPtr ctxt,
                                             xmlParserInputBufferPtr input,
                                             xmlCharEncoding enc,
                                             xmlSAXHandlerPtr sax,
                                             void *user_data);

Validate a document tree in memory.

ctxt : a schema validation context
input : the input to use for reading the data
enc : an optional encoding information
sax : a SAX handler for the resulting events
user_data : the context to provide to the SAX handler.
Returns :0 if the document is schemas valid, a positive error code number otherwise and -1 in case of internal or API error.