Oracle® XML Developer's Kit Programmer's Guide 10g Release 1 (10.1) Part Number B10794-01 |
|
|
View PDF |
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 14, " XML Parser for C". |
This chapter contains these topics:
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, " XML Parser for Java", for more information about XML Schema and why you would want to use XML Schema. |
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
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
Table 16-1 lists the supplied files and directories for this release:
Table 16-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 16-2 lists the included libraries:
XML Schema Processor for C can be called as an executable by invoking bin/schema
in the install area. This takes two arguments:
XML instance document
Optionally, a default schema
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.
Figure 16-1 describes the calling sequence for the XML Schema Processor for C, as follows:
The sequence of calls to the processor is: initialize, load, validate, validate,..., validate, terminate.
The initialize call is invoked once at the beginning of a session; it returns a schema context which is used throughout the session.
Schema documents to be used in the session are loaded in advance.
The instance document to be validated is first parsed with the XML parser.
The top of the XML element subtree for the instance is then passed to the schema validate function.
If no explicit schema is defined in the instance document, any pre-loaded schemas will be used.
More documents can then be validated using the same schema context.
When the session is over, the Schema tear-down function is called, which releases all memory allocated for the loaded schemas.
The directory xdk/demo/c/schema
contains sample XML Schema applications that illustrate how to use Oracle XML Schema Processor with its API. Table 16-3 lists the provided sample files.
Table 16-3 XML Schema for C Samples Provided
Sample File | Description |
---|---|
|
Makefile to build the sample programs and run them, verifying correct output. |
|
Program which invokes the XML Schema for C API |
|
Sample schema, instance document, and expected output respectively, after running xsdtest on them. |
|
Second sample schema, instance document, and expected output respectively, after running xsdtest on them. |
|
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