Packages: All | Callback | DOM | Range | SAX | Schema | Traversal | XML | XPath | XPointer | XSLT | XSLTVM | Functions | Datatypes |
Function | Description |
---|---|
XmlSchemaClean | |
XmlSchemaCreate | Create and return a schema context |
XmlSchemaDestroy | Destroy a schema context |
XmlSchemaErrorWhere | |
XmlSchemaLoad | Load a schema document |
XmlSchemaLoadedList | Return the size and/or list of loaded schema documents. |
XmlSchemaSetErrorHandler | |
XmlSchemaSetValidateOptions | Set option(s) to be used in the next validation session |
XmlSchemaTargetNamespace | Return target namespace of a given schema document |
XmlSchemaUnload | Unload a schema document |
XmlSchemaValidate | Validate an element node against a schema |
XmlSchemaVersion | Return the version of this schema implementation |
Name | XmlSchemaClean | |||
---|---|---|---|---|
Interface | Schema | |||
Purpose | ||||
Prototype | void XmlSchemaClean(xsdctx *sctx); | |||
Arguments |
| |||
Returns | void | |||
Description | Clean up loaded schemas in a schema context and recycle the schema
context.
| |||
Example | ... xctx = XmlCreate(&xerr, (oratext *) "tlsx2", "data_encoding", outcoding, NULL); if (xerr) DISCARD printf("Failed to initialze XML meta context, error %u\n", (unsigned) xerr); return 1; ... if (!(scctx = XmlSchemaCreate(xctx, &xerr, NULL))) DISCARD printf("Failed, code %u!\n", xerr); return 2; for (i = startNo; i <= endNo; i++) sprintf(schema, "tlsx%d.xsd", i); sprintf(doc, "tlsx%d.xml", i); if (xerr = XmlSchemaLoad(scctx, (oratext *)schema, NULL)) DISCARD printf("Assessement of %s failed, error %u\n", schema, (unsigned) xerr); XmlSchemaClean(scctx); continue; if (!(docnode = XmlLoadDom(xctx, &xerr, "uri", doc, "default_input_encoding", incoding, NULL))) DISCARD printf("Parse of %s failed, error %u\n", doc, (unsigned) xerr); XmlFreeDocument(xctx, docnode); XmlSchemaClean(scctx); continue; root = XmlDomGetDocElem(xctx, docnode); if (xerr = XmlSchemaValidate(scctx, xctx, root)) DISCARD printf("Validation of %s failed, error %u\n", doc, (unsigned) xerr); else DISCARD stlptf("Document %s is valid.\n", doc); XmlFreeDocument(xctx, docnode); XmlSchemaClean(scctx); XmlSchemaDestroy(scctx); XmlDestroy(xctx); return 0; | |||
See Also | XmlSchemaCreate, XmlSchemaDestroy |
Name | XmlSchemaCreate | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Interface | Schema | |||||||||
Purpose | Create and return a schema context | |||||||||
Prototype | xsdctx *XmlSchemaCreate(xmlctx *xctx, xmlerr *err, ...); | |||||||||
Arguments |
| |||||||||
Returns | (xsdctx *) schema context | |||||||||
Description | Return a schema context to be used in other validator APIs. This
needs to be paired with an XmlSchemaDestroy.
| |||||||||
See Also | XmlSchemaDestroy, XmlCreate |
Name | XmlSchemaDestroy | |||
---|---|---|---|---|
Interface | Schema | |||
Purpose | Destroy a schema context | |||
Prototype | void XmlSchemaDestroy(xsdctx *sctx); | |||
Arguments |
| |||
Returns | (void) | |||
Description | Destroy a schema context and free up all its resources.
| |||
See Also | XmlSchemaCreate |
Name | XmlSchemaErrorWhere | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Interface | Schema | |||||||||
Purpose | ||||||||||
Prototype | xmlerr XmlSchemaErrorWhere(xsdctx *sctx, ub4 *line, oratext **path); | |||||||||
Arguments |
| |||||||||
Returns | (xmlerr) error code | |||||||||
Description | Returns the location (line#, path) where an error occured.
| |||||||||
See Also | XmlSchemaSetErrorHandler |
Name | XmlSchemaLoad | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Interface | Schema | |||||||||
Purpose | Load a schema document | |||||||||
Prototype | xmlerr XmlSchemaLoad(xsdctx *sctx, oratext *uri, ...); | |||||||||
Arguments |
| |||||||||
Returns | (xmlerr) numeric error code, XMLERR_OK [0] on success | |||||||||
Description | Load up a schema document to be used in the next validation session. Schema documents can be incrementally loaded into a schema context as long as every loaded schema document is valid. When the last loaded schema turns out to be invalid, you need to clean up the schema context by calling XmlSchemaClean and reload everyting all over again including the last schema with appropriate correction. | |||||||||
See Also | XmlSchemaUnload, XmlSchemaLoadedList |
Name | XmlSchemaLoadedList | ||||||
---|---|---|---|---|---|---|---|
Interface | Schema | ||||||
Purpose | Return the size and/or list of loaded schema documents. | ||||||
Prototype | ub4 XmlSchemaLoadedList(xsdctx *sctx, oratext **list); | ||||||
Arguments |
| ||||||
Returns | (ub4) list size | ||||||
Description | Return only the size of loaded schema documents if list is NULL.
If list is NOT NULL, a list of URL pointers are returned in the
user-provided pointer buffer. Note that its user's responsibility
to provide a buffer with big enough size.
| ||||||
Example | listSize = XmlSchemaLoadedList(scctx, (oratext **)NULL); DISCARD printf("There are %d target namespace(s) loaded.\n", listSize); DISCARD printf("And, they are:\n"); | ||||||
See Also | XmlSchemaLoad, XmlSchemaUnload |
Name | XmlSchemaSetErrorHandler | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Interface | Schema | |||||||||
Purpose | ||||||||||
Prototype | xmlerr XmlSchemaSetErrorHandler(xsdctx *sctx, XML_ERRMSG_F((*errhdl), ectx, msg, err), void *errctx); | |||||||||
Arguments |
| |||||||||
Returns | (xmlerr) error code | |||||||||
Description | Sets an error message handler and its associated context in a schema
context. To retrieve useful location information on errors, the
address of the schema context must be provided in the error handler
context.
| |||||||||
Example | XML_ERRMSG_F(schema_err_handler, msgctx, msg, errcode) xsdctx *sctx = (xsdctx *)msgctx; ub4 line; oratext *path; ... DISCARD XmlSchemaErrorWhere(sctx, &line, &path); DISCARD printf("Line Number=%d\n", line); DISCARD printf("Errcode=%d\n", errcode); DISCARD printf("Msg=%s\n", msg); main(int argc, char *argv[]) ... if (!(scctx = XmlSchemaCreate(xctx, &xerr, NULL))) DISCARD printf("Failed to initialize XML parser, error %d\n", xerr); XmlFreeDocument(xctx, docnode); XmlDestroy(xctx); return 3; ... if (xerr = XmlSchemaSetErrorHandler(scctx, schema_err_handler, scctx)) DISCARD printf("Failed to set error handler, error %d\n", xerr); XmlFreeDocument(xctx, docnode); XmlSchemaDestroy(scctx); XmlDestroy(xctx); return 4; ... | |||||||||
See Also | XmlSchemaCreate, XML_ERRMSG_F, XmlSchemaErrorWhere |
Name | XmlSchemaSetValidateOptions | ||||||
---|---|---|---|---|---|---|---|
Interface | Schema | ||||||
Purpose | Set option(s) to be used in the next validation session | ||||||
Prototype | xmlerr XmlSchemaSetValidateOptions(xsdctx *sctx, ...); | ||||||
Arguments |
| ||||||
Returns | (xmlerr) numeric error code, XMLERR_OK [0] on success | ||||||
Description | Set options to be used in the next validation session. Previously
set options will remain effective until they are overwritten or reset.
| ||||||
Example | XmlSchemaSetValidateOptions(scctx, "ignore_id_constraint", (boolean)TRUE, NULL); | ||||||
See Also | XmlSchemaValidate |
Name | XmlSchemaTargetNamespace | ||||||
---|---|---|---|---|---|---|---|
Interface | Schema | ||||||
Purpose | Return target namespace of a given schema document | ||||||
Prototype | oratext *XmlSchemaTargetNamespace(xsdctx *sctx, oratext *uri); | ||||||
Arguments |
| ||||||
Returns | (oratext *) target namespace string; NULL if given document not | ||||||
Description | Return target namespace of a given schema document identified by its
URI. All currently loaded schema documents can be queried. Currently
loaded schema documents include the ones loaded via XmlSchemaLoad's and
the ones loaded via schemaLocation or noNamespaceSchemaLocation hints.
| ||||||
See Also | XmlSchemaLoadedList |
Name | XmlSchemaUnload | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Interface | Schema | |||||||||
Purpose | Unload a schema document | |||||||||
Prototype | xmlerr XmlSchemaUnload(xsdctx *sctx, oratext *uri, ...); | |||||||||
Arguments |
| |||||||||
Returns | (xmlerr) numeric error code, XMLERR_OK [0] on success | |||||||||
Description | Unload a schema document from the validator. All previously loaded
schema documents will remain loaded until they are unloaded. To
unload all loaded schema documents, set uri to be NULL (this is
equivalent to XmlSchemaClean). Note that all children schemas
associated with the given schema are also unloaded. In this
implementation, it only support the following scenarios:
1. load, load, ... 2. load, load, load, unload, unload, unload, clean,
and then repeat. It doesn't not support: load, load, unload, load,
....
| |||||||||
Example | xerr = XmlSchemaLoad(scctx, schema1, NULL); ... xerr = XmlSchemaUnload(scctx, schema1, NULL); | |||||||||
See Also | XmlSchemaLoad, XmlSchemaLoadedList |
Name | XmlSchemaValidate | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Interface | Schema | |||||||||
Purpose | Validate an element node against a schema | |||||||||
Prototype | xmlerr XmlSchemaValidate(xsdctx *sctx, xmlctx *xctx, xmlelemnode *elem); | |||||||||
Arguments |
| |||||||||
Returns | (xmlerr) numeric error code, XMLERR_OK [0] on success | |||||||||
Description | Validates an element node against a schema. Schemas used in current
session consists of all schema documents specified through
XmlSchemaLoad and provided as hint(s) through schemaLocation or
noNamespaceSchemaLocation in the instance document. After the
invokation of this routine, all loaded schema documents remain loaded
and can be queried by XmlSchemaLoadedList. However, they will remain
inactive. In the next validation session, inactive schema documents
can be activated by specifying them via XmlSchemaLoad or providing
them as hint(s) via schemaLocation or noNamespaceSchemaLocation in
the new instance document. To unload a schema document and all
its descendants (documents included or imported nestedly), use
XmlSchemaUnload.
| |||||||||
See Also | XmlSchemaSetValidateOptions |
Name | XmlSchemaVersion |
---|---|
Interface | Schema |
Purpose | Return the version of this schema implementation |
Prototype | oratext *XmlSchemaVersion(void); |
Arguments | void |
Returns | (oratext *) version string [compiler encoding] |
Description | Return the version of this schema implementation.
|