Skip Headers
Oracle® XML Developer's Kit Programmer's Guide
10g Release 2 (10.2)

Part Number B14252-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

17 Using the XML Schema Processor for C

This chapter contains these topics:

Note:

Use the new unified C API for new XDK and Oracle XML DB applications. The old C functions are deprecated and supported only for backward compatibility, but will not be enhanced. They will be removed in a future release.

The new C API is described in Chapter 15, "Using the XML Parser for C".

Oracle XML Schema Processor for C

The XML Schema processor for C is a companion component to the XML parser for C. It allows support for simple and complex datatypes in 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 every operating system where Oracle is ported.

See Also:

Chapter 3, "Using the XML Parser for Java", for more information about XML Schema and why you would want to use XML Schema.

Oracle XML Schema for C Features

XML Schema processor for C has the following features:

  • Supports simple and complex types

  • Built on XML parser for C

  • Supports the W3C XML Schema Recommendation

See Also:

Standards Conformance

The Schema Processor 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

  • W3C recommendation for XML Schema

XML Schema Processor for C: Supplied Software

Table 17-1 lists the supplied files and directories for this release.

Table 17-1 XML Schema Processor for C: Supplied Files

Directory and Files Description
bin schema processor executable, schema
lib XML/XSL/Schema & support libraries
nls/data Globalization Support data files
xdk/demo/c/schema example usage of the Schema processor
xdk/include header files
xdk/mesg error message files
xdk/readme.html introductory file

Table 17-2 lists the included libraries.

Table 17-2 XML Schema Processor for C: Supplied Libraries

Included Library Description
libxml10.a XML parser, XSLT processor, XML Schema processor
libcore10.a CORE functions
libnls10.a Globalization Support

Using the C XML Schema Processor Command-Line Utility

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

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 Makefile in the xdk/demo/c/schema subdirectory for details on how to build your program.

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

XML Schema Processor for C Usage Diagram

Figure 17-1 describes the calling sequence for the XML Schema processor for C, as follows:

  1. The initialize call is invoked once at the beginning of a session; it returns a schema context which is used throughout the session.

  2. Schema documents to be used in the session are loaded in advance.

  3. The instance document to be validated is first parsed with the XML parser.

  4. The top of the XML element subtree for the instance is then passed to the schema validate function.

  5. If no explicit schema is defined in the instance document, any pre-loaded schemas will be used.

  6. More documents can then be validated using the same schema context.

  7. When the session is over, the Schema tear-down function is called, which releases all memory allocated for the loaded schemas.

Figure 17-1 XML Schema Processor for C Usage Diagram

Description of adxdk092.gif follows
Description of the illustration adxdk092.gif

How to Run XML Schema for C Sample Programs

The directory xdk/demo/c/schema contains sample XML Schema applications that illustrate how to use Oracle XML Schema processor with its API. Table 17-3 lists the provided sample files.

Table 17-3 XML Schema for C Samples Provided

Sample File Description

Makefile

Makefile to build the sample programs and run them, verifying correct output.

xsdtest.c

Program which invokes the XML Schema for C API

car.{xsd,xml,std}

Sample schema, instance document, and expected output respectively, after running xsdtest on them.

aq.{xsd,xml,std}

Second sample schema, instance document, and expected output respectively, after running xsdtest on them.

pub.{xsd,xml,std}

Third sample schema, instance document, and 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