Skip Headers

Oracle9i XML API Reference - XDK and Oracle XML DB
Release 2 (9.2)

Part Number A96616-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to next page

15
XML Schema Processor for C

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:


XML Schema Processor for C


Calling Sequence of XML Schema Processor for C

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 Types of XML Schema Processor for C

Table 15-1 Data Types of XML Schema Processor for C  
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.


Functions and Methods of XML Schema Processor for C

Table 15-2 Summary of Functions and Methods of XML Schema Processor for C  
Function / Method Description

schemaInitialize()

Initialize the schema processor

schemaLoad()

Load an XML Schema file offline

schemaTarget()

Return target namespace URI for schema

schemaTerminate()

Shut down the Schema processor

schemaValidate()

Validate an instance document against a Schema

schemaInitialize()

Description

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.

Syntax

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

Arguments

Argument IN / OUT Description

ctx

(IN)

XML parser context used to allocate memory of the Schema context.

schemaLoad()

Description

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:

Syntax

uword schemaLoad( xsdctx *scctx,
                  oratext *uri,
                  oratext *nsp,
                  xsd **schema);

Argument IN / OUT Description

scctx

(IN)

XML context used to allocate memory for the Schema context

uri

(IN)

URL of schema, in compiler character set

nsp

(IN)

Namespace of schema; optional; in compiler character set

schema

(OUT)

Returned schema structure

schemaTarget()

Description

Returns target namespace URI for schema.

Syntax

oratext *schemaTarget( xsd *schema);

Argument IN / OUT Description

xsd

(IN)

Schema structure

schemaTerminate()

Description

Tears down the Schema processor, releasing all allocated memory. The context may not be used again.

Syntax

void schemaTerminate( xsdctx *scctx);

Argument IN / OUT Description

scctx

(IN)

Schema context to terminate.

schemaValidate()

Description

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.

Syntax

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.


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

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

Master Index

Feedback