dleslie 00/06/02 08:34:28
Added: c/samples/TraceListen birds.xml birds.xsl TraceListen.cpp
TraceListen.dsp
Log:
Sample application using TraceListener
Revision Changes Path
1.1 xml-xalan/c/samples/TraceListen/birds.xml
Index: birds.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<Class>
<Order Name="TINAMIFORMES">
<Family Name="TINAMIDAE">
<Species Scientific_Name="Tinamus major"> Great
Tinamou.</Species>
<Species Scientific_Name="Nothocercus">Highland Tinamou.</Species>
<Species Scientific_Name="Crypturellus soui">Little
Tinamou.</Species>
<Species Scientific_Name="Crypturellus cinnamomeus">Thicket
Tinamou.</Species>
<Species Scientific_Name="Crypturellus boucardi">Slaty-breasted
Tinamou.</Species>
<Species Scientific_Name="Crypturellus kerriae">Choco
Tinamou.</Species>
</Family>
</Order>
<Order Name="GAVIIFORMES">
<Family Name="GAVIIDAE">
<Species Scientific_Name="Gavia stellata">Red-throated
Loon.</Species>
<Species Scientific_Name="Gavia arctica">Arctic Loon.</Species>
<Species Scientific_Name="Gavia pacifica">Pacific Loon.</Species>
<Species Scientific_Name="Gavia immer">Common Loon.</Species>
<Species Scientific_Name="Gavia adamsii">Yellow-billed
Loon.</Species>
</Family>
</Order>
<Order Name="PODICIPEDIFORMES">
<Family Name="PODICIPEDIDAE">
<Species Scientific_Name="Tachybaptus dominicus">Least
Grebe.</Species>
<Species Scientific_Name="Podilymbus podiceps">Pied-billed
Grebe.</Species>
<Species Scientific_Name="">Atitlan Grebe.</Species>
<Species Scientific_Name="">Horned Grebe.</Species>
<Species Scientific_Name="">Red-necked Grebe.</Species>
<Species Scientific_Name="">Eared Grebe.</Species>
<Species Scientific_Name="">Western Grebe.</Species>
<Species Scientific_Name="">Clark's Grebe.</Species>
<Species Scientific_Name=""/>
</Family>
</Order>
<Order Name="PROCELLARIIFORMES">
<Family Name="DIOMEDEIDAE">
<Species Scientific_Name="Thalassarche
chlororhynchos">Yellow-nosed Albatross. (A)</Species>
<Species Scientific_Name="Thalassarche cauta">Shy Albatross.
(A)</Species>
<Species Scientific_Name="Thalassarche melanophris">Black-browed
Albatross. (A)</Species>
<Species Scientific_Name="Phoebetria palpebrata">Light-mantled
Albatross. (A)</Species>
<Species Scientific_Name="Diomedea exulans">Wandering Albatross.
(A)</Species>
<Species Scientific_Name="Phoebastria immutabilis">Laysan
Albatross.</Species>
<Species Scientific_Name="Phoebastria nigripes">Black-footed
Albatross.</Species>
<Species Scientific_Name="Phoebastria albatrus">Short-tailed
Albatross. (N)</Species>
</Family>
<Family Name="PROCELLARIIDAE">
<Species Scientific_Name="Fulmarus glacialis">Northern
Fulmar.</Species>
<Species Scientific_Name="Pterodroma neglecta">Kermadec Petrel.
(A)</Species>
<Species Scientific_Name="Pterodroma arminjoniana">Herald Petrel.
(A)</Species>
<Species Scientific_Name="Pterodroma ultima">Murphy's Petrel.
(N)</Species>
<Species Scientific_Name="Pterodroma inexpectata">Mottled Petrel.
(A)</Species>
<Species Scientific_Name="Pterodroma cahow">Bermuda
Petrel.</Species>
<Species Scientific_Name="Pterodroma hasitata">Black-capped
Petrel.</Species>
<Species Scientific_Name="Pterodroma externa">Juan Fernandez
Petrel. (N)</Species>
<Species Scientific_Name="Pterodroma phaeopygia">Dark-rumped
Petrel.</Species>
<Species Scientific_Name="Pterodroma cervicalis">White-necked
Petrel. (H)</Species>
<Species Scientific_Name="Pterodroma hypoleuca">Bonin Petrel.
(H)</Species>
<Species Scientific_Name="Pterodroma nigripennis">Black-winged
Petrel. (H, A)</Species>
<Species Scientific_Name="Pterodroma cookii">Cook's Petrel.
(N)</Species>
<Species Scientific_Name="Pterodroma longirostris">Stejneger's
Petrel. (A)</Species>
<Species Scientific_Name="Bulweria bulwerii">Bulwer's Petrel.
(H)</Species>
<Species Scientific_Name="Bulweria fallax">Jouanin's Petrel. (H,
A)</Species>
<Species Scientific_Name="Procellaria parkinsoni">Parkinson's
Petrel. (N)</Species>
<Species Scientific_Name="Calonectris leucomelas">Streaked
Shearwater. (A)</Species>
<Species Scientific_Name="Calonectris diomedea">Cory's
Shearwater. (N)</Species>
<Species Scientific_Name="Puffinus creatopus">Pink-footed
Shearwater. (N)</Species>
<Species Scientific_Name="Puffinus carneipes">Flesh-footed
Shearwater. (N)</Species>
<Species Scientific_Name="Puffinus gravis">Greater Shearwater.
(N)</Species>
<Species Scientific_Name="Puffinus pacificus">Wedge-tailed
Shearwater.</Species>
<Species Scientific_Name="Puffinus bulleri">Buller's Shearwater.
(N)</Species>
<Species Scientific_Name="Puffinus griseus">Sooty Shearwater.
(N)</Species>
<Species Scientific_Name="Puffinus tenuirostris">Short-tailed
Shearwater. (N)</Species>
<Species Scientific_Name="Puffinus nativitatis">Christmas
Shearwater. (H)</Species>
<Species Scientific_Name="Puffinus puffinus">Manx
Shearwater.</Species>
<Species Scientific_Name="Puffinus auricularis">Townsend's
Shearwater.</Species>
<Species Scientific_Name="Puffinus opisthomelas">Black-vented
Shearwater.</Species>
<Species Scientific_Name="Puffinus lherminieri">Audubon's
Shearwater.</Species>
<Species Scientific_Name="Puffinus assimilis">Little Shearwater.
(A)</Species>
</Family>
<Family Name="HYDROBATIDAE">
<Species Scientific_Name="Oceanites oceanicus">Wilson's
Storm-Petrel. (N)</Species>
<Species Scientific_Name="Pelagodroma marina">White-faced
Storm-Petrel. (A)</Species>
<Species Scientific_Name="Hydrobates pelagicus">European
Storm-Petrel. (A)</Species>
<Species Scientific_Name="Oceanodroma furcata">Fork-tailed
Storm-Petrel.</Species>
<Species Scientific_Name="Oceanodroma leucorhoa">Leach's
Storm-Petrel.</Species>
<Species Scientific_Name="Oceanodroma homochroa">Ashy
Storm-Petrel.</Species>
<Species Scientific_Name="Oceanodroma castro">Band-rumped
Storm-Petrel. (N)</Species>
<Species Scientific_Name="Oceanodroma tethys">Wedge-rumped
Storm-Petrel. (N)</Species>
<Species Scientific_Name="Oceanodroma melania">Black
Storm-Petrel.</Species>
<Species Scientific_Name="Oceanodroma macrodactyla">Guadalupe
Storm-Petrel.</Species>
<Species Scientific_Name="Oceanodroma markhami">Markham's
Storm-Petrel. (A)</Species>
<Species Scientific_Name="Oceanodroma tristrami">Tristram's
Storm-Petrel. (H)</Species>
<Species Scientific_Name="Oceanodroma microsoma">Least
Storm-Petrel.</Species>
</Family>
</Order>
<Order Name="PELECANIFORMES">
<Family Name="PHAETHONTIDAE">
<Species Scientific_Name="Phaethon lepturus">White-tailed
Tropicbird.</Species>
<Species Scientific_Name="Phaethon aethereus">Red-billed
Tropicbird.</Species>
<Species Scientific_Name="Phaethon rubricauda">Red-tailed
Tropicbird.</Species>
</Family>
<Family Name="SULIDAE">
<Species Scientific_Name="Sula dactylatra">Masked Booby.</Species>
<Species Scientific_Name="Sula nebouxii">Blue-footed
Booby.</Species>
<Species Scientific_Name="Sula variegata">Peruvian Booby.
(A)</Species>
<Species Scientific_Name="Sula leucogaster">Brown Booby.</Species>
<Species Scientific_Name="Sula sula">Red-footed Booby.</Species>
<Species Scientific_Name="Morus bassanus">Northern
Gannet.</Species>
</Family>
<Family Name="PELECANIDAE">
<Species Scientific_Name="Pelecanus erythrorhynchos">American
White Pelican.</Species>
<Species Scientific_Name="Pelecanus occidentalis">Brown
Pelican.</Species>
</Family>
<Family Name="PHALACROCORACIDAE">
<Species Scientific_Name="Phalacrocorax penicillatus">Brandt's
Cormorant.</Species>
<Species Scientific_Name="Phalacrocorax brasilianus">Neotropic
Cormorant.</Species>
<Species Scientific_Name="Phalacrocorax auritus">Double-crested
Cormorant.</Species>
<Species Scientific_Name="Phalacrocorax carbo">Great
Cormorant.</Species>
<Species Scientific_Name="Phalacrocorax urile">Red-faced
Cormorant.</Species>
<Species Scientific_Name="Phalacrocorax pelagicus">Pelagic
Cormorant.</Species>
</Family>
<Family Name="ANHINGIDAE">
<Species Scientific_Name="Anhinga anhinga">Anhinga.</Species>
</Family>
<Family Name="FREGATIDAE">
<Species Scientific_Name="Fregata magnificens">Magnificent
Frigatebird.</Species>
<Species Scientific_Name="Fregata minor">Great
Frigatebird.</Species>
<Species Scientific_Name="Fregata ariel">Lesser Frigatebird.
(A)</Species>
</Family>
</Order>
</Class>
1.1 xml-xalan/c/samples/TraceListen/birds.xsl
Index: birds.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="Class">
<BirdInfo>
<xsl:apply-templates select="Order"/>
</BirdInfo>
</xsl:template>
<xsl:template match="Order">
Order is: <xsl:value-of select="@Name"/>
<xsl:apply-templates select="Family"/><xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="Family">
Family is: <xsl:value-of select="@Name"/>
<xsl:apply-templates select="Species | SubFamily | text()"/>
</xsl:template>
<xsl:template match="SubFamily">
SubFamily is <xsl:value-of select="@Name"/>
<xsl:apply-templates select="Species | text()"/>
</xsl:template>
<xsl:template match="Species">
<xsl:choose>
<xsl:when test="name(..)='SubFamily'">
<xsl:text> </xsl:text><xsl:value-of select="."/><xsl:text>
</xsl:text><xsl:value-of select="@Scientific_Name"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/><xsl:text> </xsl:text><xsl:value-of
select="@Scientific_Name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
1.1 xml-xalan/c/samples/TraceListen/TraceListen.cpp
Index: TraceListen.cpp
===================================================================
#include <iostream>
#include <fstream>
#include <util/PlatformUtils.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <DOMSupport/DOMSupportDefault.hpp>
#include <XPath/XObjectFactoryDefault.hpp>
#include <XPath/XPathSupportDefault.hpp>
#include <XPath/XPathFactoryDefault.hpp>
#include <XPath/XPathProcessorImpl.hpp>
#include <XercesPlatformSupport/XercesDOMPrintWriter.hpp>
#include <XercesPlatformSupport/TextFileOutputStream.hpp>
#include <XercesPlatformSupport/XercesStdTextOutputStream.hpp>
#include <XercesParserLiaison/XercesParserLiaison.hpp>
#include <XSLT/XSLTEngineImpl.hpp>
#include <XSLT/XSLTInputSource.hpp>
#include <XSLT/XSLTResultTarget.hpp>
#include <XSLT/StylesheetConstructionContextDefault.hpp>
#include <XSLT/StylesheetExecutionContextDefault.hpp>
#include <XSLT/TraceListenerDefault.hpp>
#include <XSLT/XSLTProcessorEnvSupportDefault.hpp>
int
main(
int argc,
const char* argv[])
{
#if !defined(XALAN_NO_NAMESPACES)
using std::auto_ptr;
using std::cerr;
using std::endl;
#endif
// TraceListener flags...
bool traceTemplates = false;
bool traceTemplateChildren = false;
bool traceGenerationEvent = false;
bool traceSelectionEvent = false;
if (argc < 2 || argc > 5)
{
cerr << "Usage: TraceListen [+ 1 or more of following] -TT -TG
-TS -TTC" << endl;
return -1;
}
// Set the TraceListener flags...
for (int i = 1; i < argc; i ++)
{
if(!stricmp("-TT", argv[i]))
{
traceTemplates = true;
}
else if(!stricmp("-TG", argv[i]))
{
traceGenerationEvent = true;
}
else if(!stricmp("-TS", argv[i]))
{
traceSelectionEvent = true;
}
else if(!stricmp("-TTC", argv[i]))
{
traceTemplateChildren = true;
}
else
{
cerr << "Usage: TraceListen [+ 1 or more of following] -TT -TG
-TS -TTC" << endl;
return -1;
}
}
try
{
// Call the static initializers...
XMLPlatformUtils::Initialize();
XSLTEngineImpl::Initialize();
// Create the support objects that are necessary for running
the processor...
DOMSupportDefault theDOMSupport;
XercesParserLiaison
theParserLiaison(theDOMSupport);
XPathSupportDefault
theXPathSupport(theDOMSupport);
XSLTProcessorEnvSupportDefault theXSLTProcessorEnvSupport;
XObjectFactoryDefault
theXObjectFactory(theXSLTProcessorEnvSupport, theXPathSupport);
XPathFactoryDefault theXPathFactory;
// Create a processor...
XSLTEngineImpl theProcessor(
theParserLiaison,
theXPathSupport,
theXSLTProcessorEnvSupport,
theXObjectFactory,
theXPathFactory);
// Connect the processor to the support object...
theXSLTProcessorEnvSupport.setProcessor(&theProcessor);
// Create a stylesheet construction context, and a stylesheet
// execution context...
StylesheetConstructionContextDefault theConstructionContext(
theProcessor,
theXSLTProcessorEnvSupport,
theXObjectFactory,
theXPathFactory);
StylesheetExecutionContextDefault
theExecutionContext(
theProcessor,
theXSLTProcessorEnvSupport,
theXPathSupport,
theXObjectFactory);
// Our input files...The assumption is that the executable will be run
// from same directory as the input files.
const XalanDOMString theXMLFileName("birds.xml");
const XalanDOMString theXSLFileName("birds.xsl");
// Our input sources...
XSLTInputSource theInputSource(c_wstr(theXMLFileName));
XSLTInputSource
theStylesheetSource(c_wstr(theXSLFileName));
// Our output target...
TextFileOutputStream theOutputStream("birds.out");
XercesDOMPrintWriter theResultWriter(theOutputStream);
XSLTResultTarget
theResultTarget(&theResultWriter);
// Set up a diagnostic writer to be used by the TraceListener...
XercesStdTextOutputStream theStdErr(cerr);
XercesDOMPrintWriter
diagnosticsWriter(theStdErr);
// Set up the TraceListener...
auto_ptr<TraceListener> theTraceListener;
theTraceListener = auto_ptr<TraceListener>(new TraceListenerDefault(
diagnosticsWriter,
traceTemplates,
traceTemplateChildren,
traceGenerationEvent,
traceSelectionEvent));
// Add the TraceListener to the XSLT processor...
theProcessor.setTraceSelects(traceSelectionEvent);
theProcessor.addTraceListener(theTraceListener.get());
// Perform the transformation...
theProcessor.process(
theInputSource,
theStylesheetSource,
theResultTarget,
theConstructionContext,
theExecutionContext);
}
catch(...)
{
cerr << "Exception caught! Exiting..." << endl;
}
return 0;
}
1.1 xml-xalan/c/samples/TraceListen/TraceListen.dsp
Index: TraceListen.dsp
===================================================================
# Microsoft Developer Studio Project File - Name="TraceListen" - Package
Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=TraceListen - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "TraceListen.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "TraceListen.mak" CFG="TraceListen - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "TraceListen - Win32 Release" (based on "Win32 (x86) Console
Application")
!MESSAGE "TraceListen - Win32 Debug" (based on "Win32 (x86) Console
Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "TraceListen - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\..\Build\Win32\VC6\Release"
# PROP Intermediate_Dir "..\..\Build\Win32\VC6\Release\TraceListen"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D
"_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "..\..\..\..\xml-xerces\c\src" /I
"..\..\src" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 ..\..\..\..\xml-xerces\c\Build\Win32\VC6\Release\*.lib
..\..\Build\Win32\VC6\Release\*.lib kernel32.lib user32.lib gdi32.lib
winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
!ELSEIF "$(CFG)" == "TraceListen - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "..\..\Build\Win32\VC6\Debug"
# PROP Intermediate_Dir "..\..\Build\Win32\VC6\Debug\TraceListen"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D
"_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /ZI /Od /I
"..\..\..\..\xml-xerces\c\src" /I "..\..\src" /D "WIN32" /D "_DEBUG" /D
"_CONSOLE" /D "_MBCS" /D "XML_DEBUG" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 ..\..\..\..\xml-xerces\c\Build\Win32\VC6\Debug\*.lib
..\..\Build\Win32\VC6\Debug\*.lib kernel32.lib user32.lib gdi32.lib
winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
/pdbtype:sept
!ENDIF
# Begin Target
# Name "TraceListen - Win32 Release"
# Name "TraceListen - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\TraceListen.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project