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/06/22 20:51:04 UTC

cvs commit: xml-xalan/c/src/XalanTransformer XalanCAPI.cpp XalanCAPI.h XalanTransformer.cpp XalanTransformer.hpp

dbertoni    01/06/22 11:51:03

  Modified:    c/src/XalanTransformer XalanCAPI.cpp XalanCAPI.h
                        XalanTransformer.cpp XalanTransformer.hpp
  Log:
  Updates to the C API for parsed source documents.  Return error codes consistently from functions.
  
  Revision  Changes    Path
  1.20      +44 -37    xml-xalan/c/src/XalanTransformer/XalanCAPI.cpp
  
  Index: XalanCAPI.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanCAPI.cpp,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- XalanCAPI.cpp	2001/06/21 15:39:46	1.19
  +++ XalanCAPI.cpp	2001/06/22 18:50:58	1.20
  @@ -185,15 +185,15 @@
   
   
   XALAN_TRANSFORMER_EXPORT_FUNCTION(int)
  -XalanTransformToFileCSS(
  -			const char*		theXMLFileName, 
  +XalanTransformToFilePrebuilt(
  +			XalanPSHandle	theParsedSource, 
   			XalanCSSHandle	theCSSHandle,
   			const char*		theOutFileName,
   			XalanHandle		theXalanHandle)
   {
   	// Do the transformation...
   	return getTransformer(theXalanHandle)->transform(
  -				theXMLFileName,
  +				*getParsedSource(theParsedSource),
   				getStylesheet(theCSSHandle),
   				theOutFileName);
   }
  @@ -243,8 +243,8 @@
   
   
   XALAN_TRANSFORMER_EXPORT_FUNCTION(int)
  -XalanTransformToDataCSS(
  -			const char*		theXMLFileName, 
  +XalanTransformToDataPrebuilt(
  +			XalanPSHandle	theParsedSource, 
   			XalanCSSHandle	theCSSHandle,
   			char**			theOutput,
   			XalanHandle		theXalanHandle)
  @@ -258,7 +258,7 @@
   	// Do the transformation...
   	const int	status =
   		getTransformer(theXalanHandle)->transform(
  -			theXMLFileName,
  +			*getParsedSource(theParsedSource),
   			getStylesheet(theCSSHandle),
   			theOutputStream);
   
  @@ -286,10 +286,10 @@
   
   XALAN_TRANSFORMER_EXPORT_FUNCTION(int) 
   XalanTransformToHandler(
  -			const char*				theXMLFileName, 
  +			const char*				theXMLFileName,
   			const char*				theXSLFileName,
   			XalanHandle				theXalanHandle,
  -			void*					theOutputHandle, 
  +			void*					theOutputHandle,
   			XalanOutputHandlerType	theOutputHandler,
   			XalanFlushHandlerType	theFlushHandler)
   {
  @@ -305,17 +305,17 @@
   
   
   XALAN_TRANSFORMER_EXPORT_FUNCTION(int) 
  -XalanTransformToHandlerCSS(
  -			const char*				theXMLFileName, 
  +XalanTransformToHandlerPrebuilt(
  +			XalanPSHandle			theParsedSource,
   			XalanCSSHandle			theCSSHandle,
   			XalanHandle				theXalanHandle,
  -			void*					theOutputHandle, 
  +			void*					theOutputHandle,
   			XalanOutputHandlerType	theOutputHandler,
   			XalanFlushHandlerType	theFlushHandler)
   {
   	// Do the transformation...
   	return getTransformer(theXalanHandle)->transform(
  -			theXMLFileName,
  +			*getParsedSource(theParsedSource),
   			getStylesheet(theCSSHandle),
   			theOutputHandle,
   			theOutputHandler,
  @@ -324,51 +324,58 @@
   
   
   
  -XALAN_TRANSFORMER_EXPORT_FUNCTION(XalanCSSHandle)
  +XALAN_TRANSFORMER_EXPORT_FUNCTION(int)
   XalanCompileStylesheet(
  -			const char*		theXSLFileName,
  -			XalanHandle		theXalanHandle)
  +			const char*			theXSLFileName,
  +			XalanHandle			theXalanHandle,
  +			XalanCSSHandle*		theCSSHandle)
   {
   	const XalanCompiledStylesheet*	theCompiledStylesheet = 0;
   
  -	getTransformer(theXalanHandle)->compileStylesheet(
  -		theXSLFileName,
  -		theCompiledStylesheet);
  +	const int	theResult =
  +		getTransformer(theXalanHandle)->compileStylesheet(
  +			theXSLFileName,
  +			theCompiledStylesheet);
  +
  +	if (theResult == 0)
  +	{
  +		*theCSSHandle = theCompiledStylesheet;
  +	}
   
  -	return theCompiledStylesheet;
  +	return theResult;
   }
   
   
   
  -XALAN_TRANSFORMER_EXPORT_FUNCTION(XalanPSHandle)
  -XalanParseSource(
  -			const char*		theXMLFileName,
  +XALAN_TRANSFORMER_EXPORT_FUNCTION(int)
  +XalanDestroyCompiledStylesheet(
  +			XalanCSSHandle	theCSSHandle,
   			XalanHandle		theXalanHandle)
   {
  -	const XalanParsedSource*	theParsedSource = 0;
  -
  -	getTransformer(theXalanHandle)->parseSource(
  -		theXMLFileName,
  -		theParsedSource);
  -
  -	return theParsedSource;
  +	return getTransformer(theXalanHandle)->destroyStylesheet(getStylesheet(theCSSHandle));
   }
   
   
   
  -XALAN_TRANSFORMER_EXPORT_FUNCTION(XalanPSHandle)
  -XalanParseSourceUseXerceDOM(
  +XALAN_TRANSFORMER_EXPORT_FUNCTION(int)
  +XalanParseSource(
   			const char*		theXMLFileName,
  -			XalanHandle		theXalanHandle)
  +			XalanHandle		theXalanHandle,
  +			XalanPSHandle*	thePSHandle)
   {
   	const XalanParsedSource*	theParsedSource = 0;
  +
  +	const int	theResult =
  +		getTransformer(theXalanHandle)->parseSource(
  +			theXMLFileName,
  +			theParsedSource);
   
  -	getTransformer(theXalanHandle)->parseSource(
  -		theXMLFileName,
  -		theParsedSource,
  -		true);
  +	if (theResult == 0)
  +	{
  +		*thePSHandle = theParsedSource;
  +	}
   
  -	return theParsedSource;
  +	return theResult;
   }
   
   
  
  
  
  1.13      +66 -43    xml-xalan/c/src/XalanTransformer/XalanCAPI.h
  
  Index: XalanCAPI.h
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanCAPI.h,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- XalanCAPI.h	2001/06/12 19:12:53	1.12
  +++ XalanCAPI.h	2001/06/22 18:50:59	1.13
  @@ -142,28 +142,28 @@
   	 */
   	XALAN_TRANSFORMER_EXPORT_FUNCTION(int)
   	XalanTransformToFile(
  -				const char*				theXMLFileName, 
  -				const char*				theXSLFileName,
  -				const char*				theOutFileName,
  -				XalanHandle				theXalanHandle);
  +				const char*		theXMLFileName, 
  +				const char*		theXSLFileName,
  +				const char*		theOutFileName,
  +				XalanHandle		theXalanHandle);
   
   	/**
   	 * Transform the XML source tree to the given result file.
   	 * The processor will apply the compiled stylesheet to the input
   	 * file and write the transformation result to a new output file.
   	 *
  -	 * @param theXMLFileName	filename of XML input source
  +	 * @param theParsedSource	handle of parsed source
   	 * @param theCSSHandle		handle of compiled stylesheet 
   	 * @param theOutFileName	filename of output source
   	 * @param theXalanHandle	handle of XalanTransformer instance.
   	 * @return	0 for success 
   	 */
   	XALAN_TRANSFORMER_EXPORT_FUNCTION(int)
  -	XalanTransformToFileCSS(
  -				const char*				theXMLFileName, 
  -				XalanCSSHandle			theCSSHandle,
  -				const char*				theOutFileName,
  -				XalanHandle				theXalanHandle);
  +	XalanTransformToFilePrebuilt(
  +			XalanPSHandle	theParsedSource, 
  +			XalanCSSHandle	theCSSHandle,
  +			const char*		theOutFileName,
  +			XalanHandle		theXalanHandle);
   
   	/**
   	 * Transform the XML source tree to a dynamically allocated buffer.
  @@ -180,10 +180,10 @@
   	 */
   	XALAN_TRANSFORMER_EXPORT_FUNCTION(int) 
   	XalanTransformToData(
  -				const char*				theXMLFileName, 
  -				const char*				theXSLFileName,
  -				char**					theOutput,
  -				XalanHandle				theXalanHandle);
  +			const char*		theXMLFileName, 
  +			const char*		theXSLFileName,
  +			char**			theOutput,
  +			XalanHandle		theXalanHandle);
   
   	/**
   	 * Transform the XML source tree to a dynamically allocated buffer.
  @@ -199,20 +199,20 @@
   	 * @return	0 for success 
   	 */
   	XALAN_TRANSFORMER_EXPORT_FUNCTION(int) 
  -	XalanTransformToDataCSS(
  -				const char*				theXMLFileName, 
  -				XalanCSSHandle			theCSSHandle,
  -				char**					theOutput,
  -				XalanHandle				theXalanHandle);
  +	XalanTransformToDataPrebuilt(
  +				XalanPSHandle	theParsedSource,
  +				XalanCSSHandle	theCSSHandle,
  +				char**			theOutput,
  +				XalanHandle		theXalanHandle);
   
   	/**
   	 * Free memory allocated as a result of calling
   	 * XalanTransformToData.
   	 * 
  -	 * @param theStream The address of character data.
  +	 * @param theData The address of character data.
   	 */
   	XALAN_TRANSFORMER_EXPORT_FUNCTION(void)
  -	XalanFreeData(char*		theStream);
  +	XalanFreeData(char*		theData);
   
   	/**
   	 * Transform the XML source tree to a callback function.
  @@ -256,8 +256,8 @@
   	 * 
   	 * - See XalanOutputHandlerType and XalanFlushHandlerType for more 
   	 * details.
  -	 * 
  -	 * @param theXMLFileName	filename of XML input source
  +	 *
  +	 * @param thePSHandle		handle of parsed source
   	 * @param theCSSHandle		handle of compiled stylesheet 
   	 * @param theXalanHandle	handle of XalanTransformer instance.
   	 * @param theOutputHandle	void pointer passed through to callback.
  @@ -266,26 +266,39 @@
   	 * @return	0 for success 
   	 */
   	XALAN_TRANSFORMER_EXPORT_FUNCTION(int) 
  -	XalanTransformToHandlerCSS(
  -				const char*				theXMLFileName, 
  +	XalanTransformToHandlerPrebuilt(
  +				XalanPSHandle			thePSHandle,
   				XalanCSSHandle			theCSSHandle,
   				XalanHandle				theXalanHandle,
  -				void*					theOutputHandle, 
  +				void*					theOutputHandle,
   				XalanOutputHandlerType	theOutputHandler,
   				XalanFlushHandlerType	theFlushHandler);
   
   	/**
  -	 * Creates a complied stylesheet.  The input source can be 
  -	 * a file name, a stream or a root node.
  +	 * Creates a compiled stylesheet.
   	 *
   	 * @param theXSLFileName	filename of stylesheet source
   	 * @param theXalanHandle	handle of XalanTransformer instance.
  -	 * @return	a CSSHandle or 0 for failure.
  +	 * @param theCSSHandle		a pointer to a XalanCSSHandle
  +	 * @return 0 for success.
   	 */
  -	XALAN_TRANSFORMER_EXPORT_FUNCTION(XalanCSSHandle)
  +	XALAN_TRANSFORMER_EXPORT_FUNCTION(int)
   	XalanCompileStylesheet(
  -				const char*				theXSLFileName,
  -				XalanHandle				theXalanHandle);
  +			const char*			theXSLFileName,
  +			XalanHandle			theXalanHandle,
  +			XalanCSSHandle*		theCSSHandle);
  +
  +	/**
  +	 * Destroys a compiled stylesheet.
  +	 *
  +	 * @param theCSSHandle		handle of the compiled stylesheet
  +	 * @param theXalanHandle	handle of XalanTransformer instance.
  +	 * @return 0 for success
  +	 */
  +	XALAN_TRANSFORMER_EXPORT_FUNCTION(int)
  +	XalanDestroyCompiledStylesheet(
  +			XalanCSSHandle	theCSSHandle,
  +			XalanHandle		theXalanHandle);
   
   	/**
   	 * Parse source document.  The input source can be 
  @@ -293,17 +306,27 @@
   	 *
   	 * @param theInputSource	input source	
   	 * @param theXalanHandle	handle of XalanTransformer instance.	 
  -	 * @return	a pointer to a XalanParsedSource or 0 for failure.
  +	 * @param thePSHandle		a pointer to a XalanPSHandle
  +	 * @return 0 for success.
   	 */	
  -	XALAN_TRANSFORMER_EXPORT_FUNCTION(XalanPSHandle)
  +	XALAN_TRANSFORMER_EXPORT_FUNCTION(int)
   	XalanParseSource(
  -			const char*				theXMLFileName,
  -			XalanHandle				theXalanHandle);
  +			const char*		theXMLFileName,
  +			XalanHandle		theXalanHandle,
  +			XalanPSHandle*	thePSHandle);
   
  -	XALAN_TRANSFORMER_EXPORT_FUNCTION(XalanPSHandle)
  -	XalanParseSourceUseXerceDOM(
  -			const char*				theXMLFileName,
  -			XalanHandle				theXalanHandle);
  +	/**
  +	 * Destroys a parsed source.
  +	 * a file name, a stream or a root node.
  +	 *
  +	 * @param thePSHandle		handle of parsed source
  +	 * @param theXalanHandle	handle of XalanTransformer instance.	 
  +	 * @return 0 for success
  +	 */	
  +	XALAN_TRANSFORMER_EXPORT_FUNCTION(int)
  +	XalanDestroyParsedSource(
  +			XalanPSHandle	thePSHandle,
  +			XalanHandle		theXalanHandle);
   
   	/**
   	 * Set a top-level stylesheet parameter.  This value can be evaluated via
  @@ -315,9 +338,9 @@
   	 */
   	XALAN_TRANSFORMER_EXPORT_FUNCTION(void)
   	XalanSetStylesheetParam(
  -				const char*				key,
  -				const char*				expression,
  -				XalanHandle				theXalanHandle);
  +				const char*		key,
  +				const char*		expression,
  +				XalanHandle		theXalanHandle);
   
   	/**
   	 * Returns the last error that occurred as a 
  
  
  
  1.23      +97 -67    xml-xalan/c/src/XalanTransformer/XalanTransformer.cpp
  
  Index: XalanTransformer.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanTransformer.cpp,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- XalanTransformer.cpp	2001/06/21 15:39:45	1.22
  +++ XalanTransformer.cpp	2001/06/22 18:51:00	1.23
  @@ -10,33 +10,33 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *	  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.
  + *	  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.
  + *	  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.
  + *	  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.
  + *	  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
  + * 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
  @@ -113,7 +113,7 @@
   	m_stylesheetExecutionContext(),
   	m_compiledStylesheets(),
   	m_parsedSources(),
  -    m_paramPairs(),
  +	m_paramPairs(),
   	m_functionPairs(),
   	m_errorMessage(1, '\0')
   {
  @@ -171,13 +171,13 @@
   XalanTransformer::transform(
   	const XalanParsedSource&	theParsedXML, 
   	const XSLTInputSource&		theStylesheetSource,
  -	const XSLTResultTarget&		theResultTarget)
  +	const XSLTResultTarget& 	theResultTarget)
   {
   #if !defined(XALAN_NO_NAMESPACES)
   	using std::for_each;
   #endif
   
  -	int		theResult = 0;
  +	int 	theResult = 0;
   
   	// Clear the error message.
   	m_errorMessage.resize(1, '\0');
  @@ -191,7 +191,7 @@
   		XalanAutoPtr<XalanParsedSourceHelper>	theHelper(theParsedXML.createHelper());
   		assert(theHelper.get() != 0);
   
  -		DOMSupport&						theDOMSupport = theHelper->getDOMSupport();
  +		DOMSupport& 					theDOMSupport = theHelper->getDOMSupport();
   
   		XMLParserLiaison&				theParserLiaison = theHelper->getParserLiaison();
   
  @@ -200,7 +200,7 @@
   
   		XObjectFactoryDefault			theXObjectFactory;
   
  -		XPathFactoryDefault				theXPathFactory;
  +		XPathFactoryDefault 			theXPathFactory;
   
   		// Create a processor...
   		XSLTEngineImpl	theProcessor(
  @@ -278,7 +278,7 @@
   			TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
   		}
   
  -		theResult = -1;		
  +		theResult = -1; 	
   	}
   	catch (SAXException& e)
   	{
  @@ -316,8 +316,8 @@
   		{
   			XalanDOMString theMessage("XalanDOMException caught.  The code is ");
   			
  -			append(theMessage,  LongToDOMString(long(e.getExceptionCode())));
  -			append(theMessage,  XalanDOMString("."));						 
  +			append(theMessage,	LongToDOMString(long(e.getExceptionCode())));
  +			append(theMessage,	XalanDOMString("."));						 
   
   			TranscodeToLocalCodePage(theMessage, m_errorMessage, true);
   		}
  @@ -334,13 +334,13 @@
   XalanTransformer::transform(
   			const XalanParsedSource&		theParsedXML, 
   			const XalanCompiledStylesheet*	theCompiledStylesheet,
  -			const XSLTResultTarget&			theResultTarget)
  +			const XSLTResultTarget& 		theResultTarget)
   {
   #if !defined(XALAN_NO_NAMESPACES)
   	using std::for_each;
   #endif
   
  -	int		theResult = 0;
  +	int 	theResult = 0;
   
   	// Clear the error message.
   	m_errorMessage.resize(1, '\0');
  @@ -354,7 +354,7 @@
   		XalanAutoPtr<XalanParsedSourceHelper>	theHelper(theParsedXML.createHelper());
   		assert(theHelper.get() != 0);
   
  -		DOMSupport&						theDOMSupport = theHelper->getDOMSupport();
  +		DOMSupport& 					theDOMSupport = theHelper->getDOMSupport();
   
   		XMLParserLiaison&				theParserLiaison = theHelper->getParserLiaison();
   
  @@ -363,7 +363,7 @@
   
   		XObjectFactoryDefault			theXObjectFactory;
   
  -		XPathFactoryDefault				theXPathFactory;
  +		XPathFactoryDefault 			theXPathFactory;
   
   		// Create a processor...
   		XSLTEngineImpl	theProcessor(
  @@ -420,7 +420,7 @@
   
   		// Do the transformation...
   		theProcessor.process(
  -					theParsedXML.getDocument(),		
  +					theParsedXML.getDocument(), 	
   					tempResultTarget,					
   					m_stylesheetExecutionContext);
   	}
  @@ -435,7 +435,7 @@
   			TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
   		}
   
  -		theResult = -1;		
  +		theResult = -1; 	
   	}
   	catch (SAXException& e)
   	{
  @@ -473,8 +473,8 @@
   		{
   			XalanDOMString theMessage("XalanDOMException caught.  The code is ");
   			
  -			append(theMessage,  LongToDOMString(long(e.getExceptionCode())));
  -			append(theMessage,  XalanDOMString("."));						 
  +			append(theMessage,	LongToDOMString(long(e.getExceptionCode())));
  +			append(theMessage,	XalanDOMString("."));						 
   
   			TranscodeToLocalCodePage(theMessage, m_errorMessage, true);
   		}
  @@ -489,15 +489,14 @@
   
   int
   XalanTransformer::transform(
  -	const XSLTInputSource&		theInputSource, 
  -	const XSLTInputSource&		theStylesheetSource,
  -	const XSLTResultTarget&		theResultTarget)
  +			const XSLTInputSource&			theInputSource, 
  +			const XalanCompiledStylesheet*	theCompiledStylesheet,
  +			const XSLTResultTarget& 		theResultTarget)
   {
  -	// Parse the source document.
   	const XalanParsedSource*	theParsedSource = 0;
  -
  + 
   	const int	theResult = parseSource(theInputSource, theParsedSource);
  -
  + 
   	if (theResult != 0)
   	{
   		return theResult;
  @@ -505,7 +504,7 @@
   	else
   	{
   		assert(theParsedSource != 0);
  -
  + 
   		// Make sure the parsed source is destroyed when
   		// the transformation is finished...
   		EnsureDestroyParsedSource	theGuard(*this, theParsedSource);
  @@ -513,19 +512,18 @@
   		// Do the transformation...
   		return transform(
   						*theParsedSource,
  -						theStylesheetSource,
  +						theCompiledStylesheet,
   						theResultTarget);
   	}
   }
   
  -
  -
   int
   XalanTransformer::transform(
  -			const XSLTInputSource&			theInputSource, 
  -			const XalanCompiledStylesheet*	theCompiledStylesheet,
  -			const XSLTResultTarget&			theResultTarget)
  +	const XSLTInputSource&		theInputSource, 
  +	const XSLTInputSource&		theStylesheetSource,
  +	const XSLTResultTarget& 	theResultTarget)
   {
  +	// Parse the source document.
   	const XalanParsedSource*	theParsedSource = 0;
   
   	const int	theResult = parseSource(theInputSource, theParsedSource);
  @@ -545,7 +543,7 @@
   		// Do the transformation...
   		return transform(
   						*theParsedSource,
  -						theCompiledStylesheet,
  +						theStylesheetSource,
   						theResultTarget);
   	}
   }
  @@ -555,7 +553,7 @@
   int
   XalanTransformer::transform(
   			const XSLTInputSource&		theInputSource, 		
  -			const XSLTResultTarget&		theResultTarget)
  +			const XSLTResultTarget& 	theResultTarget)
   {
   	// Do the transformation...
   	return transform(
  @@ -592,7 +590,7 @@
   
   int
   XalanTransformer::transform(
  -			const XSLTInputSource&			theInputSource, 
  +			const XalanParsedSource&		theParsedSource, 
   			const XalanCompiledStylesheet*	theCompiledStylesheet,
   			void*							theOutputHandle, 
   			XalanOutputHandlerType			theOutputHandler,
  @@ -607,7 +605,7 @@
   
   	// Do the transformation...
   	return transform(
  -					theInputSource, 
  +					theParsedSource,
   					theCompiledStylesheet,
   					theResultTarget);
   }
  @@ -640,7 +638,7 @@
   int
   XalanTransformer::compileStylesheet(
   			const XSLTInputSource&				theStylesheetSource,
  -			const XalanCompiledStylesheet*&		theCompiledStylesheet)
  +			const XalanCompiledStylesheet*& 	theCompiledStylesheet)
   {
   	// Clear the error message.
   	m_errorMessage.resize(1, '\0');
  @@ -648,7 +646,7 @@
   	// Store error messages from problem listener.
   	XalanDOMString	theErrorMessage;
   
  -	int				theResult = 0;
  +	int 			theResult = 0;
   
   	try
   	{
  @@ -665,7 +663,7 @@
   
   		XObjectFactoryDefault			theXObjectFactory;
   
  -		XPathFactoryDefault				theXPathFactory;
  +		XPathFactoryDefault 			theXPathFactory;
   
   		// Create a processor...
   		XSLTEngineImpl	theProcessor(
  @@ -741,9 +739,9 @@
   		{
   			XalanDOMString theMessage("XalanDOMException caught.  The code is ");
   
  -			append(theMessage,  LongToDOMString(long(e.getExceptionCode())));
  +			append(theMessage,	LongToDOMString(long(e.getExceptionCode())));
   
  -			append(theMessage,  XalanDOMString("."));
  +			append(theMessage,	XalanDOMString("."));
   
   			TranscodeToLocalCodePage(theMessage, m_errorMessage, true);
   		}
  @@ -756,24 +754,40 @@
   
   
   
  -void
  +int
   XalanTransformer::destroyStylesheet(const XalanCompiledStylesheet*	theStylesheet)
   {
   #if !defined(XALAN_NO_NAMESPACES)
   	using std::find;
   #endif
   
  -	const CompiledStylesheetPtrVectorType::iterator		i =
  +	const CompiledStylesheetPtrVectorType::iterator 	i =
   		find(
   			m_compiledStylesheets.begin(),
   			m_compiledStylesheets.end(),
   			theStylesheet);
  +
  +	if (i == m_compiledStylesheets.end())
  +	{
  +		const char* const	theStylesheetErrorMessage =
  +				"An invalid compiled stylesheet was provided.";
  +
  +		const unsigned int	theLength =
  +			length(theStylesheetErrorMessage);
   
  -	if (i != m_compiledStylesheets.end())
  +		m_errorMessage.resize(theLength + 1, CharVectorType::value_type(0));
  +
  +		strncpy(&*m_errorMessage.begin(), theStylesheetErrorMessage, theLength);
  +
  +		return -1;
  +	}
  +	else
   	{
   		m_compiledStylesheets.erase(i);
   
   		delete theStylesheet;
  +
  +		return 0;
   	}
   }
   
  @@ -789,7 +803,7 @@
   	m_errorMessage.clear();
   	m_errorMessage.push_back(0);
   
  -	int	theResult = 0;
  +	int theResult = 0;
   
   	try
   	{
  @@ -827,9 +841,9 @@
   	{
   		XalanDOMString theMessage("XalanDOMException caught.  The code is ");
   			
  -		append(theMessage,  LongToDOMString(long(e.getExceptionCode())));
  +		append(theMessage,	LongToDOMString(long(e.getExceptionCode())));
   
  -		append(theMessage,  XalanDOMString("."));						 
  +		append(theMessage,	XalanDOMString("."));						 
   
   		TranscodeToLocalCodePage(theMessage, m_errorMessage, true);
   
  @@ -841,7 +855,7 @@
   
   
   
  -void
  +int
   XalanTransformer::destroyParsedSource(const XalanParsedSource*	theParsedSource)
   {
   #if !defined(XALAN_NO_NAMESPACES)
  @@ -853,12 +867,28 @@
   			m_parsedSources.begin(),
   			m_parsedSources.end(),
   			theParsedSource);
  +
  +	if (i == m_parsedSources.end())
  +	{
  +		const char* const	theParsedSourceErrorMessage =
  +				"An invalid parsed source was provided.";
  +
  +		const unsigned int	theLength =
  +			length(theParsedSourceErrorMessage);
   
  -	if (i != m_parsedSources.end())
  +		m_errorMessage.resize(theLength + 1, CharVectorType::value_type(0));
  +
  +		strncpy(&*m_errorMessage.begin(), theParsedSourceErrorMessage, theLength);
  +
  +		return -1;
  +	}
  +	else
   	{
   		m_parsedSources.erase(i);
   
   		delete theParsedSource;
  +
  +		return 0;
   	}
   }
   
  @@ -880,7 +910,7 @@
   {
   	m_parsedSources.reserve(m_parsedSources.size() + 1);
   
  -	XalanDocumentBuilder* const		theNewBuilder = new XalanDefaultDocumentBuilder;
  +	XalanDocumentBuilder* const 	theNewBuilder = new XalanDefaultDocumentBuilder;
   
   	m_parsedSources.push_back(theNewBuilder);
   
  @@ -901,7 +931,7 @@
   XalanTransformer::installExternalFunction(
   			const XalanDOMString&	theNamespace,
   			const XalanDOMString&	functionName,
  -			const Function&			function)
  +			const Function& 		function)
   {
   	m_functionPairs.push_back(FunctionPairType(QNameByValue(theNamespace, functionName), function.clone()));
   }
  @@ -912,7 +942,7 @@
   XalanTransformer::installExternalFunctionGlobal(
   			const XalanDOMString&	theNamespace,
   			const XalanDOMString&	functionName,
  -			const Function&			function)
  +			const Function& 		function)
   {
   	XSLTProcessorEnvSupportDefault::installExternalFunctionGlobal(
   			theNamespace,
  @@ -933,7 +963,7 @@
   		{
   			delete m_functionPairs[i].second;
   
  -			m_functionPairs.erase(m_functionPairs.begin() + i);		
  +			m_functionPairs.erase(m_functionPairs.begin() + i); 	
   		}
   	}	
   }
  @@ -977,8 +1007,8 @@
   
   		m_stylesheetExecutionContext.reset();
   
  -        // Clear the ParamPairVectorType.
  -        m_paramPairs.clear();
  +		// Clear the ParamPairVectorType.
  +		m_paramPairs.clear();
   	}
   	catch(...)
   	{
  
  
  
  1.26      +64 -65    xml-xalan/c/src/XalanTransformer/XalanTransformer.hpp
  
  Index: XalanTransformer.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanTransformer.hpp,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- XalanTransformer.hpp	2001/06/21 15:39:44	1.25
  +++ XalanTransformer.hpp	2001/06/22 18:51:01	1.26
  @@ -10,33 +10,33 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *	  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.
  + *	  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.
  + *	  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.
  + *	  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.
  + *	  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
  + * 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
  @@ -135,14 +135,14 @@
   	transform(
   			const XalanParsedSource&	theParsedXML, 
   			const XSLTInputSource&		theStylesheetSource,
  -			const XSLTResultTarget&		theResultTarget);
  +			const XSLTResultTarget& 	theResultTarget);
   
   	/**
   	 * Transform will apply the compiled stylesheet to the parsed xml source
   	 * and write the transformation output to the target. 
   	 *
   	 * @param theParsedXML			the parsed input source
  -	 * @param theCompiledStylesheet	pointer to a compiled stylesheet
  +	 * @param theCompiledStylesheet pointer to a compiled stylesheet
   	 * @param theResultTarget		output source 
   	 * @return	0 for success
   	 */
  @@ -150,7 +150,7 @@
   	transform(
   			const XalanParsedSource&		theParsedXML, 
   			const XalanCompiledStylesheet*	theCompiledStylesheet,
  -			const XSLTResultTarget&			theResultTarget);
  +			const XSLTResultTarget& 		theResultTarget);
   
   	/**
   	 * Transform will apply the stylesheet source to the input source
  @@ -167,26 +167,9 @@
   	transform(
   			const XSLTInputSource&		theInputSource, 
   			const XSLTInputSource&		theStylesheetSource,
  -			const XSLTResultTarget&		theResultTarget);
  +			const XSLTResultTarget& 	theResultTarget);
   
   	/**
  -	 * Transform will apply the compiled stylesheet to the input source
  -	 * and write the transformation output to the target. The input 
  -	 * source and result target can be a file name, a stream or a root
  -	 * node. 
  -	 *
  -	 * @param theInputSource		input source
  -	 * @param theCompiledStylesheet	pointer to a compiled stylesheet
  -	 * @param theResultTarget		output source 
  -	 * @return	0 for success
  -	 */
  -	int
  -	transform(
  -			const XSLTInputSource&			theInputSource, 
  -			const XalanCompiledStylesheet*	theCompiledStylesheet,
  -			const XSLTResultTarget&			theResultTarget);
  -
  -	/**
   	 * Transform will apply the stylesheet provided as a PI in the 
   	 * XML of the input source and write the transformation output to 
   	 * the target. The input source and result target can be a file 
  @@ -199,7 +182,7 @@
   	int
   	transform(
   			const XSLTInputSource&		theInputSource, 		
  -			const XSLTResultTarget&		theResultTarget);
  +			const XSLTResultTarget& 	theResultTarget);
   
   	/**
   	 * Transform will apply the stylesheet source to the input source
  @@ -229,6 +212,23 @@
   	
   	/**
   	 * Transform will apply the compiled stylesheet to the input source
  +	 * and write the transformation output to the target. The input 
  +	 * source and result target can be a file name, a stream or a root
  +	 * node. 
  +	 *
  +	 * @param theInputSource		input source
  +	 * @param theCompiledStylesheet pointer to a compiled stylesheet
  +	 * @param theResultTarget		output source 
  +	 * @return	0 for success
  +	 */
  +	int
  +	transform(
  +			const XSLTInputSource&			theInputSource, 
  +			const XalanCompiledStylesheet*	theCompiledStylesheet,
  +			const XSLTResultTarget& 		theResultTarget);
  + 
  +	/**
  +	 * Transform will apply the compiled stylesheet to the source
   	 * and write the transformation result to a callback function  
   	 * in pre-allocated blocks. The input source can be a file name, 
   	 * a stream or a root node. Upon termination, Xalan releases any 
  @@ -238,8 +238,8 @@
   	 * - See XalanTransformerOutputStream and XalanOutputHandlerType 
   	 * for more details.
   	 * 
  -	 * @param theInputSource		input source
  -	 * @param theCompiledStylesheet	pointer to a compiled stylesheet
  +	 * @param theParsedSource		Parsed source instance
  +	 * @param theCompiledStylesheet pointer to a compiled stylesheet
   	 * @param theOutputHandle		void pointer passed through to callback.
   	 * @param theOutputHandler		a user defined callback function.
   	 * @param theFlushHandler		An optional user-defined callback function.
  @@ -247,7 +247,7 @@
   	 */
   	int
   	transform(
  -			const XSLTInputSource&			theInputSource,
  +			const XalanParsedSource&		theParsedSource,
   			const XalanCompiledStylesheet*	theCompiledStylesheet,
   			void*							theOutputHandle,
   			XalanOutputHandlerType			theOutputHandler,
  @@ -282,7 +282,7 @@
   	 * a file name, a stream or a root node.   The XalanTransformer
   	 * instance owns the XalanCompiledStylesheet instance and will
   	 * delete it when the XalanTransformer instance goes out of scope,
  -	 * or you explicitly call destroyStylesheet().  You must not delete
  +	 * or you explicitly call destroyStylesheet().	You must not delete
   	 * the instance yourself.
   	 *
   	 * @param theStylesheetSource input source
  @@ -292,16 +292,16 @@
   	int
   	compileStylesheet(
   			const XSLTInputSource&				theStylesheetSource,
  -			const XalanCompiledStylesheet*&		theCompiledStylesheet);
  +			const XalanCompiledStylesheet*& 	theCompiledStylesheet);
   
   	/**
   	 * Destroy a XalanCompiledStylesheet instance created by a previous
  -	 * call to compileStylesheet().  Passing a pointer that is not created
  -	 * by a call to createDocumentBuilder() can result in undefined behavior.
  +	 * call to compileStylesheet().
   	 *
  -	 * @param theStylesheet	The instance to destroy.
  +	 * @param theStylesheet The instance to destroy.
  +	 * @return 0 for success 
   	 */
  -	void
  +	int
   	destroyStylesheet(const XalanCompiledStylesheet*	theStylesheet);
   
   	/**
  @@ -325,17 +325,16 @@
   
   	/**
   	 * Destroy a parsed source created by a previous call to parseSource().
  -	 * Passing a pointer that was not created by a call to parseSource() can
  -	 * result in undefined behavior.
   	 *
   	 * @param theParsedSource The XalanParsedSource instance to destroy.
  +	 * @return 0 for success 
   	 */
  -	void
  +	int
   	destroyParsedSource(const XalanParsedSource*	theParsedSource);
   
   	/**
   	 * Create a document builder.  Using the document builder, you
  -	 * can construct a document using SAX2 interfaces.  The XalanTransformer
  +	 * can construct a document using SAX2 interfaces.	The XalanTransformer
   	 * instance owns the document builder and will delete it when the
   	 * XalanTransformer instance goes out of scope, or you explicitly call
   	 * deleteDocumentBuilder().  You must not delete the instance yourself.
  @@ -366,7 +365,7 @@
   	installExternalFunction(
   			const XalanDOMString&	theNamespace,
   			const XalanDOMString&	functionName,
  -			const Function&			function);
  +			const Function& 		function);
   
   	/**
   	 * Install an external function in the global space.
  @@ -379,7 +378,7 @@
   	installExternalFunctionGlobal(
   			const XalanDOMString&	theNamespace,
   			const XalanDOMString&	functionName,
  -			const Function&			function);
  +			const Function& 		function);
   
   	/**
   	 * Uninstall an external local function.
  @@ -417,7 +416,7 @@
   
   	/**
   	 * Returns the last error that occurred as a 
  -	 * result of calling transform.	
  +	 * result of calling transform. 
   	 *
   	 * @return	error message const character pointer.
   	 */
  @@ -428,17 +427,17 @@
   #if defined(XALAN_NO_NAMESPACES)
   	typedef vector<XalanCompiledStylesheet*>			CompiledStylesheetPtrVectorType;
   	typedef vector<XalanParsedSource*>					ParsedSourcePtrVectorType;
  -	typedef pair<XalanDOMString, XalanDOMString>    	ParamPairType;
  -	typedef vector<ParamPairType>		                ParamPairVectorType;
  -	typedef pair<QNameByValue, Function*>    			FunctionPairType;
  -	typedef vector<FunctionPairType>		            FunctionParamPairVectorType;
  +	typedef pair<XalanDOMString, XalanDOMString>		ParamPairType;
  +	typedef vector<ParamPairType>						ParamPairVectorType;
  +	typedef pair<QNameByValue, Function*>				FunctionPairType;
  +	typedef vector<FunctionPairType>					FunctionParamPairVectorType;
   #else
  -	typedef std::vector<const XalanCompiledStylesheet*>	CompiledStylesheetPtrVectorType;
  +	typedef std::vector<const XalanCompiledStylesheet*> CompiledStylesheetPtrVectorType;
   	typedef std::vector<const XalanParsedSource*>		ParsedSourcePtrVectorType;
   	typedef std::pair<XalanDOMString, XalanDOMString>	ParamPairType;
  -	typedef std::vector<ParamPairType>	                ParamPairVectorType;
  -	typedef std::pair<QNameByValue, Function*>    		FunctionPairType;
  -	typedef std::vector<FunctionPairType>		        FunctionParamPairVectorType;
  +	typedef std::vector<ParamPairType>					ParamPairVectorType;
  +	typedef std::pair<QNameByValue, Function*>			FunctionPairType;
  +	typedef std::vector<FunctionPairType>				FunctionParamPairVectorType;
   #endif
   
   	class EnsureDestroyParsedSource
  @@ -506,7 +505,7 @@
   
   		XalanTransformer&			m_transformer;
   
  -		XalanDocumentBuilder* const	m_documentBuilder;
  +		XalanDocumentBuilder* const m_documentBuilder;
   	};
   
   protected:
  @@ -536,13 +535,13 @@
   
   	StylesheetExecutionContextDefault		m_stylesheetExecutionContext;
   
  -	CompiledStylesheetPtrVectorType			m_compiledStylesheets;
  +	CompiledStylesheetPtrVectorType 		m_compiledStylesheets;
   
   	ParsedSourcePtrVectorType				m_parsedSources;
   
  -    ParamPairVectorType                     m_paramPairs;
  +	ParamPairVectorType 					m_paramPairs;
   
  -	FunctionParamPairVectorType				m_functionPairs;
  +	FunctionParamPairVectorType 			m_functionPairs;
   
   	CharVectorType							m_errorMessage;
   
  
  
  

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