Skip Headers

Oracle® XML Reference
10g (9.0.4)

Part Number B10926-01
Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Go to previous page Go to next page

13
XML Schema Processor for C

The schema API is very simple: initialize, validate,...validate, terminate.

The validation process is go/no-go. Either the document is valid with respect to the schemas or it is invalid. When it is valid, a zero error code is returned. When it is invalid, a non-zero error code is returned indicating the problem. There is no distinction between warnings and errors; all problems are errors and considered fatal: validation stops immediately.

As schemas are encountered, they are loaded and preserved in the schema context. No schema is loaded more than once during a session. There is no clean up call similar to xmlclean. Hence, if you need to release all memory and reset state before validating a new document, you must terminate the context and start over.

This chapter contains the following sections:


XML Schema Methods for C

Table 13-1 summarizes the methods of the C parser.

Table 13-1 Summary of Methods of XML Schema for C
Method Description

schemaInitialize()

Initializes the XML schema processor.

schemaValidate()

Validate an instance document against a schema

schemaTerminate()

Terminates (tears down) the schema processor


schemaInitialize()

Initializes the XML schema processor. Must be called before the processor can be used to validate any documents. The XML parser context is used to allocate memory for the schema context. The schema context is returned, and must be passed to all subsequent schema functions. This context pointer is opaque-- you cannot reference its members. If the return context is NULL, initialization failed and err will be set with the numeric error code indicating the problem.

Syntax

xsdctx *schemaInitialize(xmlctx *ctx, uword *err)

Parameter IN/OUT Description
ctx
IN

XML parser context

err
OUT

Returned error code


schemaValidate()

Validates an instance document against a schema or schemas.The schema context returned by schemaInitialize must be passed in. The document to be validated is specified by the XML parser context inst used to parse the document. Note the document must already have been parsed. If no schemas are explicitly referenced in the instance document, the default schema (specified by URL) is assumed. If the document does specify all necessary schemas, and a default schema is also supplied, the default will be ignored. If the document does not reference any schemas and no default is supplied, an error will result.

Syntax

uword schemaValidate(xsdctx *scctx, xmlctx *inst, oratext *schema)

Parameter IN/OUT Description
scctx
IN

Schema context

inst
IN

Instance document context

schema
IN

URL of default schema

Comments


schemaTerminate()

Terminates (shuts down) the schema processor, freeing all memory allocated on the original XML parser context passed to schemaInitialize. After termination, the schema context is no longer valid. To continue using the schema processor, a new schema must be created with schemaInitialize.

Syntax

void schemaTerminate(xsdctx *scctx)

Parameter IN/OUT Description
scctx
IN

Schema context


Go to previous page Go to next page
Oracle
Copyright © 2001, 2003 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index