You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@apache.org on 2001/04/26 18:38:50 UTC

cvs commit: xml-xalan/c/samples/SimpleXPathAPI SimpleXPathAPI.dsp SimpleXPathAPI.cpp foo.xml

dbertoni    01/04/26 09:38:50

  Added:       c/samples/SimpleXPathAPI SimpleXPathAPI.dsp
                        SimpleXPathAPI.cpp foo.xml
  Log:
  Initial revision.
  
  Revision  Changes    Path
  1.1                  xml-xalan/c/samples/SimpleXPathAPI/SimpleXPathAPI.dsp
  
  Index: SimpleXPathAPI.dsp
  ===================================================================
  # Microsoft Developer Studio Project File - Name="SimpleXPathAPI" - Package Owner=<4>
  # Microsoft Developer Studio Generated Build File, Format Version 6.00
  # ** DO NOT EDIT **
  
  # TARGTYPE "Win32 (x86) Console Application" 0x0103
  
  CFG=SimpleXPathAPI - 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 "SimpleXPathAPI.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 "SimpleXPathAPI.mak" CFG="SimpleXPathAPI - Win32 Debug"
  !MESSAGE 
  !MESSAGE Possible choices for configuration are:
  !MESSAGE 
  !MESSAGE "SimpleXPathAPI - Win32 Release" (based on "Win32 (x86) Console Application")
  !MESSAGE "SimpleXPathAPI - 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)" == "SimpleXPathAPI - 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\SimpleXPathAPI"
  # 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 /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 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\xerces-c_1.lib /nologo /subsystem:console /machine:I386
  
  !ELSEIF  "$(CFG)" == "SimpleXPathAPI - 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\SimpleXPathAPI"
  # 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 /W4 /Gm /GR /GX /Zi /Od /I "..\..\..\..\xml-xerces\c\src" /I "..\..\src" /D "_CONSOLE" /D "WIN32" /D "_DEBUG" /D "_MBCS" /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\xerces-c_1D.lib /nologo /subsystem:console /map /debug /machine:I386 /pdbtype:sept
  
  !ENDIF 
  
  # Begin Target
  
  # Name "SimpleXPathAPI - Win32 Release"
  # Name "SimpleXPathAPI - Win32 Debug"
  # Begin Group "Source Files"
  
  # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
  # Begin Source File
  
  SOURCE=.\SimpleXPathAPI.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/samples/SimpleXPathAPI/SimpleXPathAPI.cpp
  
  Index: SimpleXPathAPI.cpp
  ===================================================================
  #include <cassert>
  
  
  #if defined(XALAN_OLD_STREAM_HEADERS)
  #include <iostream.h>
  #else
  #include <iostream>
  #endif
  
  
  
  #include <util/PlatformUtils.hpp>
  #include <framework/LocalFileInputSource.hpp>
  
  
  
  #include <XalanDOM/XalanDocument.hpp>
  #include <XalanDOM/XalanElement.hpp>
  
  
  
  #include <XPath/XObject.hpp>
  
  
  
  #include <XalanSourceTree/XalanSourceTreeDOMSupport.hpp>
  #include <XalanSourceTree/XalanSourceTreeInit.hpp>
  #include <XalanSourceTree/XalanSourceTreeParserLiaison.hpp>
  
  
  
  #include <XPathAPI/XPathEvaluator.hpp>
  
  
  
  #if !defined(XALAN_NO_NAMESPACES)
  using std::cerr;
  using std::endl;
  using std::vector;
  #endif
  
  
  
  int
  main(
  			int				argc,
  			const char*		argv[])
  {
  #if !defined(XALAN_NO_NAMESPACES)
  	using std::cerr;
  	using std::cout;
  	using std::endl;
  #endif
  
  	int		theResult = 0;
  
  	if (argc != 4)
  	{
  		cerr << "Usage: SimpleXPathAPI XMLFilePath Context XPathExpression" << endl;
  
  		theResult = -1;
  	}
  	else
  	{
  		try
  		{
  			XMLPlatformUtils::Initialize();
  
  			XPathEvaluator::initialize();
  
  			{
  				// Initialize the XalanSourceTree subsystem...
  				XalanSourceTreeInit		theSourceTreeInit;
  
  				// We'll use these to parse the XML file.
  				XalanSourceTreeDOMSupport		theDOMSupport;
  				XalanSourceTreeParserLiaison	theLiaison(theDOMSupport);
  
  				// Hook the two together...
  				theDOMSupport.setParserLiaison(&theLiaison);
  
  				// Create an input source that represents a local file...
  				const LocalFileInputSource	theInputSource(XalanDOMString(argv[1]).c_str());
  
  				// Parse the document...
  				XalanDocument* const	theDocument =
  						theLiaison.parseXMLStream(theInputSource);
  				assert(theDocument != 0);
  
  				XPathEvaluator	theEvaluator;
  
  				// OK, let's find the context node...
  				XalanNode* const	theContextNode =
  						theEvaluator.selectSingleNode(
  							theDOMSupport,
  							theDocument,
  							XalanDOMString(argv[2]).c_str(),
  							0);
  
  				if (theContextNode == 0)
  				{
  					cerr << "Warning -- No nodes matched the location path \""
  						 << argv[2]
  						 << "\"."
  						 << endl
  						 << "Execution cannot continue..."
  						 << endl
  						 << endl;
  				}
  				else
  				{
  					// OK, let's evaluate the expression...
  					const XObjectPtr	theResult(
  						theEvaluator.evaluate(
  								theDOMSupport,
  								theContextNode,
  								XalanDOMString(argv[3]).c_str(),
  								0));
  
  					assert(theResult.null() == false);
  
  					cout << "The string value of the result is:"
  						 << endl
  						 << theResult->str()
  						 << endl
  						 << endl;
  				}
  			}
  
  			XPathEvaluator::terminate();
  
  			XMLPlatformUtils::Terminate();
  		}
  		catch(...)
  		{
  			cerr << "Exception caught!" << endl;
  
  			theResult = -1;
  		}
  	}
  
  	return theResult;
  };
  
  
  
  1.1                  xml-xalan/c/samples/SimpleXPathAPI/foo.xml
  
  Index: foo.xml
  ===================================================================
  <?xml version="1.0"?>
  <doc>
    <name first="David" last="Marston"/>
    <name first="David" last="Bertoni"/>
    <name first="Donald" last="Leslie"/>
    <name first="Emily" last="Farmer"/>
    <name first="Myriam" last="Midy"/>
    <name first="Paul" last="Dick"/>
    <name first="Scott" last="Boag"/>
    <name first="Shane" last="Curcuru"/>
    <name first="Joseph" last="Kesselman"/>
    <name first="Stephen" last="Auriemma"/>
  </doc>
  
  

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