Oracle9i XML API Reference - XDK and Oracle XML DB Release 2 (9.2) Part Number A96616-01 |
|
XML Schema is an alternative to XML DTDs. It defines the document organization, like DTD, but it also provides data typing of element content and additional features. XML Schema provides many built-in datatypes such as scalar, real, date and time, URIs, and encoded binary data. User-defined datatypes can be build from these primitive datatypes through extension or restriction.
XML Schema is still beta. This version implements the May 2001 W3C Recommendation. This beta implementation is incomplete at present; not all schema features are implemented.
This chapter describes the following section:
The sequence of calls to the processor is schemaInitialize()
, schemaValidate()
, ... , schemaValidate()
, schemaTerminate()
. The initialize()
call is invoked once at the beginning of a session; it returns a Schema context that is used throughout the session.
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 nonzero 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.
The instance document to be validated is first parsed with the XML parser. The root element for the instance is then passed to the Schema validate function, along with an optional Schema URL. If optimal schema is provided, it will be loaded and become the default schema. More documents may then be processed using the same Schema context. When the session is over, the schemaTerminate()
function is called, which releases all memory allocated by the loaded Schemas.
Data Type | Definition | Description |
---|---|---|
xsd |
typedef struct xsd xsd; |
Schema structure. |
xsdctx |
typedef struct xsdctx xsdctx; |
Schema processor context. |
Note: The contents of xsdctx
and xsd
are private (opaque) and must not be accessed by users.
Initializes the XML Schema processor; must be called before any Schema validation can take place. The same context may be used repeatedly for validating multiple documents. Returns a pointer to the allocated context; otherwise returns NULL.
xsdctx *schemaInitialize( xmlctx *ctx, uword *err);
Argument | IN / OUT | Description |
---|---|---|
ctx |
(IN) |
XML parser context used to allocate memory of the Schema context. |
Loads Schema and returns the error code, or 0
for success.
To indicate that "nsp" is not provided, specify NULL
; to indicate that it's not in any target namespace, specify an empty string, ""; otherwise, provide a namespace URI such as "http://www.example.com/Report". If "nsp" is provided, then the following must be all true:
targetNamespace
[attribute] of imported schema.targetNamespace
[attribute].uword schemaLoad( xsdctx *scctx, oratext *uri, oratext *nsp, xsd **schema);
Returns target namespace URI for schema.
oratext *schemaTarget( xsd *schema);
Argument | IN / OUT | Description |
---|---|---|
xsd |
(IN) |
Schema structure |
Tears down the Schema processor, releasing all allocated memory. The context may not be used again.
void schemaTerminate( xsdctx *scctx);
Argument | IN / OUT | Description |
---|---|---|
scctx |
(IN) |
Schema context to terminate. |
Validates an instance document against a Schema. If the default Schema is provided, the named schema is loaded and will become the default. Returns 0
on success (the document is structurally valid and all datatypes check out), or an error code on failure.
uword schemaValidate( xsdctx *scctx, xmlnode *root, xsd *schema);
Argument | IN / OUT | Description |
---|---|---|
ctx |
(IN) |
Schema context. |
root |
(IN) |
Root element of instance of document to validate. |
schema |
(IN) |
URI of default Schema, in compiler character set. |
|
Copyright © 2001, 2002 Oracle Corporation. All Rights Reserved. |
|