Skip Headers

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

Previous | Next |

# 20 XSLT Processor for C++

This chapter contains these topics:

- Accessing XSLT for C++

- Xsl Namespace

- XSLT for C++ DOM Interface Usage

- Invoking XSLT for C++

- Using the Sample Files Included with the Software

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.

## Accessing XSLT for C++

XSLT for C++ is provided with the database and the Application Server. It is also available for download from the OTN site `http://www.oracle.com/technology/tech/xml`.

Sample files are located at `xdk/demo/cpp/new`.

`readme.html` in the root directory of the software archive contains release specific information including bug fixes and API additions.

See Also: "XVM Processor"

## Xsl Namespace

This is the namespace for XSLT compilers and transformers.

### Xsl Interfaces

`XslException` Interface - Root interface for all XSLT-related exceptions.

`Transformer` Interface -Basic XSLT processor. This interface can be used to invoke all XSLT processors.

`CompTransformer` Interface - Extended XSLT processor. This interface can be used only with processors that create intermediate binary bytecode (currently XVM-based processor only).

`Compiler` Interface - XSLT compiler. It is used for compilers that compile XSLT into binary bytecode.

See Also: Oracle XML API Reference

## XSLT for C++ DOM Interface Usage

1. There are two inputs to `XMLParser.xmlparse()`:

   - The XML document

   - The stylesheet to be applied to the XML document

2. Any XSLT processor is initiated by calling the tools factory to create a particular XSLT transformer or compiler.

3. The stylesheet is supplied to any transformer by calling `setXSL()` member functions.

4. The XML instance document is supplied as a parameter to the transform member functions.

5. The resultant document (XML, HTML, VML, and so on) is typically sent to an application for further processing. The document is sent as a DOM tree or as a sequence of SAX events. SAX events are produced if a SAX event handler is provided by the user.

6. The application terminates the XSLT processors by invoking their destructors.

## Invoking XSLT for C++

XSLT for C++ can be invoked in two ways:

- By invoking the executable on the command line

- By writing C++ code and using the supplied APIs

### Command Line Usage

XSLT for C++ can be called as an executable by invoking `bin/xml.`

See Also: Table 14-4, "XML Parser and XSLT Processor: Command Line Options"

### Writing C++ Code to Use Supplied APIs

XSLT for C++ can also be invoked by writing code to use the supplied APIs. The code must be compiled using the headers in the `public` subdirectory and linked against the libraries in the `lib` subdirectory. Please see the `Makefile` or `make.bat` in `xdk/demo/cpp/new` for full details of how to build your program.

## Using the Sample Files Included with the Software

The `$ORACLE_HOME/xdk/demo/cpp/parser/` directory contains several XML applications to illustrate how to use the XSLT for C++.

Table 20-1 lists the sample files.

Table 20-1 XSLT for C++ Sample Files

Sample File Name | Description
--- | ---
    XSLSampleMain.cpp
    XSLSampleGen.cpp
    XSLSampleGen.hpp
| Sources for sample XSLT usage program. `XSLSample` takes two arguments, the XSL stylesheet and the XML file. If you redirect `stdout` of this program to a file, you may have some output missing, depending on your environment.
    XVMSampleMain.cpp
    XVMSampleGen.cpp
    XVMSampleGen.hpp
| Sources for the sample XVM usage program.