You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by pa...@apache.org on 2001/04/04 00:28:54 UTC

cvs commit: xml-xalan/c/Tests/Transformer Transformer.dsp TestXalanTransformer.cpp

pauldick    01/04/03 15:28:54

  Added:       c/Tests/Transformer Transformer.dsp TestXalanTransformer.cpp
  Log:
  New transformer test harness from Steve A.
  
  Revision  Changes    Path
  1.1                  xml-xalan/c/Tests/Transformer/Transformer.dsp
  
  Index: Transformer.dsp
  ===================================================================
  # Microsoft Developer Studio Project File - Name="Transformer" - Package Owner=<4>
  # Microsoft Developer Studio Generated Build File, Format Version 6.00
  # ** DO NOT EDIT **
  
  # TARGTYPE "Win32 (x86) Application" 0x0101
  
  CFG=Transformer - 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 "Transformer.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 "Transformer.mak" CFG="Transformer - Win32 Debug"
  !MESSAGE 
  !MESSAGE Possible choices for configuration are:
  !MESSAGE 
  !MESSAGE "Transformer - Win32 Release" (based on "Win32 (x86) Application")
  !MESSAGE "Transformer - Win32 Debug" (based on "Win32 (x86) Application")
  !MESSAGE 
  
  # Begin Project
  # PROP AllowPerConfigDependencies 0
  # PROP Scc_ProjName ""
  # PROP Scc_LocalPath ""
  CPP=cl.exe
  MTL=midl.exe
  RSC=rc.exe
  
  !IF  "$(CFG)" == "Transformer - 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\Transformer"
  # PROP Ignore_Export_Lib 0
  # PROP Target_Dir ""
  # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
  # ADD CPP /nologo /MD /W4 /GR /GX /O2 /Ob2 /I "..\..\..\..\xml-xerces\c\src" /I "..\..\src\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
  # SUBTRACT CPP /YX
  # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
  # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
  # 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 /nologo /subsystem:windows /machine:I386
  # ADD LINK32 ..\..\..\..\xml-xerces\c\Build\Win32\VC6\Release\xerces-c_1.lib ..\..\Build\Win32\VC6\Release\*.lib /nologo /stack:0x1f4000 /subsystem:console /pdb:none /machine:I386
  
  !ELSEIF  "$(CFG)" == "Transformer - 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\Transformer"
  # PROP Ignore_Export_Lib 0
  # PROP Target_Dir ""
  # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
  # ADD CPP /nologo /MDd /W4 /Gm /GR /GX /Zi /Od /I "..\..\..\..\xml-xerces\c\src" /I "..\..\src\\" /D "_WINDOWS" /D "_CONSOLE" /D "WIN32" /D "_DEBUG" /D "_MBCS" /YX /FD /GZ /c
  # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
  # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
  # 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 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
  # ADD LINK32 ..\..\..\..\xml-xerces\c\Build\Win32\VC6\Debug\xerces-c_1D.lib ..\..\Build\Win32\VC6\Debug\*.lib /nologo /stack:0x1f4000 /subsystem:console /debug /machine:I386 /pdbtype:sept
  # SUBTRACT LINK32 /pdb:none
  
  !ENDIF 
  
  # Begin Target
  
  # Name "Transformer - Win32 Release"
  # Name "Transformer - Win32 Debug"
  # Begin Group "Source Files"
  
  # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
  # Begin Source File
  
  SOURCE=.\TestXalanTransformer.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
  
  
  
  1.1                  xml-xalan/c/Tests/Transformer/TestXalanTransformer.cpp
  
  Index: TestXalanTransformer.cpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  #define TEST_XALAN_CPP
  
  
  #include <util/PlatformUtils.hpp>
  
  
  #if defined(TEST_XALAN_CPP)
  
  #include <XalanTransformer/XalanTransformer.hpp>
  
  #include <strstream>
  
  #if !defined(XALAN_NO_NAMESPACES)
  	using std::ostrstream;
  	using std::cout;
  #endif
  
  #else
  
  #include <XalanTransformer/XalanCAPI.h>
  
  #include <stdio.h>
  
  #endif
  
  
  static unsigned long xalan_output_handler(const void *data, unsigned long length, const void *handle)
  {
  	FILE *fp = (FILE*)handle;
  
  	char* d = (char *)data;
  
  	
  	fwrite( d, sizeof( char ), length, stdout );
  
  	return fwrite( d, sizeof( char ), length, fp );
  }
  
  
  
  static void xalan_flush_handler(const void *handle)
  {
  	FILE *fp = (FILE*)handle;
  
  	fflush(fp);
  }
  
  
  
  int
  main(
  			int				/* argc */,
  			const char*		/* argv[] */)
  {
  	const char* const		theXMLFileName = "d:\\xslt\\xsl-test\\perf\\basic\\basic-all_well.xml";
  	const char* const 		theXSLFileName = "d:\\xslt\\xsl-test\\perf\\basic\\basic-all_well.xsl";
  	const char* const		theOutFileName = "d:\\Transformer-Results\\basic-all_well.out";
  
  	const char* const 		theXMLFileName2 = "d:\\xslt\\xsl-test\\perf\\basic\\miscfam.xml";
  	const char* const		theXSLFileName2 = "d:\\xslt\\xsl-test\\perf\\basic\\miscfam.xsl";
  
  	const char* const 		theXMLFileName3 = "d:\\xslt\\xsl-test\\conf\\embed\\embed01.xml";	
  	const char* const		theOutFileName3 = "d:\\Transformer-Results\\embed01.out";
  
  	const char* const 		theXMLFileName4 = "d:\\xml-xalan\\c\\samples\\UseStylesheetParam\\foo.xml";	
  	const char* const 		theXSLFileName4 = "d:\\xml-xalan\\c\\samples\\UseStylesheetParam\\foo.xsl";	
  
  #if defined(TEST_XALAN_CPP)
  
  	// Call the static initializer for Xerces.
  	XMLPlatformUtils::Initialize();
  
      // Initialize Xalan.
      XalanTransformer::initialize();
  
  	XalanTransformer xalan;
  
  	const XalanCompiledStylesheet* const	css = xalan.compileStylesheet(theXSLFileName);
  
  	for(int i=0; i<1; ++i)
  	{
  
  		if(xalan.transform(theXMLFileName, css, "d:\\transformer-results\\css.out"))
  		{
  			cout << xalan.getLastError();
  
  			return 0;	
  		}
  		
  		if(xalan.transform(theXMLFileName3, theOutFileName3))
  		{
  			cout << xalan.getLastError();
  
  			return 0;	
  		}
  
  		if(xalan.transform(theXMLFileName, theXSLFileName, theOutFileName))
  		{
  			cout << xalan.getLastError();
  
  			return 0;	
  		}
  
  		ostrstream	theOutput;
  
  		if(xalan.transform(theXMLFileName2, theXSLFileName2, &theOutput))
  		{
  			cout << xalan.getLastError();
  
  			return 0;	
  		}
  
  		theOutput << '\0';
  
  		cout << theOutput.str();
  
  		ostrstream	theOutput3;
  
  		if(xalan.transform(theXMLFileName3, theOutput3))
  		{
  			cout << xalan.getLastError();
  
  			return 0;	
  		}
  /*		
  		if(xalan.transform(theXMLFileName, css, cout))
  		{
  			cout << xalan.getLastError();
  
  			return 0;	
  		}
  */		
  		xalan.setStylesheetParam("param1", "'What is Up'");
  
  		if(xalan.transform(theXMLFileName4, theXSLFileName4, &cout))
  		{
  			cout << xalan.getLastError();
  
  			return 0;	
  		}
  
  		if(xalan.transform(theXMLFileName4, theXSLFileName4, &cout))
  		{
  			cout << xalan.getLastError();
  
  			return 0;	
  		}
  	}
  
     // Terminate Xalan.
  	XalanTransformer::terminate();
  
  	// Call the static terminator for Xerces.
  	XMLPlatformUtils::Terminate();
  
  #else
  	XalanInitialize();
  
  	XalanHandle xalan = CreateXalanTransformer();
  	XalanCSSHandle theXalanCSS2 = XalanCompileStylesheet(theXSLFileName2, xalan);
  	XalanCSSHandle theXalanCSS4 = XalanCompileStylesheet(theXSLFileName4, xalan);
  
  	for(int i=0; i<2; ++i)
  	{
  		if(XalanTransformToFile(theXMLFileName, theXSLFileName, theOutFileName, xalan))
  		{
  			puts("Error");
  			puts(XalanGetLastError(xalan));
  			return 0;	
  		}
  
  		char* 		theOutput;
  
  		if(XalanTransformToData(theXMLFileName2, theXSLFileName2, &theOutput, xalan))
  		{
  			puts("Error");
  			puts(XalanGetLastError(xalan));
  			return 0;	
  		}
  
  		puts(theOutput);
  
  		XalanFreeData(theOutput);
  
  		if(XalanTransformToFile(theXMLFileName3, NULL, theOutFileName3, xalan))
  		{
  			puts("Error");
  			puts(XalanGetLastError(xalan));
  			return 0;	
  		}
  		
  		if(XalanTransformToData(theXMLFileName3, NULL, &theOutput, xalan))
  		{
  			puts("Error");
  			puts(XalanGetLastError(xalan));
  			return 0;	
  		}
  
  		puts(theOutput);
  
  		XalanFreeData(theOutput);
  
  		if(XalanTransformToDataCSS(theXMLFileName2, theXalanCSS2, &theOutput, xalan))
  		{
  			puts("Error");
  			puts(XalanGetLastError(xalan));
  			return 0;	
  		}
  
  		puts(theOutput);
  
  		XalanFreeData(theOutput);
  
  		FILE* fp =0;
  		fp = fopen("c:\\temp\\test.out", "w");
  
  		if(XalanTransformToHandlerCSS(theXMLFileName2, theXalanCSS2, xalan, fp, xalan_output_handler, xalan_flush_handler))
  		{
  			puts("Error");
  			puts(XalanGetLastError(xalan));
  			return 0;	
  		}
  
  		fclose(fp);
  
  		XalanSetStylesheetParam("param1", "'hi'", xalan);
  
  		//if(xalan.transform(theXMLFileName4, theXSLFileName4, &cout))
  		if(XalanTransformToDataCSS(theXMLFileName4, theXalanCSS4, &theOutput, xalan))
  		{
  			puts("Error");
  			puts(XalanGetLastError(xalan));
  			return 0;
  		}
  
  		puts(theOutput);
  
  		XalanFreeData(theOutput);
  
  	}
  
  	DeleteXalanTransformer(xalan);
  
  	XalanTerminate();
  #endif
  
  	return 0;
  }
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org