Each of the subdirectories in the Xalan-C++ samples directory contains the source files for a
sample application. The executables for the samples are in the build subdirectory, which should be on the system
path.

With most of the samples, you can use the following procedure:

Go to the samples subdirectory containing the sample (use the DOS shell if you are running Windows)

Run the sample from the command line (as indicated below)

Examine the application source files. You may also want to modify the source files. Remember that if you
modify a .cpp file, you must rebuild the executable and place it on the path before you can run the
modified application.

Each sample application looks for input files in the current directory, the directory from
which you run the application. The input files are in the samples subdirectory along with the sample source
files. For the UNIX builds, application executables are in the bin subdirectory. For the Windows32 build, the
application executable is in the bin subdirectory (Xalan-C_1_10_0-<my_Windows_distribution>\bin). To run a
sample, be sure the executable is on the path, and run it from the samples subdirectory that contains the input
files.

The most of the samples are implemented without providing a pluggable memory manager. The SimpleTransform sample illustrates,
in addition to a simple transformation, the usage of the processor with memory manager

Rebuilding a Sample application

Instructions for rebuilding the samples differ depending on whether you are using the binary package or the source
package.

For Windows users, the Xalan Visual C++ workspace contains project configurations for building
each of the samples. Users who have downloaded the source package, can find the XalanICU.dsw workspace
file under:

Xalan-C_1_10_0-src\src\xalanc\Projects\Win32\VC6

and XalanICU.sln solution file under:

Xalan-C_1_10_0-src\src\xalanc\Projects\Win32\VC7.1

Users who have downloaded the binary package, should use the Samples.dsw workspace file
located under:

Xalan-C_1_10_0-<my_Win32_distribution>\Samples\Projects\Win32\VC6

or the Samples.sln solution file for .NET V7.1 users, located under:

Xalan-C_1_10_0-<my_Win32_distribution>\Samples\Projects\Win32\VC7.1

The Makefile that comes with the UNIX distributions include targets for rebuilding one or all of
the sample applications. To rebuild one or more sample applications from the UNIX source package,
go to the Xalan-C_1_10_0-src directory and run

To rebuild the samples from the UNIX binary package, go to the ../samples directory of your installation,
run the runConfigure utility for your target platform, and then run gmake. For example, AIX users would
issue the following command:

./runConfigure -p aix -c xlc_r -x xlC_rcd samples

gmake Target

where Target can be Samples (for building all samples), or the individual sample name as
listed above.

This sample must be built with the Apache Web server, and the Xalan-C++ distribution files do not include a binary
for ApacheModuleXSLT. Assuming you have installed the Apache server on your platform, you can use Visual C++ on Windows to
build ApacheModuleXSLT.dll, or the Makefile on UNIX to build xslt_module (with the appropriate library suffix).

What it does: runs as an Apache module on an Apache Web server; performs transformations and returns the output to a Web
browser. You configure Apache to respond to a given URL request for an output file (html or txt file in the configuration below)
by applying an xsl stylesheet file to an xml document file (both with the specified name in a given location) and returning
the transformation output to the client.

This sample also illustrates use of the XalanTransformer class and the C API defined in src/XalanTransformer/XalanCAPI.h. It returns
transformation output in blocks to a callback function, which enables the browser to start displaying the result before the transformation
has been completed.

You may need to adjust the Visual C++ or Makefile settings to locate the required Apache header files. As shipped, the Visual C++
project file looks in \Apache Group\Apache\src\include, and the UNIX Makefile looks in usr/lib.

(UNIX only) Be sure the Xalan and Xerces libraries are on your library path (you can accomplish this by copying them to
/usr/lib; see Setting up the path/library path), and copy the Apache module to
/usr/lib/apache.

This <Location> element instructs the module to respond to requests for xxx.html and xxx.txt files in the
in the xslt subdirectory (under the document root; see next item) by applying the xxx.xsl stylesheet to xxx.xml
(both in that directory) and returning the transformation result to the browser.

For example, a request for foo.html instructs the module to apply foo.xsl to foo.xml and return the result.

Note: It is up to the stylesheet to apply the appropriate xsl:output method to the output. Whether the user specifies html or txt is, of
itself, immaterial.

Put xml/xsl file pairs in the <Location> subdirectory (xslt in the example)) under the document root directory specified in
httpd.conf by the DocumentRoot and <Directory> settings. Alternatively, you can modify these settings to point to
Xalan-C_1_10_0-<my_UNIX_distribution>/samples/ApacheModuleXSLT, which includes an xslt subdirectory with xml/xsl file pairs
(foo.xml/xsl, apachemod.xml/xsl).

Start the Apache server.

From a Web browser, call the module with a URL as follows:http://serverName/xslt/xxx.html
where serverName is the Apache server (such as www.myServer.com) and xxx is the name of an xml/xsl pair of files
(such as foo.xml and foo.xsl) in the xslt subdirectory under the DocumentRoot directory.

For example,http://www.myServer.com/xslt/apachemod.html
instructs ApacheModuleXSLT to apply the apachemod.xsl stylesheet to the apachemod.xml XML document (both files in the xslt directory
under the Apache DocumentRoot directory) and return the transformation result to the browser.

CompileStylesheet

What it does: Use a compiled stylesheet to perform a series of transformations.

What it does: Use a DocumentBuilder to programmatically construct an XML document, apply the foo.xsl stylesheet to
this document, and write the ouput to foo.out.

You can run it from the DocumentBuilder subdirectory with

DocumentBuilder

ExternalFunctions

What it does: implement, install, and illustrate the usage of three extension functions. The functions return a
square root, a cube, and a string with the current date and time. The sample stylesheet (foo.xsl) gets the area
of a cube and units of measurement from an XML document (foo.xml), computes the length of each side
of a cube and the volume of the cube, and enters the date and time of the transformation. The output appears in
foo.out.

What it does: performs a transformation with input in the form of a pre-built XercesDOM or XalanSourceTree.

Run this sample from the ParsedSourceWrappers subdirectory with

ParsedSourceWrappers

See transformXercesDOM() and transformXalanSourceTree() as called by transform() in ParsedSourceWrappers.cpp.

SerializeNodeSet

What it does: Serialize the node set returned by the application of an XPath expression to an XML document.

Run this sample from the SerializeNodeSet subdirectory with

SerializeNodeSet XMLFileContextNodeXPathExpression

where XMLFile is an XML source file, ContextNode is the location path to the context
node, and XPathExpression is an XPath expression to apply to that context node. The SerializeNodeSet
directory contains the same foo.xml sample source file as the preceding examples.

SimpleTransform

What it does: The SimpleTransform class uses the foo.xsl stylesheet to transform foo.xml, and writes the
output to foo.out. The source for this sample has been modified to demonstrate the usage of the new pluggable
memory management feature.

What it does: Use the XPathEvaluator C interface to evaluate an XPath epxeression and display the string value returned
by the epxression.

Keep in mind that the string value returned by an XPath expression is the string value of the first node in the nodeset
returned by the epxresssion.

Run this sample from the SimpleXPathCAPI subdirectory with

SimpleXPathCAPI XMLFileXPathExpression

where XMLFile is an XML source file, and XPathExpression is an XPath expression to apply to the XML
source file. The SimpleXPathCAPI subdirectory contains an XML file named xml.foo identical to foo.xml in the preceding
example.

You can try command lines like

SimpleXPathCAPI foo.xml /doc/name[3]

StreamTransform

What it does: The StreamTransform class processes character input streams containing a stylesheet and an XML document, and
writes the transformation output to a character output stream. This sample illustrates the process for working with stylesheets
and documents that you assemble in memory.

You can run it from the SimpleTransform subdirectory with

StreamTransform

ThreadSafe

What it does: Multiple threads use a single compiled stylesheet (StylesheetRoot) and DOM source tree (XalanNode) to perform
transformations concurrently. The application tracks the progress of the threads in messages to the console, and each thread
writes its own output file. Imagine a server application responding to multiple clients who happen to request the same
transformation.

// Set up a diagnostic writer to be used by the TraceListener...
XalanStdOutputStream theStdErr(cerr);
XalanOutputStreamPrintWriter diagnosticsWriter(theStdErr);
// Make sure that error reporting, which includes any TraceListener
// output does not throw exceptions when transcoding, since that could
// result in an exception being thrown while another exception is active.
// In particular, characters that the TraceListener writes might not be
// representable in the local code page.
theStdErr.setThrowTranscodeException(false);
// Set up the TraceListener...
// traceTemplates, traceTemplateChildren, traceGenerationEvent,
// and TraceSelectionEvent are booleans set by the command line.
TraceListenerDefault theTraceListener(
diagnosticsWriter,
traceTemplates,
traceTemplateChildren,
traceGenerationEvent,
traceSelectionEvent);
// Add the TraceListener to the XSLT processor...
theProcessor.setTraceSelects(traceSelectionEvent);
theProcessor.addTraceListener(&theTraceListener);
// Perform the transformation
....

TransformToXercesDOM

What it does: Performs a simple transformation but puts the result in a Xerces DOMDocument

Run this sample from the TransformToXercesDOM subdirectory with

TransformToXercesDOM XMLFileXSLFile

where XMLFile is a source XML file, and XSLFile is the XLST input file. The program will use
XSLFile to transform the input file XMLFile using Xerces DOM as the output destination.

See the FormatterToXercesDOM usage in the sample code.

UseStylesheetParam

What it does: Set a stylesheet parameter that the stylesheet uses during the transformation.

You can run it from the UseStylesheetParam subdirectory with

UseStylesheetParam key expression

where key is the parameter key (or name) and expression is a string expression enclosed
in single quotes.

The example uses a stylesheet (foo.xsl) with a parameter named param1. The stylesheet accepts any string
expression. Enclose the string expression in single quotes (so it is interpreted as an expression); if it
includes more than a single word, enclose the resulting string in double quotes so the executable interprets it
as a single argument. For example:

What it does: XalanTransform uses the XalanTransformer class and the associated C++ API to apply an XSL stylesheet
file to an XML document file and write the transformation output to either an output file or to a stream. XalanTransform
takes command-line arguments for the XML document to be transformed, the XSL stylesheet to apply, and an optional output
file argument. If you omit the third argument, XalanTransform writes the transformation output to a stream that is sent to
standard out (the console).

What it does: Return transformation output in blocks to a callback function, which writes the output to a file.
This sample illustrates the use of a callback function to incrementally process a transformation result, that is to begin
working with the transformation result before the transformation has been completed. See Processing output incrementally.

You can run it from the XalanTransformerCallback subdirectory with

XalanTransformerCallback foo.xml foo.xsl [foo.out]

If you omit the third argument, the transformation result is written to the console.