dleslie     00/05/08 08:26:24

  Added:       c/samples/UseStylesheetParam foo.xml foo.xsl
                        UseStylesheetParam.cpp UseStylesheetParam.dsp
  Log:
  UseStylesheetParam -- build executable that takes two params,
  a param key (name) and a string expression.
  
  Revision  Changes    Path
  1.1                  xml-xalan/c/samples/UseStylesheetParam/foo.xml
  
  Index: foo.xml
  ===================================================================
  <?xml version="1.0"?>
  <doc>Hello</doc>
  
  
  
  1.1                  xml-xalan/c/samples/UseStylesheetParam/foo.xsl
  
  Index: foo.xsl
  ===================================================================
  <?xml version="1.0"?> 
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
version="1.0">
    <xsl:param name="param1" select="'default value'"/>
    <xsl:template match="doc">
      <out><xsl:value-of select="$param1"/></out>
    </xsl:template>
  </xsl:stylesheet>
  
  
  
  1.1                  
xml-xalan/c/samples/UseStylesheetParam/UseStylesheetParam.cpp
  
  Index: UseStylesheetParam.cpp
  ===================================================================
  #include <iostream>
  #include <fstream>
  
  #include <util/PlatformUtils.hpp>
  #include <parsers/DOMParser.hpp>
  #include <dom/DOM_Node.hpp>
  
  #include <PlatformSupport/DOMStringHelper.hpp>
  
  #include <DOMSupport/DOMSupportDefault.hpp>
  
  #include <XPath/XObjectFactoryDefault.hpp>
  #include <XPath/XPathSupportDefault.hpp>
  #include <XPath/XPathFactoryDefault.hpp>
  
  #include <XSLT/StylesheetConstructionContextDefault.hpp>
  #include <XSLT/StylesheetExecutionContextDefault.hpp>
  #include <XSLT/XSLTEngineImpl.hpp>
  #include <XSLT/XSLTInputSource.hpp>
  #include <XSLT/XSLTProcessorEnvSupportDefault.hpp>
  #include <XSLT/XSLTResultTarget.hpp>
  
  #include <XercesParserLiaison/XercesParserLiaison.hpp>
  
  #include <XercesPlatformSupport/TextFileOutputStream.hpp>
  #include <XercesPlatformSupport/XercesDOMPrintWriter.hpp>
  
  int
  main(
                  int                                argc,
                  const char*            argv [])
  {
  #if !defined(XALAN_NO_NAMESPACES)
    using std::cerr;
    using std::endl;
    using std::ofstream;
  #endif
  
        if (argc != 3)
        {
                cerr << "Usage: UseStylesheetParam key expression" << endl;
  
                return -1;
        }       
        try
                {
                        // Call the static initializers...
                        XMLPlatformUtils::Initialize();
                        XSLTEngineImpl::Initialize();
                        
                        // Get the stylesheet parameter key (name) and
        // expression (a string expression).
                        const DOMString         paramKey(argv[1]);
                        const DOMString         paramExpression(argv[2]);
  
                        // Set up input and output objects for the 
transformation.
                        // Assumption: the executable is run from the directory
                        // containing the input files. 
                        const DOMString         theXMLFileName("foo.xml");
                        const DOMString         theXSLFileName("foo.xsl");
                        XSLTInputSource         
theInputSource(c_wstr(theXMLFileName));
                        XSLTInputSource         
theStylesheetSource(c_wstr(theXSLFileName));
   
                        // The output target...
                        TextFileOutputStream    theOutputStream("foo.out");
                        XercesDOMPrintWriter    
theResultWriter(theOutputStream);
                        XSLTResultTarget                  
theResultTarget(&theResultWriter);
  
                                        // 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);
                        // Use the parser liaison as the formatter...
                        theProcessor.setFormatter(&theParserLiaison);
                        // Create a stylesheet construction context, and a 
stylesheet
                        // execution context...
                        StylesheetConstructionContextDefault    
theConstructionContext(
                                                theProcessor,
                                                theXSLTProcessorEnvSupport,
                                                theXObjectFactory,
                                                theXPathFactory);
                        StylesheetExecutionContextDefault               
theExecutionContext(
                                                theProcessor,
                                                theXSLTProcessorEnvSupport,
                                                theXPathSupport,
                                                theXObjectFactory);
  
                        // Set the stylesheet parameter.
                        theProcessor.setStylesheetParam(paramKey,  
paramExpression);
   
                        // Perform the transformation...
                        theProcessor.process(
                                                theInputSource,
                                                &theStylesheetSource,
                                                theResultTarget,
                                                theConstructionContext,
                                                theExecutionContext);
                }
                catch(...)
                {
                        cerr << "UseStylesheetParam Exception caught!!!"
                                 << endl
                                 << endl;
                }
          return 0;
  }
  
  
  1.1                  
xml-xalan/c/samples/UseStylesheetParam/UseStylesheetParam.dsp
  
  Index: UseStylesheetParam.dsp
  ===================================================================
  # Microsoft Developer Studio Project File - Name="UseStylesheetParam" - 
Package Owner=<4>
  # Microsoft Developer Studio Generated Build File, Format Version 6.00
  # ** DO NOT EDIT **
  
  # TARGTYPE "Win32 (x86) Console Application" 0x0103
  
  CFG=UseStylesheetParam - 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 "UseStylesheetParam.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 "UseStylesheetParam.mak" CFG="UseStylesheetParam - Win32 
Debug"
  !MESSAGE 
  !MESSAGE Possible choices for configuration are:
  !MESSAGE 
  !MESSAGE "UseStylesheetParam - Win32 Release" (based on "Win32 (x86) Console 
Application")
  !MESSAGE "UseStylesheetParam - 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)" == "UseStylesheetParam - 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\UseStylesheetParam"
  # 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)" == "UseStylesheetParam - 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\UseStylesheetParam"
  # 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 "UseStylesheetParam - Win32 Release"
  # Name "UseStylesheetParam - Win32 Debug"
  # Begin Group "Source Files"
  
  # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
  # Begin Source File
  
  SOURCE=.\UseStylesheetParam.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
  
  
  

Reply via email to