xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmit...@apache.org
Subject cvs commit: xml-xalan/c/samples/XPathWrapper TestDriver.cpp XPathWrapper.cpp XPathWrapper.hpp
Date Fri, 12 Nov 2004 04:02:39 GMT
dmitryh     2004/11/11 20:02:39

  Modified:    c/samples/XPathWrapper TestDriver.cpp XPathWrapper.cpp
                        XPathWrapper.hpp
  Log:
  Fix for the sample
  
  Revision  Changes    Path
  1.19      +64 -31    xml-xalan/c/samples/XPathWrapper/TestDriver.cpp
  
  Index: TestDriver.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/samples/XPathWrapper/TestDriver.cpp,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- TestDriver.cpp	26 Feb 2004 22:27:24 -0000	1.18
  +++ TestDriver.cpp	12 Nov 2004 04:02:39 -0000	1.19
  @@ -17,13 +17,14 @@
   #include "XPathWrapper.hpp"
   
   
  -
  +#include <xercesc/util/PlatformUtils.hpp>
   #include <xercesc/util/XMLException.hpp>
   
   
   
   #include <xalanc/PlatformSupport/DOMStringHelper.hpp>
   
  +#include <xalanc/XalanTransformer/XalanTransformer.hpp>
   
   
   #if defined(XALAN_CLASSIC_IOSTREAMS)
  @@ -65,38 +66,70 @@
   		return -1;
   	}
   
  -	XPathWrapper::ChVectorType	theXML;
  -
  -	ifstream	in(argv[1]);
  -
  -	// slow and dirty dump of the xml file into a buffer
  -	char c;
  -	while(in.get(c))
  -		theXML.push_back(c);
  -	theXML.push_back('\0');
  +    
  +    XALAN_USING_XERCES(XMLPlatformUtils)
  +    XALAN_USING_XERCES(XMLException)
  +	XALAN_USING_XALAN(XalanTransformer)
  +
  +        //initialize Xerces...
  +    try
  +    {
  +        XMLPlatformUtils::Initialize();
  +    }
  +    catch(const XMLException&)
  +    {
  +        cerr << "XMLPlatformUtils::Initialize() failed!" << endl;
  +        
  +        return -1;
  +    }
  +    
  +    // Initialize Xalan.
  +	XalanTransformer::initialize();
  +
  +    {
  +        XPathWrapper::ChVectorType	theXML;
  +        
  +        ifstream	in(argv[1]);
  +        
  +        // slow and dirty dump of the xml file into a buffer
  +        char c;
  +        while(in.get(c))
  +            theXML.push_back(c);
  +        theXML.push_back('\0');
  +        
  +        ///////////////////////////////////////////..
  +        
  +        // create your XPath helper object
  +        XPathWrapper helper;
  +        
  +        try
  +        {
  +            // call evaluate, passing in the XML string, the context string and the xpath
string
  +            XPathWrapper::CharVectorTypeVectorType	result;
  +
  +            helper.evaluate(&*theXML.begin(), argv[2], argv[3], result);
  +            
  +            // take the resulting string vector	and do whatever you want with it:
  +            size_t len = result.size();
  +            
  +            cout << "the result set has " << len << " strings\n";
  +            
  +            for (size_t i=0; i<len; i++)
  +                cout << "item " << (i+1) << "= \"" << &*result[i].begin()
<< "\"" << endl;
  +        }
  +        catch(const XERCES_CPP_NAMESPACE_QUALIFIER XMLException&)
  +        {
  +            cerr << "Exception caught!  Exiting..." << endl;
  +        }
  +    }
  +	// Terminate Xalan...
  +	XalanTransformer::terminate();
   
  -	///////////////////////////////////////////..
  -
  -	// create your XPath helper object
  -	XPathWrapper helper;
  -
  -	try
  -	{
  -		// call evaluate, passing in the XML string, the context string and the xpath string
  -		const XPathWrapper::CharVectorTypeVectorType	result = helper.evaluate(&*theXML.begin(),
argv[2], argv[3]);
  +    // Shut down Xerces...
  +	XMLPlatformUtils::Terminate();
   
  -		// take the resulting string vector	and do whatever you want with it:
  -		size_t len = result.size();
  -
  -		cout << "the result set has " << len << " strings\n";
  -
  -		for (size_t i=0; i<len; i++)
  -			cout << "item " << (i+1) << "= \"" << &*result[i].begin()
<< "\"" << endl;
  -	}
  -	catch(const XERCES_CPP_NAMESPACE_QUALIFIER XMLException&)
  -	{
  -		cerr << "Exception caught!  Exiting..." << endl;
  -	}
  +	// Clean up the ICU, if it's integrated...
  +	XalanTransformer::ICUCleanUp();
   
   	return 0;
   }
  
  
  
  1.27      +13 -27    xml-xalan/c/samples/XPathWrapper/XPathWrapper.cpp
  
  Index: XPathWrapper.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/samples/XPathWrapper/XPathWrapper.cpp,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- XPathWrapper.cpp	26 Feb 2004 22:27:24 -0000	1.26
  +++ XPathWrapper.cpp	12 Nov 2004 04:02:39 -0000	1.27
  @@ -30,7 +30,6 @@
   
   
   #include <xercesc/framework/MemBufInputSource.hpp>
  -#include <xercesc/util/PlatformUtils.hpp>
   
   
   
  @@ -82,33 +81,20 @@
   {
   public:
   
  -	XPathWrapper::CharVectorTypeVectorType
  +    typedef 	XPathWrapper::CharVectorTypeVectorType CharVectorTypeVectorType;
  +
  +    void
   	evaluate(
   		const char*		xml,
   		const char*		context, 
   		const char*		expr,
  -		ostream&		errorStream)
  +		ostream&		errorStream,
  +        CharVectorTypeVectorType& theResultList)
   	{
   #if defined(XALAN_STRICT_ANSI_HEADERS)
   		using std::strlen;
   #endif
   
  -		XALAN_USING_XERCES(XMLPlatformUtils)
  -		XALAN_USING_XERCES(XMLException)
  -
  -		//initialize Xerces...
  -		try
  -		{
  -			XMLPlatformUtils::Initialize();
  -		}
  -		catch(const XMLException&)
  -		{
  -			errorStream << "XMLPlatformUtils::Initialize() failed!" << endl;
  -
  -			throw;
  -		}
  -
  -		XPathWrapper::CharVectorTypeVectorType	theResultList;
   
   		{
   			// Just hoist everything...
  @@ -126,6 +112,8 @@
   
   			XalanElement*	rootElem = 0;
   
  +            XALAN_USING_XERCES(XMLException)
  +
   			try
   			{
   				XALAN_USING_XERCES(MemBufInputSource)
  @@ -254,11 +242,7 @@
   				throw;
   			}
   
  -			// Shut down Xerces...
  -			XMLPlatformUtils::Terminate();
   		}
  -
  -		return theResultList;
   	}
   };
   
  @@ -281,17 +265,19 @@
   
   
   
  -XPathWrapper::CharVectorTypeVectorType
  +void
   XPathWrapper::evaluate(
   		const char*		xml, 
   		const char*		context, 
  -		const char*		path)
  +		const char*		path,
  +        CharVectorTypeVectorType& theResult)
   {
  -	return pImpl->evaluate(
  +	pImpl->evaluate(
   			xml,
   			context,
   			path,
  -			cerr);
  +			cerr,
  +            theResult);
   }
   
   
  
  
  
  1.14      +7 -10     xml-xalan/c/samples/XPathWrapper/XPathWrapper.hpp
  
  Index: XPathWrapper.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/samples/XPathWrapper/XPathWrapper.hpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- XPathWrapper.hpp	26 Feb 2004 22:27:24 -0000	1.13
  +++ XPathWrapper.hpp	12 Nov 2004 04:02:39 -0000	1.14
  @@ -20,15 +20,13 @@
   
   #include <xalanc/Include/PlatformDefinitions.hpp>
   
  +#include <xalanc/Include/XalanVector.hpp>
   
   
   #include <xalanc/PlatformSupport/DOMStringHelper.hpp>
   
   
   
  -#include <vector>
  -
  -
   
   #if defined(XALAN_NEEDS_EXPLICIT_TEMPLATE_INSTANTIATION)
   #include <stl/_vector.c>
  @@ -47,11 +45,9 @@
   
   	typedef XALAN_CPP_NAMESPACE_QUALIFIER CharVectorType	ChVectorType;
   
  -#if defined(XALAN_NO_STD_NAMESPACE)
  -	typedef vector<ChVectorType>		CharVectorTypeVectorType;	
  -#else
  -	typedef std::vector<ChVectorType>	CharVectorTypeVectorType;	
  -#endif	
  +
  +	typedef XALAN_CPP_NAMESPACE_QUALIFIER XalanVector<ChVectorType>		CharVectorTypeVectorType;

  +
   
   	XPathWrapper();
   
  @@ -61,11 +57,12 @@
   	// Given an xml document and an xpath context and expression in the form of (ascii) string
objects,
   	// this function parses the XML document, evaluates the xpath and returns the result,
as a list of 
   	// string objects
  -	CharVectorTypeVectorType
  +	void
   	evaluate(
   		const char*		xml, 
   		const char*		context, 
  -		const char*		path);
  +		const char*		path,
  +                CharVectorTypeVectorType& theResult);
   
   private:
   
  
  
  

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


Mime
View raw message