Skip Headers

Oracle® XML Developer's Kit Programmer's Guide 10g Release 2 (10.1.2) Part No. B14033-01 |
| Contents | Index

Previous | Next |

# 21 XML Schema Processor for C++

This chapter contains these topics:

- Oracle XML Schema Processor for C++

- XML Schema Processor API

- Running the Provided XML Schema for C++ Sample Programs

Note: Use the new unified C++ API in `xml.hpp` for new XDK applications. The old C++ API in `oraxml.hpp` is deprecated and supported only for backward compatibility, but will not be enhanced. It will be removed in a future release.

## Oracle XML Schema Processor for C++

The XML Schema Processor for C++ is a companion component to the XML Parser for C++ that allows support to simple and complex datatypes into XML applications.

The XML Schema Processor for C++ supports the W3C XML Schema Recommendation. This makes writing custom applications that process XML documents straightforward, and means that a standards-compliant XML Schema Processor is part of the XDK on each operating system where Oracle is ported.

### Oracle XML Schema for C++ Features

XML Schema Processor for C++ has the following features:

- Supports simple and complex types

- Built upon the XML Parser for C++

- Supports the W3C XML Schema Recommendation

The XML Schema Processor for C++ class is `OracleXml::Parser::SchemaValidator`.

See Also: Oracle XML API Reference

#### Online Documentation

Documentation for Oracle XML Schema Processor for C++ is located in `/xdk/doc/cpp/schema` directory in your install area.

### Standards Conformance

The XML Schema Processor for C++ conforms to the following standards:

- W3C recommendation for Extensible Markup Language (XML) 1.0

- W3C recommendation for Document Object Model Level 1.0

- W3C recommendation for Namespaces in XML 1.0

- W3C recommendation for XML Schema 1.0

## XML Schema Processor API

Interface `SchemaValidator` is an abstract template class to handle XML schema-based validation of XML documents.

### Invoking XML Schema Processor for C++

The XML Schema Processor for C++ can be called as an executable by invoking `bin/schema` in the install area. This takes the arguments:

- XML instance document

- Optionally, a default schema

- Optionally, the working directory

Table 21-1 lists the options (can be listed if the option is invalid or -h is the option):

Table 21-1 XML Schema Processor for C++ Command Line Options

Option | Description
--- | ---
`-0` | Always exit with code 0 (success).
`-e` `encoding` | Specify default input file encoding.
`-E` `encoding` | Specify output/data/presentation encoding.
`-h` | Help. Prints these choices.
`-i` | Ignore provided schema.
`-o` `num` | Validation option.
`-p` | Print document instance to `stdout` on success.
`-u` | Force the Unicode path.
`-v` | Version - display version, then exit.

The XML Schema Processor for C++ can also be invoked by writing code using the supplied APIs. The code must be compiled using the headers in the `include` subdirectory and linked against the libraries in the `lib` subdirectory. See M`akefile` or `Make.bat` in the `xdk/demo/cpp/schema` directory for details on how to build your program.

Error message files in different languages are provided in the `mesg` subdirectory.

## Running the Provided XML Schema for C++ Sample Programs

The directory `xdk/demo/cpp/schema` contains a sample application that illustrates how to use Oracle XML Schema Processor for C++ with its API. Table 21-2 lists the sample files provided.

Table 21-2 XML Schema Processor for C++ Samples Provided

Sample File | Description
--- | ---
`Makefile` | Makefile to build the sample programs and run them, verifying correct output.
`xsdtest.cpp` | Trivial program which invokes the XML Schema for C++ API
`car.{xsd,xml,std}` | Sample schema, instance document, expected output respectively, after running `xsdtest` on them.
`aq.{xsd,xml,std}` | Second sample schema's, instance document, expected output respectively, after running `xsdtest` on them.
`pub.{xsd,xml,std}` | Third sample schema's, instance document, expected output respectively, after running `xsdtest` on them.

To build the sample programs, run `make`.

To build the programs and run them, comparing the actual output to expected output:

    make sure