Skip Headers

Oracle® XML Reference 10g (9.0.4) Part Number B10926-01 |
Home | Contents | Index

# 15
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++

  See Also: Oracle Application Developer's Guide - XML

## XML Schema Methods for C++

Table 15-1 summarizes the methods of the C++ parser.

##### Table 15-1 Summary of Methods of XML Schema for C++

Method | Description
--- | ---
XMLSchema::initialize()```` | Initializes the XML schema processor.
XMLSchema::validate()```` | Validate an instance document against a schema
XMLSchema::terminate()```` | Terminates (tears down) the schema processor

## XMLSchema::initialize()

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

    uword initialize(xmlctx *ctx)

Parameter | IN/OUT | Description
--- | --- | ---
    ctx
    IN
| XML parser context

## XMLSchema::validate()

Validates an instance document against a schema or schemas.The schema context returned by XMLSchema::initialize() must be passed in. The document to be validated is specified by the XML parser context 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 validate(xmlctx *inst, oratext *schema)

Parameter | IN/OUT | Description
--- | --- | ---
    inst
    IN
| Instance document context
    schema
    IN
| URL of default schema

#### Comments

## XMLSchema::terminate()

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

#### Syntax

    void terminate()

| Copyright © 2001, 2003 Oracle Corporation. All Rights Reserved. |
Home | Contents | Index