You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mh...@apache.org on 2004/02/25 21:48:00 UTC

cvs commit: xml-xalan/c/src/xalanc/XalanTransformer XalanTransformer.cpp

mhoyt       2004/02/25 12:48:00

  Modified:    c/Projects/Win32/VC6/AllInOne AllInOne.dsp
                        AllInOneWithICU.dsp
               c/src/xalanc/ICUBridge ICUBridge.cpp ICUBridge.hpp
               c/src/xalanc/TestXSLT process.cpp
               c/src/xalanc/XPath XPathExecutionContext.hpp
                        XPathExecutionContextDefault.cpp
                        XPathExecutionContextDefault.hpp
               c/src/xalanc/XSLT FunctionFormatNumber.cpp
                        FunctionFormatNumber.hpp
                        StylesheetExecutionContextDefault.cpp
                        StylesheetExecutionContextDefault.hpp XSLTInit.cpp
               c/src/xalanc/XalanTransformer XalanTransformer.cpp
  Added:       c/src/xalanc/ICUBridge ICUFormatNumberFunctor.cpp
                        ICUFormatNumberFunctor.hpp
  Removed:     c/src/xalanc/ICUBridge FunctionICUFormatNumber.cpp
                        FunctionICUFormatNumber.hpp
               c/src/xalanc/PlatformSupport XalanDecimalFormat.cpp
                        XalanDecimalFormat.hpp
  Log:
  Fix to improve performance of ICU-enabled format-number()
  
  Revision  Changes    Path
  1.47      +0 -8      xml-xalan/c/Projects/Win32/VC6/AllInOne/AllInOne.dsp
  
  Index: AllInOne.dsp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/Projects/Win32/VC6/AllInOne/AllInOne.dsp,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- AllInOne.dsp	6 Jan 2004 03:34:44 -0000	1.46
  +++ AllInOne.dsp	25 Feb 2004 20:47:59 -0000	1.47
  @@ -591,14 +591,6 @@
   # End Source File
   # Begin Source File
   
  -SOURCE=..\..\..\..\src\xalanc\PlatformSupport\XalanDecimalFormat.cpp
  -# End Source File
  -# Begin Source File
  -
  -SOURCE=..\..\..\..\src\xalanc\PlatformSupport\XalanDecimalFormat.hpp
  -# End Source File
  -# Begin Source File
  -
   SOURCE=..\..\..\..\src\xalanc\PlatformSupport\XalanDecimalFormatSymbols.cpp
   # End Source File
   # Begin Source File
  
  
  
  1.44      +8 -16     xml-xalan/c/Projects/Win32/VC6/AllInOne/AllInOneWithICU.dsp
  
  Index: AllInOneWithICU.dsp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/Projects/Win32/VC6/AllInOne/AllInOneWithICU.dsp,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- AllInOneWithICU.dsp	6 Jan 2004 03:34:44 -0000	1.43
  +++ AllInOneWithICU.dsp	25 Feb 2004 20:47:59 -0000	1.44
  @@ -591,14 +591,6 @@
   # End Source File
   # Begin Source File
   
  -SOURCE=..\..\..\..\src\xalanc\PlatformSupport\XalanDecimalFormat.cpp
  -# End Source File
  -# Begin Source File
  -
  -SOURCE=..\..\..\..\src\xalanc\PlatformSupport\XalanDecimalFormat.hpp
  -# End Source File
  -# Begin Source File
  -
   SOURCE=..\..\..\..\src\xalanc\PlatformSupport\XalanDecimalFormatSymbols.cpp
   # End Source File
   # Begin Source File
  @@ -2679,14 +2671,6 @@
   # PROP Default_Filter ""
   # Begin Source File
   
  -SOURCE=..\..\..\..\src\xalanc\ICUBridge\FunctionICUFormatNumber.cpp
  -# End Source File
  -# Begin Source File
  -
  -SOURCE=..\..\..\..\src\xalanc\ICUBridge\FunctionICUFormatNumber.hpp
  -# End Source File
  -# Begin Source File
  -
   SOURCE=..\..\..\..\src\xalanc\ICUBridge\ICUBridge.cpp
   # End Source File
   # Begin Source File
  @@ -2720,6 +2704,14 @@
   # Begin Source File
   
   SOURCE=..\..\..\..\src\xalanc\ICUBridge\ICUBridgeDefinitions.hpp
  +# End Source File
  +# Begin Source File
  +
  +SOURCE=..\..\..\..\src\xalanc\ICUBridge\ICUFormatNumberFunctor.cpp
  +# End Source File
  +# Begin Source File
  +
  +SOURCE=..\..\..\..\src\xalanc\ICUBridge\ICUFormatNumberFunctor.hpp
   # End Source File
   # Begin Source File
   
  
  
  
  1.4       +0 -99     xml-xalan/c/src/xalanc/ICUBridge/ICUBridge.cpp
  
  Index: ICUBridge.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/ICUBridge/ICUBridge.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ICUBridge.cpp	6 Jan 2004 02:41:27 -0000	1.3
  +++ ICUBridge.cpp	25 Feb 2004 20:47:59 -0000	1.4
  @@ -60,21 +60,10 @@
   
   
   #include <xalanc/PlatformSupport/DOMStringHelper.hpp>
  -#include <xalanc/PlatformSupport/XalanDecimalFormatSymbols.hpp>
  -
  -
  -
  -#include <xalanc/PlatformSupport/DoubleSupport.hpp>
   
   
   
   #include <unicode/coll.h>
  -#include <unicode/dcfmtsym.h>
  -#include <unicode/decimfmt.h>
  -
  -
  -
  -#include <xalanc/Include/XalanAutoPtr.hpp>
   
   
   
  @@ -294,93 +283,5 @@
   	}
   #endif
   }
  -
  -
  -
  -static void
  -doFormatNumber(
  -			const XalanDOMString&				thePattern,
  -			double								theNumber,
  -			const XalanDecimalFormatSymbols&	theXalanDFS,
  -			UErrorCode&							theStatus,
  -			XalanDOMString&						theResult)
  -{
  -	if (theStatus == U_ZERO_ERROR ||
  -		theStatus == U_USING_DEFAULT_WARNING)
  -	{
  -		// Use a XalanAutoPtr, to keep this safe until we construct the DecimalFormat instance.
  -		XalanAutoPtr<DecimalFormatSymbols>	theDFS(new DecimalFormatSymbols(theStatus));
  -
  -		// We got a XalanDecimalFormatSymbols, so set the
  -		// corresponding data in the ICU DecimalFormatSymbols.
  -		theDFS->setSymbol(DecimalFormatSymbols::kZeroDigitSymbol, UChar(theXalanDFS.getZeroDigit()));
  -		theDFS->setSymbol(DecimalFormatSymbols::kGroupingSeparatorSymbol, UChar(theXalanDFS.getGroupingSeparator()));
  -		theDFS->setSymbol(DecimalFormatSymbols::kDecimalSeparatorSymbol, UChar(theXalanDFS.getDecimalSeparator()));
  -		theDFS->setSymbol(DecimalFormatSymbols::kPerMillSymbol, UChar(theXalanDFS.getPerMill()));
  -		theDFS->setSymbol(DecimalFormatSymbols::kPercentSymbol, UChar(theXalanDFS.getPercent()));
  -		theDFS->setSymbol(DecimalFormatSymbols::kDigitSymbol, UChar(theXalanDFS.getDigit()));
  -		theDFS->setSymbol(DecimalFormatSymbols::kPatternSeparatorSymbol, UChar(theXalanDFS.getPatternSeparator()));
  -
  -		theDFS->setSymbol(DecimalFormatSymbols::kInfinitySymbol, ICUBridge::XalanDOMStringToUnicodeString(theXalanDFS.getInfinity()));
  -		theDFS->setSymbol(DecimalFormatSymbols::kNaNSymbol, ICUBridge::XalanDOMStringToUnicodeString(theXalanDFS.getNaN()));
  -		theDFS->setSymbol(DecimalFormatSymbols::kMinusSignSymbol, UChar(theXalanDFS.getMinusSign()));
  -		theDFS->setSymbol(DecimalFormatSymbols::kCurrencySymbol, ICUBridge::XalanDOMStringToUnicodeString(theXalanDFS.getCurrencySymbol()));
  -		theDFS->setSymbol(DecimalFormatSymbols::kIntlCurrencySymbol, ICUBridge::XalanDOMStringToUnicodeString(theXalanDFS.getInternationalCurrencySymbol()));
  -		theDFS->setSymbol(DecimalFormatSymbols::kMonetarySeparatorSymbol, UChar(theXalanDFS.getMonetaryDecimalSeparator()));
  -
  -		UnicodeString	theUnicodeResult;
  -
  -		// Construct a DecimalFormat.  Note that we release the XalanAutoPtr, since the
  -		// DecimalFormat will adopt the DecimalFormatSymbols instance.
  -		DecimalFormat	theFormatter(ICUBridge::XalanDOMStringToUnicodeString(thePattern), theDFS.release(), theStatus);
  -
  -		if (U_SUCCESS(theStatus))
  -		{
  -			// Do the format...
  -			theFormatter.format(theNumber, theUnicodeResult);
  -
  -			ICUBridge::UnicodeStringToXalanDOMString(theUnicodeResult, theResult);
  -
  -			theStatus = U_ZERO_ERROR;
  -		}
  -	}
  -}
  -
  -
  -
  -unsigned long
  -ICUBridge::FormatNumber(
  -			const XalanDOMString&				thePattern,
  -			double								theNumber,
  -			const XalanDecimalFormatSymbols*	theXalanDFS,
  -			XalanDOMString&						theResult)
  -{
  -	UErrorCode	theStatus = U_ZERO_ERROR;
  -
  -	if (theXalanDFS == 0)
  -	{
  -		XalanDecimalFormatSymbols	theDefaultSymbols;
  -
  -		doFormatNumber(
  -				thePattern,
  -				theNumber,
  -				theDefaultSymbols,
  -				theStatus,
  -				theResult);
  -	}
  -	else
  -	{
  -		doFormatNumber(
  -				thePattern,
  -				theNumber,
  -				*theXalanDFS,
  -				theStatus,
  -				theResult);
  -	}
  -
  -	return theStatus;
  -}
  -
  -
   
   XALAN_CPP_NAMESPACE_END
  
  
  
  1.4       +0 -9      xml-xalan/c/src/xalanc/ICUBridge/ICUBridge.hpp
  
  Index: ICUBridge.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/ICUBridge/ICUBridge.hpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ICUBridge.hpp	6 Jan 2004 02:41:27 -0000	1.3
  +++ ICUBridge.hpp	25 Feb 2004 20:47:59 -0000	1.4
  @@ -77,8 +77,6 @@
   
   
   class Function;
  -class XalanDecimalFormatSymbols;
  -
   
   
   class XALAN_ICUBRIDGE_EXPORT ICUBridge
  @@ -103,13 +101,6 @@
   	UnicodeStringToXalanDOMString(
   			const UnicodeString&	theString,
   			XalanDOMString&			theResult);
  -
  -	static unsigned long
  -	FormatNumber(
  -			const XalanDOMString&				thePattern,
  -			double								theNumber,
  -			const XalanDecimalFormatSymbols*	theXalanDFS,
  -			XalanDOMString&						theResult);
   };
   
   
  
  
  
  1.1                  xml-xalan/c/src/xalanc/ICUBridge/ICUFormatNumberFunctor.cpp
  
  Index: ICUFormatNumberFunctor.cpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2004 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/>.
   */
  
  
  
  #include <algorithm>
  
  
  
  #include "ICUFormatNumberFunctor.hpp"
  
  
  
  #include <xalanc/ICUBridge/ICUBridge.hpp>
  
  
  
  #include <xalanc/Include/XalanAutoPtr.hpp>
  
  
  
  #include <xalanc/PlatformSupport/DOMStringHelper.hpp>
  #include <xalanc/PlatformSupport/XalanDecimalFormatSymbols.hpp>
  #include <xalanc/PlatformSupport/XalanMessageLoader.hpp>
  
  
  
  #include <xalanc/XPath/XPathExecutionContext.hpp>
  
  
  
  XALAN_CPP_NAMESPACE_BEGIN
  
  
  
  ICUFormatNumberFunctor::ICUFormatNumberFunctor()
  {
  	XalanDecimalFormatSymbols defaultXalanDFS;
  
  	m_defaultDecimalFormat = createDecimalFormat(defaultXalanDFS);
  }
  
  
  	
  ICUFormatNumberFunctor::~ICUFormatNumberFunctor()
  {
  	delete m_defaultDecimalFormat;
  
  	XALAN_USING_STD(for_each)
  	for_each(
  		m_decimalFormatCache.begin(),
  		m_decimalFormatCache.end(),
  		DecimalFormatCacheStruct::DecimalFormatDeleteFunctor());
  }
  
  
  
  void
  ICUFormatNumberFunctor::operator() (
  		XPathExecutionContext&				executionContext,	
  		double								theNumber,
  		const XalanDOMString&				thePattern,
  		const XalanDecimalFormatSymbols*	theDFS,
  		XalanDOMString&						theResult,
  		const XalanNode*					context,
  		const LocatorType*					locator) const 
  {
  	if (!doFormat(theNumber, thePattern, theResult, theDFS))
  	{
  		executionContext.warn(
  			XalanMessageLoader::getMessage(XalanMessages::FormatNumberFailed_1Param),
  			context,
  			locator);
  	}		
  }
  
  
  
  ICUFormatNumberFunctor::DecimalFormatType * 
  ICUFormatNumberFunctor::getCachedDecimalFormat(const XalanDecimalFormatSymbols &theDFS) const
  {
  	XALAN_USING_STD(find_if)
  
  	DecimalFormatCacheListType&		theNonConstCache =
  #if defined(XALAN_NO_MUTABLE)
  		(DecimalFormatCacheListType&)m_decimalFormatCache;
  #else
  		m_decimalFormatCache;
  #endif
  
  	DecimalFormatCacheListType::iterator i =
  		find_if(
  			theNonConstCache.begin(),
  			theNonConstCache.end(),
  			DecimalFormatCacheStruct::DecimalFormatFindFunctor(&theDFS));
  
  	if (i == theNonConstCache.end())
  	{
  		return 0;
  	}
  	else
  	{
  		// Let's do a quick check to see if we found the first entry.
  		// If so, we don't have to update the cache, so just return the
  		// appropriate value...
  		const DecimalFormatCacheListType::iterator	theBegin =
  			theNonConstCache.begin();
  
  		if (i == theBegin)
  		{
  			return (*i).m_formatter;
  		}
  		else
  		{
  			// Save the formatter, because splice() may invalidate
  			// i.
  			DecimalFormatType* const		theFormatter = (*i).m_formatter;
  
  			// Move the entry to the beginning the cache
  			theNonConstCache.splice(theBegin, theNonConstCache, i);
  
  			return theFormatter;
  		}
  	}
  }
  
  
  
  bool
  ICUFormatNumberFunctor::doFormat(	
  		double								theNumber,
  		const XalanDOMString&				thePattern,
  		XalanDOMString&						theResult,
  		const XalanDecimalFormatSymbols*	theDFS) const
  {
  	if (theDFS == 0)
  	{
  		return doICUFormat(theNumber,thePattern,theResult);
  	}
  
  	DecimalFormatType*	theFormatter = getCachedDecimalFormat(*theDFS);
  
  	if (theFormatter != 0)
  	{
  		return doICUFormat(theNumber, thePattern, theResult, theFormatter);
  	}
  	else
  	{
  		XalanAutoPtr<DecimalFormatType>	theDecimalFormatGuard(createDecimalFormat(*theDFS));
  
  		if (theDecimalFormatGuard.get() !=0)
  		{
  			// OK, there was no error, so cache the instance...
  			cacheDecimalFormat(theDecimalFormatGuard.get(), *theDFS);
  
  			// Release the collator, since it's in the cache and
  			// will be controlled by the cache...
  			DecimalFormatType * theDecimalFormat = theDecimalFormatGuard.release();
  
  			return doICUFormat(theNumber, thePattern, theResult, theDecimalFormat);
  		}
  		else
  		{
  			return doICUFormat(theNumber,thePattern,theResult);
  		}
  	}
  }
  
  
  
  ICUFormatNumberFunctor::DecimalFormatType *
  ICUFormatNumberFunctor::createDecimalFormat(
  		const XalanDecimalFormatSymbols&	theXalanDFS) const
  {
  	UErrorCode theStatus = U_ZERO_ERROR;	
  	
  	// Use a XalanAutoPtr, to keep this safe until we construct the DecimalFormat instance.
  	XalanAutoPtr<DecimalFormatSymbols>	theDFS(new DecimalFormatSymbols(theStatus));
  	// We got a XalanDecimalFormatSymbols, so set the
  	// corresponding data in the ICU DecimalFormatSymbols.
  	theDFS->setSymbol(DecimalFormatSymbols::kZeroDigitSymbol, UChar(theXalanDFS.getZeroDigit()));
  	theDFS->setSymbol(DecimalFormatSymbols::kGroupingSeparatorSymbol, UChar(theXalanDFS.getGroupingSeparator()));
  	theDFS->setSymbol(DecimalFormatSymbols::kDecimalSeparatorSymbol, UChar(theXalanDFS.getDecimalSeparator()));
  	theDFS->setSymbol(DecimalFormatSymbols::kPerMillSymbol, UChar(theXalanDFS.getPerMill()));
  	theDFS->setSymbol(DecimalFormatSymbols::kPercentSymbol, UChar(theXalanDFS.getPercent()));
  	theDFS->setSymbol(DecimalFormatSymbols::kDigitSymbol, UChar(theXalanDFS.getDigit()));
  	theDFS->setSymbol(DecimalFormatSymbols::kPatternSeparatorSymbol, UChar(theXalanDFS.getPatternSeparator()));
  
  	theDFS->setSymbol(DecimalFormatSymbols::kInfinitySymbol, ICUBridge::XalanDOMStringToUnicodeString(theXalanDFS.getInfinity()));
  	theDFS->setSymbol(DecimalFormatSymbols::kNaNSymbol, ICUBridge::XalanDOMStringToUnicodeString(theXalanDFS.getNaN()));
  	theDFS->setSymbol(DecimalFormatSymbols::kMinusSignSymbol, UChar(theXalanDFS.getMinusSign()));
  	theDFS->setSymbol(DecimalFormatSymbols::kCurrencySymbol, ICUBridge::XalanDOMStringToUnicodeString(theXalanDFS.getCurrencySymbol()));
  	theDFS->setSymbol(DecimalFormatSymbols::kIntlCurrencySymbol, ICUBridge::XalanDOMStringToUnicodeString(theXalanDFS.getInternationalCurrencySymbol()));
  	theDFS->setSymbol(DecimalFormatSymbols::kMonetarySeparatorSymbol, UChar(theXalanDFS.getMonetaryDecimalSeparator()));
  
  	// Construct a DecimalFormat.  Note that we release the XalanAutoPtr, since the
  	// DecimalFormat will adopt the DecimalFormatSymbols instance.
  	DecimalFormatType * theFormatter= new DecimalFormatType("", theDFS.release(), theStatus);
  
  	if (U_SUCCESS(theStatus))
  	{
  		return theFormatter;
  	} 
  	else 
  	{
  		delete theFormatter;
  		return 0;
  	}
  }
  
  
  
  void
  ICUFormatNumberFunctor::cacheDecimalFormat(
  	DecimalFormatType *						theFormatter,
  	const XalanDecimalFormatSymbols&		theDFS) const
  {
  
  	assert(theFormatter != 0);
  
  	DecimalFormatCacheListType&		theNonConstCache =
  #if defined(XALAN_NO_MUTABLE)
  		(DecimalFormatCacheListType&)m_decimalFormatCache;
  #else
  		m_decimalFormatCache;
  #endif
  
  	// Is the cache full?
  	if (theNonConstCache.size() == eCacheMax)
  	{
  		// Yes, so guard the collator instance, in case pop_back() throws...
  		XalanAutoPtr<DecimalFormatType>	theDecimalFormatGuard(theNonConstCache.back().m_formatter);
  
  		theNonConstCache.pop_back();
  	}
  
  
  	theNonConstCache.push_front(DecimalFormatCacheListType::value_type());
  
  	DecimalFormatCacheListType::value_type&		theEntry = 
  		theNonConstCache.front();
  
  	theEntry.m_formatter = theFormatter;
  	theEntry.m_DFS = theDFS;
  }
  
  
  
  bool
  ICUFormatNumberFunctor::doICUFormat(
  		double								theNumber,
  		const XalanDOMString&				thePattern,
  		XalanDOMString&						theResult,
  		DecimalFormatType*					theFormatter) const
  {
  	UErrorCode theStatus = U_ZERO_ERROR;
  
  	if (theFormatter == 0)
  	{
  		if (m_defaultDecimalFormat != 0) 
  		{
  			theFormatter = m_defaultDecimalFormat;
  		}
  		else
  		{
  			return false;
  		}
  	}
  
  	theFormatter->applyPattern(ICUBridge::XalanDOMStringToUnicodeString(thePattern),theStatus);
  
  	if (U_SUCCESS(theStatus))
  	{
  		// Do the format...
  		UnicodeString	theUnicodeResult;
  		theFormatter->format(theNumber, theUnicodeResult);
  		ICUBridge::UnicodeStringToXalanDOMString(theUnicodeResult, theResult);
  	}
  	return U_SUCCESS(theStatus);
  }
  
  
  
  XALAN_CPP_NAMESPACE_END
  
  
  
  1.1                  xml-xalan/c/src/xalanc/ICUBridge/ICUFormatNumberFunctor.hpp
  
  Index: ICUFormatNumberFunctor.hpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2004 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/>.
   */
  #if !defined(FUNCTIONICUFORMATNUMBERFUNCTOR_HEADER_GUARD_1357924680)
  #define FUNCTIONICUFORMATNUMBERFUNCTOR_HEADER_GUARD_1357924680
  
  
  
  // Base header file.  Must be first.
  #include <xalanc/ICUBridge/ICUBridgeDefinitions.hpp>
  
  
  
  #include <xalanc/PlatformSupport/XalanDecimalFormatSymbols.hpp>
  
  
  
  #include <xalanc/XSLT/StylesheetExecutionContextDefault.hpp>
  
  
  
  #include <xalanc/XPath/XPathExecutionContext.hpp>
  
  
  
  #include <unicode/decimfmt.h>
  
  
  
  #include <list>
  
  
  
  XALAN_CPP_NAMESPACE_BEGIN
  
  typedef StylesheetExecutionContextDefault::FormatNumberFunctor FormatNumberFunctor;
  // Class that implements the XSLT function format-number using the ICU.
  //
  class XALAN_ICUBRIDGE_EXPORT ICUFormatNumberFunctor : public FormatNumberFunctor
  {
  public:
  
  	ICUFormatNumberFunctor();
  
  	virtual
  	~ICUFormatNumberFunctor();
  
  	virtual void
  		operator() (
  		XPathExecutionContext&				executionContext,
  		double								theNumber,
  		const XalanDOMString&				thePattern,
  		const XalanDecimalFormatSymbols*	theDFS,
  		XalanDOMString&						theResult,
  		const XalanNode*					context = 0,
  		const LocatorType*					locator = 0) const;
  	
  #if defined(XALAN_HAS_CPP_NAMESPACE)
  	typedef U_ICU_NAMESPACE::DecimalFormat	DecimalFormatType;
  #else
  	typedef DecimalFormat					DecimalFormatType;
  #endif
  	struct DecimalFormatCacheStruct
  	{
  		DecimalFormatCacheStruct(
  				const XalanDecimalFormatSymbols&	theDFS,
  				DecimalFormatType*					theFormatter):
  			m_DFS(theDFS),
  			m_formatter(theFormatter)
  		{
  		}
  
  		DecimalFormatCacheStruct() :
  			m_DFS(),
  			m_formatter(0)
  		{
  		}
  
  #if defined(XALAN_NO_SELECTIVE_TEMPLATE_INSTANTIATION)
  		bool
  		operator<(const DecimalFormatCacheStruct&  theRHS) const
  		{
  			return this < &theRHS;
  		}
  
  		bool
  		operator==(const DecimalFormatCacheStruct&	theRHS) const
  		{
  			return this == &theRHS;
  		}
  #endif
  
  		XalanDecimalFormatSymbols	m_DFS;
  
  		DecimalFormatType *	m_formatter;
  
  		struct DecimalFormatDeleteFunctor
  		{
  			void
  			operator()(DecimalFormatCacheStruct&	theStruct) const
  			{
  				delete theStruct.m_formatter;
  			}
  		};
  
  		struct DecimalFormatFindFunctor
  		{
  			DecimalFormatFindFunctor(const XalanDecimalFormatSymbols*	theDFS) :
  				m_DFS(theDFS)
  			{
  			}
  
  			bool
  			operator()(DecimalFormatCacheStruct&	theStruct) const
  			{
  				return theStruct.m_DFS == (*m_DFS);
  			}
  
  			const XalanDecimalFormatSymbols * const	m_DFS;
  		};
  	};
  
  #if defined(XALAN_NO_STD_NAMESPACE)
  	typedef list<DecimalFormatCacheStruct>			DecimalFormatCacheListType;
  #else
  	typedef std::list<DecimalFormatCacheStruct>		DecimalFormatCacheListType;
  #endif
  
  	DecimalFormatType * getCachedDecimalFormat(const XalanDecimalFormatSymbols &theDFS) const;
  
  	bool
  	doFormat(	
  		double								theNumber,
  		const XalanDOMString&				thePattern,
  		XalanDOMString&						theResult,
  		const XalanDecimalFormatSymbols*	theDFS = 0) const;
  
  	bool
  	doICUFormat(
  		double								theNumber,
  		const XalanDOMString&				thePattern,
  		XalanDOMString&						theResult,
  		DecimalFormatType*					theFormatter = 0) const;
  
  	void
  	cacheDecimalFormat(
  		DecimalFormatType*					theFormatter,
  		const XalanDecimalFormatSymbols&	theDFS) const;
  
  	DecimalFormat *
  	createDecimalFormat(
  		const XalanDecimalFormatSymbols&	theXalanDFS) const;
  
  	enum { eCacheMax = 10 };
  
  	DecimalFormatType * m_defaultDecimalFormat;
  	
  	mutable DecimalFormatCacheListType m_decimalFormatCache;
  
  	ICUFormatNumberFunctor&
  	operator=(const ICUFormatNumberFunctor&);
  
  	bool
  	operator==(const ICUFormatNumberFunctor&) const;
  
  };
  
  XALAN_CPP_NAMESPACE_END
  
  #endif	// FUNCTIONICUFORMATNUMBERFUNCTOR_HEADER_GUARD_1357924680
  
  
  
  1.7       +0 -6      xml-xalan/c/src/xalanc/TestXSLT/process.cpp
  
  Index: process.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/TestXSLT/process.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- process.cpp	6 Jan 2004 02:41:31 -0000	1.6
  +++ process.cpp	25 Feb 2004 20:47:59 -0000	1.7
  @@ -158,7 +158,6 @@
   
   //#define XALAN_USE_ICU
   #if defined(XALAN_USE_ICU)
  -#include <xalanc/ICUBridge/FunctionICUFormatNumber.hpp>
   #include <xalanc/ICUBridge/ICUBridgeCollationCompareFunctor.hpp>
   #endif
   
  @@ -819,11 +818,6 @@
   	// we're done with the subsystem, since its destructor shuts down
   	// the subsystem.
   	XSLTInit	theInit;
  -
  -#if defined(XALAN_USE_ICU)
  -	// Create an installer to install the substitute format-number() function.
  -	FunctionICUFormatNumber::FunctionICUFormatNumberInstaller	theInstaller;
  -#endif
   
   	const XalanDOMString	mimeEncoding(XALAN_STATIC_UCODE_STRING("UTF-8"));
   	const XalanDOMString	encoding(XALAN_STATIC_UCODE_STRING("UTF-8"));
  
  
  
  1.7       +31 -7     xml-xalan/c/src/xalanc/XPath/XPathExecutionContext.hpp
  
  Index: XPathExecutionContext.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XPathExecutionContext.hpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XPathExecutionContext.hpp	6 Jan 2004 02:41:32 -0000	1.6
  +++ XPathExecutionContext.hpp	25 Feb 2004 20:47:59 -0000	1.7
  @@ -694,16 +694,40 @@
   			const XalanDOMString&	theURI,
   			XalanDocument*			theDocument) = 0;
   
  +	/**
  +	 * Formats a number according to the specified pattern.
  +	 * 
  +	 * @param number the number to be formatted
  +	 * @param pattern the format pattern
  +	 * @param theResult the formatted number
  +	 * @param context the source node
  +	 * @param locator the locator 
  +	 */
  +	virtual void formatNumber(
  +			double								number,
  +			const XalanDOMString&				pattern,
  +			XalanDOMString&						theResult,
  +			const XalanNode*					context = 0,
  +			const LocatorType*					locator = 0) = 0;
   
   	/**
  -	 * Retrieve the XalanDecimalFormatSymbols instance associated with
  -	 * the name.
  -	 *
  -	 * @param qname the QName for the lookup
  -	 * @return a pointer to the matching instance, or 0 if none was found
  +	 * Formats a number according to the specified pattern.
  +	 * 
  +	 * @param number the number to be formatted
  +	 * @param pattern the format pattern
  +	 * @param dfsName the name of decimal format to use 
  +	 * @param theResult the formatted number
  +	 * @param context the source node
  +	 * @param locator the locator 
  +	 * @return a pointer to the functor, 0 if none was found
   	 */
  -	virtual const XalanDecimalFormatSymbols*
  -	getDecimalFormatSymbols(const XalanQName&	qname) = 0;
  +	virtual void formatNumber(
  +			double								number,
  +			const XalanDOMString&				pattern,
  +			const XalanDOMString&				dfsName,
  +			XalanDOMString&						theResult,
  +			const XalanNode*					context = 0,
  +			const LocatorType*					locator = 0) = 0;
   
   	// These interfaces are inherited from ExecutionContext...
   
  
  
  
  1.6       +78 -3     xml-xalan/c/src/xalanc/XPath/XPathExecutionContextDefault.cpp
  
  Index: XPathExecutionContextDefault.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XPathExecutionContextDefault.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XPathExecutionContextDefault.cpp	6 Jan 2004 02:41:32 -0000	1.5
  +++ XPathExecutionContextDefault.cpp	25 Feb 2004 20:47:59 -0000	1.6
  @@ -72,6 +72,10 @@
   
   #include <xalanc/PlatformSupport/PrefixResolver.hpp>
   #include <xalanc/PlatformSupport/XalanLocator.hpp>
  +#include <xalanc/PlatformSupport/DoubleSupport.hpp>
  +#include <xalanc/PlatformSupport/DOMStringHelper.hpp>
  +#include <xalanc/PlatformSupport/XalanDecimalFormatSymbols.hpp>
  +#include <xalanc/PlatformSupport/XalanMessageLoader.hpp>
   
   
   
  @@ -703,10 +707,81 @@
   
   
   
  -const XalanDecimalFormatSymbols*
  -XPathExecutionContextDefault::getDecimalFormatSymbols(const XalanQName&		/* qname */)
  +void XPathExecutionContextDefault::formatNumber(
  +		double								number,
  +		const XalanDOMString&				pattern,
  +		XalanDOMString&						theResult,
  +		const XalanNode*					context,
  +		const LocatorType*					locator) 
   {
  -	return 0;
  +	doFormatNumber(number,pattern,0,theResult,context,locator);
  +}
  +
  +
  +
  +void XPathExecutionContextDefault::formatNumber(
  +			double								number,
  +			const XalanDOMString&				pattern,
  +			const XalanDOMString&				dfsName,
  +			XalanDOMString&						theResult,
  +			const XalanNode*					context,
  +			const LocatorType*					locator) 
  +{
  +	doFormatNumber(number,pattern,0,theResult,context,locator);
  +}
  +
  +
  +	
  +void XPathExecutionContextDefault::doFormatNumber(
  +			double								number,
  +			const XalanDOMString&				pattern,
  +			const XalanDecimalFormatSymbols*	theDFS,
  +			XalanDOMString&						theResult,
  +			const XalanNode*					context,
  +			const LocatorType*					locator) 
  +{
  +	if (DoubleSupport::isNaN(number) == true)
  +	{
  +		if (theDFS != 0)
  +		{
  +			theResult = theDFS->getNaN();
  +		}
  +		else
  +		{
  +			DoubleToDOMString(number, theResult);
  +		}
  +	}
  +	else if (DoubleSupport::isNegativeInfinity(number) == true)
  +	{
  +		if (theDFS != 0)
  +		{
  +			theResult = theDFS->getMinusSign();
  +			theResult += theDFS->getInfinity();
  +		}
  +		else
  +		{
  +			DoubleToDOMString(number, theResult);
  +		}
  +	}
  +	else if (DoubleSupport::isPositiveInfinity(number) == true )
  +	{
  +		if (theDFS != 0)
  +		{
  +			theResult = theDFS->getInfinity();
  +		}
  +		else
  +		{
  +			DoubleToDOMString(number, theResult);
  +		}
  +	}
  +	else
  +	{
  +	    warn( 
  +			XalanMessageLoader::getMessage(XalanMessages::FunctionIsNotImplemented_1Param,"format-number()"),
  +			context, 
  +			locator);
  +		DoubleToDOMString(number,theResult);
  +	}
   }
   
   
  
  
  
  1.6       +23 -3     xml-xalan/c/src/xalanc/XPath/XPathExecutionContextDefault.hpp
  
  Index: XPathExecutionContextDefault.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XPath/XPathExecutionContextDefault.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XPathExecutionContextDefault.hpp	6 Jan 2004 02:41:32 -0000	1.5
  +++ XPathExecutionContextDefault.hpp	25 Feb 2004 20:47:59 -0000	1.6
  @@ -216,6 +216,14 @@
   #endif
   	}
   
  +	virtual void doFormatNumber(
  +			double								number,
  +			const XalanDOMString&				pattern,
  +			const XalanDecimalFormatSymbols*	theDFS,
  +			XalanDOMString&						theResult,
  +			const XalanNode*					context = 0,
  +			const LocatorType*					locator = 0);
  +
   	// These interfaces are inherited from XPathExecutionContext...
   
   	virtual void
  @@ -342,11 +350,23 @@
   			const XalanDOMString&	theURI,
   			XalanDocument*			theDocument);
   
  -	virtual const XalanDecimalFormatSymbols*
  -	getDecimalFormatSymbols(const XalanQName&	qname);
  +	// These interfaces are inherited from ExecutionContext...
   
  +	virtual void formatNumber(
  +			double								number,
  +			const XalanDOMString&				pattern,
  +			XalanDOMString&						theResult,
  +			const XalanNode*					context = 0,
  +			const LocatorType*					locator = 0);
  +
  +	virtual void formatNumber(
  +			double								number,
  +			const XalanDOMString&				pattern,
  +			const XalanDOMString&				dfsName,
  +			XalanDOMString&						theResult,
  +			const XalanNode*					context = 0,
  +			const LocatorType*					locator = 0);
   
  -	// These interfaces are inherited from ExecutionContext...
   
   	virtual void
   	error(
  
  
  
  1.5       +15 -169   xml-xalan/c/src/xalanc/XSLT/FunctionFormatNumber.cpp
  
  Index: FunctionFormatNumber.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/FunctionFormatNumber.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FunctionFormatNumber.cpp	6 Jan 2004 02:41:36 -0000	1.4
  +++ FunctionFormatNumber.cpp	25 Feb 2004 20:47:59 -0000	1.5
  @@ -58,20 +58,8 @@
   
   
   
  -#include <xalanc/PlatformSupport/DoubleSupport.hpp>
  -#include <xalanc/PlatformSupport/DOMStringHelper.hpp>
  -#include <xalanc/PlatformSupport/XalanDecimalFormat.hpp>
  -#include <xalanc/PlatformSupport/XalanDecimalFormatSymbols.hpp>
   #include <xalanc/PlatformSupport/XalanMessageLoader.hpp>
  -
  -
  -
   #include <xalanc/XPath/XObjectFactory.hpp>
  -#include <xalanc/XPath/XalanQNameByValue.hpp>
  -
  -
  -
  -#include "Constants.hpp"
   
   
   
  @@ -91,10 +79,6 @@
   
   
   
  -static const XalanQNameByValue	theEmptyQName;
  -
  -
  -
   XObjectPtr
   FunctionFormatNumber::execute(
   			XPathExecutionContext&	executionContext,
  @@ -108,25 +92,16 @@
   	const double						theNumber = arg1->num();
   	const XalanDOMString&				thePattern = arg2->str();
   	
  -	const XalanDecimalFormatSymbols*	theDFS = 0;
  -
  -	if (theDFS == 0)
  -	{
  -		theDFS = executionContext.getDecimalFormatSymbols(theEmptyQName);
  -	}
  -
   	typedef XPathExecutionContext::GetAndReleaseCachedString	GetAndReleaseCachedString;
   
   	GetAndReleaseCachedString	theString(executionContext);
   
  -	doFormat(
  -			executionContext,
  -			context,
  -			theNumber,
  -			thePattern,
  -			theDFS,
  -			theString.get(),
  -			locator);
  +	executionContext.formatNumber(
  +			theNumber, 
  +			thePattern, 
  +			theString.get(), 
  +			context, 
  +			locator);	
   
   	return executionContext.getXObjectFactory().createString(theString);
   }
  @@ -147,116 +122,24 @@
   	const double						theNumber = arg1->num();
   	const XalanDOMString&				thePattern = arg2->str();
   
  -	const XalanDOMString&				theDecimalFormatName = arg3->str();
  -	assert(length(theDecimalFormatName) != 0);
  -
  -	const XalanQNameByValue				theQName(theDecimalFormatName, executionContext.getPrefixResolver());
  -
  -	const XalanDecimalFormatSymbols*	theDFS =
  -			executionContext.getDecimalFormatSymbols(theQName);
  -
  -	if (theDFS == 0)
  -	{
  -		executionContext.warn(
  -				s_warningNotFoundString,
  -				context,
  -				locator);
  -
  -		theDFS = executionContext.getDecimalFormatSymbols(theEmptyQName);
  +	const XalanDOMString&				theDFSName = arg3->str();
  +	assert(length(theDFSName) != 0);
   	
  -	}	
  -
   	typedef XPathExecutionContext::GetAndReleaseCachedString	GetAndReleaseCachedString;
   
   	GetAndReleaseCachedString	theString(executionContext);
   
  -	doFormat(
  -			executionContext,
  -			context,
  -			theNumber,
  -			thePattern,
  -			theDFS,
  -			theString.get(),
  -			locator);
  +	executionContext.formatNumber(
  +		theNumber, 
  +		thePattern,
  +		theDFSName,
  +		theString.get(),
  +		context, 
  +		locator);
   
   	return executionContext.getXObjectFactory().createString(theString);
   }
   
  -
  -
  -void
  -FunctionFormatNumber::doFormat(
  -			XPathExecutionContext&				executionContext,
  -			XalanNode*							context,
  -			double								theNumber,
  -			const XalanDOMString&				thePattern,
  -			const XalanDecimalFormatSymbols*	theDFS,
  -			XalanDOMString&						theResult,
  -			const LocatorType*					locator,
  -			bool								fWarn) const
  -{
  -	if (DoubleSupport::isNaN(theNumber) == true)
  -	{
  -		if (theDFS != 0)
  -		{
  -			theResult = theDFS->getNaN();
  -		}
  -		else
  -		{
  -			DoubleToDOMString(theNumber, theResult);
  -		}
  -	}
  -	else if (DoubleSupport::isNegativeInfinity(theNumber) == true)
  -	{
  -		if (theDFS != 0)
  -		{
  -			theResult = theDFS->getMinusSign();
  -			theResult += theDFS->getInfinity();
  -		}
  -		else
  -		{
  -			DoubleToDOMString(theNumber, theResult);
  -		}
  -	}
  -	else if (DoubleSupport::isPositiveInfinity(theNumber) == true )
  -	{
  -		if (theDFS != 0)
  -		{
  -			theResult = theDFS->getInfinity();
  -		}
  -		else
  -		{
  -			DoubleToDOMString(theNumber, theResult);
  -		}
  -	}
  -	else
  -	{
  -		if (fWarn == true)
  -		{
  -			executionContext.warn(s_warningNotImplementedString, context, locator);
  -		}
  -
  -		if (theDFS != 0)
  -		{
  -			XalanDecimalFormat	theFormatter(s_emptyString, *theDFS);
  -
  -			theFormatter.applyLocalizedPattern(thePattern);
  -
  -			theFormatter.format(theNumber, theResult);
  -		}
  -		else
  -		{
  -			XalanDecimalFormat	theFormatter(s_emptyString, m_decimalFormatSymbols);
  -
  -			theFormatter.applyLocalizedPattern(thePattern);
  -
  -			theFormatter.format(theNumber, theResult);
  -		}
  -	}
  -}
  -
  -
  -
   #if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
   Function*
   #else
  @@ -267,47 +150,10 @@
   	return new FunctionFormatNumber(*this);
   }
   
  -
  -
   const XalanDOMString
   FunctionFormatNumber::getError() const
   {
   	return XalanMessageLoader::getMessage(XalanMessages::FunctionTakesTwoOrThreeArguments_1Param,"format-number()");
   }
  -
  -
  -
  -static XalanDOMString	s_staticWarningNotImplementedString;
  -static XalanDOMString	s_staticWarningNotFoundString;
  -
  -
  -const XalanDOMString&	FunctionFormatNumber::s_warningNotImplementedString =
  -		s_staticWarningNotImplementedString;
  -
  -const XalanDOMString&	FunctionFormatNumber::s_warningNotFoundString =
  -		s_staticWarningNotFoundString;
  -
  -const XalanDOMString	FunctionFormatNumber::s_emptyString;
  -
  -
  -void
  -FunctionFormatNumber::initialize()
  -{
  -	s_staticWarningNotImplementedString = XalanMessageLoader::getMessage(XalanMessages::FunctionIsNotImplemented_1Param,"format-number()");
  -
  -	s_staticWarningNotFoundString = XalanMessageLoader::getMessage(XalanMessages::Decimal_formatElementNotFound_1Param,"format-number()");
  -}
  -
  -
  -
  -void
  -FunctionFormatNumber::terminate()
  -{
  -	releaseMemory(s_staticWarningNotImplementedString);
  -
  -	releaseMemory(s_staticWarningNotFoundString);
  -}
  -
  -
   
   XALAN_CPP_NAMESPACE_END
  
  
  
  1.3       +0 -53     xml-xalan/c/src/xalanc/XSLT/FunctionFormatNumber.hpp
  
  Index: FunctionFormatNumber.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/FunctionFormatNumber.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FunctionFormatNumber.hpp	6 Jan 2004 02:41:36 -0000	1.2
  +++ FunctionFormatNumber.hpp	25 Feb 2004 20:47:59 -0000	1.3
  @@ -64,32 +64,12 @@
   
   
   
  -#include <vector>
  -
  -
  -
  -#include <xalanc/XalanDOM/XalanDOMString.hpp>
  -
  -
  -
  -#include <xalanc/PlatformSupport/XalanDecimalFormatSymbols.hpp>
  -
  -
  -
   #include <xalanc/XPath/Function.hpp>
   
   
   
   XALAN_CPP_NAMESPACE_BEGIN
   
  -
  -
  -class XalanDecimalFormatSymbols;
  -class XObject;
  -class XPathExecutionContext;
  -
  -
  -
   // Implementation of the XSLT function format-number.
   //
   class XALAN_XSLT_EXPORT FunctionFormatNumber : public Function
  @@ -98,18 +78,6 @@
   
   	typedef Function	ParentType;
   
  -	/**
  -	 * Perform static initialization.  See class XSLTInit.
  -	 */
  -	static void
  -	initialize();
  -
  -	/**
  -	 * Perform static shut down.  See class XSLTInit.
  -	 */
  -	static void
  -	terminate();
  -
   	FunctionFormatNumber();
   
   	virtual
  @@ -145,19 +113,6 @@
   #endif
   	clone() const;
   
  -protected:
  -
  -	virtual void
  -	doFormat(
  -			XPathExecutionContext&				executionContext,
  -			XalanNode*							context,
  -			double								theNumber,
  -			const XalanDOMString&				thePattern,
  -			const XalanDecimalFormatSymbols*	theDFS,
  -			XalanDOMString&						theResult,
  -			const LocatorType*					locator,
  -			bool								fWarn = true) const;
  -
   private:
   
   	const XalanDOMString
  @@ -170,14 +125,6 @@
   	bool
   	operator==(const FunctionFormatNumber&) const;
   
  -	// Data members...
  -	const XalanDecimalFormatSymbols		m_decimalFormatSymbols;
  -
  -	static const XalanDOMString&		s_warningNotImplementedString;
  -
  -	static const XalanDOMString&		s_warningNotFoundString;
  -
  -	static const XalanDOMString			s_emptyString;
   };
   
   
  
  
  
  1.19      +99 -1     xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.cpp
  
  Index: StylesheetExecutionContextDefault.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.cpp,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- StylesheetExecutionContextDefault.cpp	6 Feb 2004 18:01:50 -0000	1.18
  +++ StylesheetExecutionContextDefault.cpp	25 Feb 2004 20:47:59 -0000	1.19
  @@ -136,6 +136,8 @@
   
   
   
  +
  +
   StylesheetExecutionContextDefault::StylesheetExecutionContextDefault(
   			XSLTEngineImpl&			xsltProcessor,
   			XPathEnvSupport&		theXPathEnvSupport,
  @@ -160,6 +162,7 @@
   	m_printWriters(),
   	m_outputStreams(),
   	m_collationCompareFunctor(0),
  +	m_formatNumberFunctor(0),
   	m_variablesStack(),
   	m_matchPatternCache(),
   	m_keyTables(),
  @@ -202,6 +205,7 @@
   	m_printWriters(),
   	m_outputStreams(),
   	m_collationCompareFunctor(0),
  +	m_formatNumberFunctor(0),
   	m_variablesStack(),
   	m_matchPatternCache(),
   	m_keyTables(),
  @@ -1645,6 +1649,100 @@
   
   
   
  +static const XalanQNameByValue	theEmptyQName;
  +
  +
  +
  +void 
  +StylesheetExecutionContextDefault::formatNumber(
  +			double								number,
  +			const XalanDOMString&				pattern,
  +			XalanDOMString&						theResult,
  +			const XalanNode*					context,
  +			const LocatorType*					locator)
  +{
  +	const XalanDecimalFormatSymbols * theDFS = getDecimalFormatSymbols(theEmptyQName);
  +
  +	if (m_formatNumberFunctor == 0) 
  +	{
  +		m_xpathExecutionContextDefault.doFormatNumber(number,pattern, theDFS, theResult,context,locator);
  +	} 
  +	else 
  +	{
  +		(*m_formatNumberFunctor)(*this, number,	pattern, theDFS, theResult, context, locator);
  +	}
  +}
  + 
  +
  +
  +void 
  +StylesheetExecutionContextDefault::formatNumber(
  +			double								number,
  +			const XalanDOMString&				pattern,
  +			const XalanDOMString&				dfsName,
  +			XalanDOMString&						theResult,
  +			const XalanNode*					context,
  +			const LocatorType*					locator)
  +{
  +	XalanQNameByValue&	theDFSQName = m_xpathExecutionContextDefault.getScratchQName();
  +	theDFSQName.set(dfsName, getPrefixResolver(), locator);
  +
  +	const XalanDecimalFormatSymbols*	theDFS = getDecimalFormatSymbols(theDFSQName);
  +
  +	if (theDFS == 0)
  +	{
  +		warn(
  +				XalanMessageLoader::getMessage(XalanMessages::Decimal_formatElementNotFound_1Param,"format-number()"),
  +				context,
  +				locator);	
  +		theDFS = getDecimalFormatSymbols(theEmptyQName);
  +		
  +	}
  +
  +	if (m_formatNumberFunctor == 0) 
  +	{
  +		m_xpathExecutionContextDefault.doFormatNumber(number,pattern,theDFS,theResult,context,locator);
  +	} 
  +	else 
  +	{	
  +		(*m_formatNumberFunctor)(*this, number, pattern, theDFS, theResult, context, locator);
  +	}
  +}
  +
  +
  +
  +const StylesheetExecutionContextDefault::FormatNumberFunctor*
  +StylesheetExecutionContextDefault::installFormatNumberFunctor(FormatNumberFunctor*	theFunctor)
  +{
  +	assert(theFunctor != 0);
  +
  +	const FormatNumberFunctor * const	temp = m_formatNumberFunctor;
  +
  +	m_formatNumberFunctor = theFunctor;
  +
  +	return temp;
  +}
  +
  +
  +
  +StylesheetExecutionContextDefault::FormatNumberFunctor*
  +StylesheetExecutionContextDefault::uninstallFormatNumberFunctor() {
  +	if (m_formatNumberFunctor == 0)
  +	{
  +		return 0;
  +	}
  +	else
  +	{
  +		FormatNumberFunctor * const	temp = m_formatNumberFunctor;
  +
  +		m_formatNumberFunctor = 0;
  +
  +		return temp;
  +	}
  +}
  +
  +
  +
   bool
   StylesheetExecutionContextDefault::getInConstruction(const KeyDeclaration&	keyDeclaration) const
   {
  @@ -2062,7 +2160,7 @@
   {
   	if (m_stylesheetRoot == 0)
   	{
  -		return m_xpathExecutionContextDefault.getDecimalFormatSymbols(qname);
  +		return 0; 
   	}
   	else
   	{
  
  
  
  1.14      +50 -3     xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.hpp
  
  Index: StylesheetExecutionContextDefault.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.hpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- StylesheetExecutionContextDefault.hpp	6 Feb 2004 18:01:50 -0000	1.13
  +++ StylesheetExecutionContextDefault.hpp	25 Feb 2004 20:47:59 -0000	1.14
  @@ -769,6 +769,50 @@
   	CollationCompareFunctor*
   	uninstallCollationCompareFunctor();
   
  +
  +	class  FormatNumberFunctor
  +	{
  +	public:
  +		FormatNumberFunctor() {};
  +
  +		virtual
  +		~FormatNumberFunctor() {};
  +
  +		virtual void
  +		operator() (
  +			XPathExecutionContext&				executionContext,
  +			double								theNumber,
  +			const XalanDOMString&				thePattern,
  +			const XalanDecimalFormatSymbols*	theDFS,
  +			XalanDOMString&						theResult,
  +			const XalanNode*					context = 0,
  +			const LocatorType*					locator = 0) const =0;
  +	};
  +
  +	void 
  +	formatNumber(
  +			double								number,
  +			const XalanDOMString&				pattern,
  +			XalanDOMString&						theResult,
  +			const XalanNode*					context = 0,
  +			const LocatorType*					locator = 0);
  +
  +	void 
  +	formatNumber(
  +			double								number,
  +			const XalanDOMString&				pattern,
  +			const XalanDOMString&				dfsName,
  +			XalanDOMString&						theResult,
  +			const XalanNode*					context = 0,
  +			const LocatorType*					locator = 0);
  +
  +
  +	const FormatNumberFunctor * 
  +	installFormatNumberFunctor(FormatNumberFunctor * formatNumberFunctor);
  +	
  +	FormatNumberFunctor *
  +	uninstallFormatNumberFunctor();
  +
   	virtual	bool
   	getInConstruction(const KeyDeclaration&		keyDeclaration) const;
   
  @@ -778,9 +822,6 @@
   	virtual	void
   	endConstruction(const KeyDeclaration&	keyDeclaration);
   
  -	virtual const XalanDecimalFormatSymbols*
  -	getDecimalFormatSymbols(const XalanQName&	qname);
  -
   	virtual PrintWriter*
   	createPrintWriter(XalanOutputStream*		theTextOutputStream);
   
  @@ -1009,6 +1050,9 @@
   	virtual bool
   	returnFormatterToText(FormatterToText*	theFormatter);
   
  +	virtual const XalanDecimalFormatSymbols*
  +	getDecimalFormatSymbols(const XalanQName&	qname);
  +
   private:
   
   	/**
  @@ -1091,6 +1135,8 @@
   
   	CollationCompareFunctor*			m_collationCompareFunctor;
   
  +	FormatNumberFunctor *				m_formatNumberFunctor;
  +
   	/**
   	 * Holds all information about variables during execution.
   	 */
  @@ -1158,6 +1204,7 @@
   	static XalanNumberFormatFactory*	s_xalanNumberFormatFactory;
   
   	static const DefaultCollationCompareFunctor		s_defaultCollationFunctor;
  +
   };
   
   
  
  
  
  1.4       +0 -5      xml-xalan/c/src/xalanc/XSLT/XSLTInit.cpp
  
  Index: XSLTInit.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/XSLTInit.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XSLTInit.cpp	6 Jan 2004 02:41:36 -0000	1.3
  +++ XSLTInit.cpp	25 Feb 2004 20:47:59 -0000	1.4
  @@ -61,7 +61,6 @@
   
   #include "Constants.hpp"
   #include "ElemNumber.hpp"
  -#include "FunctionFormatNumber.hpp"
   #include "StylesheetHandler.hpp"
   #include "XSLTEngineImpl.hpp"
   
  @@ -111,8 +110,6 @@
   
   	ElemNumber::initialize();
   
  -	FunctionFormatNumber::initialize();
  -
   	XSLTEngineImpl::initialize();
   
   	StylesheetHandler::initialize();
  @@ -126,8 +123,6 @@
   	StylesheetHandler::terminate();
   
   	XSLTEngineImpl::terminate();
  -
  -	FunctionFormatNumber::terminate();
   
   	ElemNumber::terminate();
   
  
  
  
  1.14      +6 -9      xml-xalan/c/src/xalanc/XalanTransformer/XalanTransformer.cpp
  
  Index: XalanTransformer.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XalanTransformer/XalanTransformer.cpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- XalanTransformer.cpp	28 Jan 2004 20:20:27 -0000	1.13
  +++ XalanTransformer.cpp	25 Feb 2004 20:48:00 -0000	1.14
  @@ -116,9 +116,9 @@
   
   //#define XALAN_USE_ICU
   #if defined(XALAN_USE_ICU)
  -#include <xalanc/ICUBridge/FunctionICUFormatNumber.hpp>
   #include <xalanc/ICUBridge/ICUBridgeCleanup.hpp>
   #include <xalanc/ICUBridge/ICUBridgeCollationCompareFunctor.hpp>
  +#include <xalanc/ICUBridge/ICUFormatNumberFunctor.hpp>
   #endif
   
   
  @@ -169,7 +169,11 @@
   
   	m_stylesheetExecutionContext->installCollationCompareFunctor(theICUFunctor.get());
   
  +	XalanAutoPtr<ICUFormatNumberFunctor>  theFormatNumberFunctor(new ICUFormatNumberFunctor());
  +	m_stylesheetExecutionContext->installFormatNumberFunctor(theFormatNumberFunctor.get());
   	theICUFunctor.release();
  +	theFormatNumberFunctor.release();
  +
   #endif
   }
   
  @@ -197,6 +201,7 @@
   #if defined(XALAN_USE_ICU)
   	// Uninstall the ICU collation compare functor, and destroy it...
   	delete m_stylesheetExecutionContext->uninstallCollationCompareFunctor();
  +	delete m_stylesheetExecutionContext->uninstallFormatNumberFunctor();
   #endif
   
   	delete m_stylesheetExecutionContext;
  @@ -218,14 +223,6 @@
   	XalanEXSLTSetFunctionsInstaller::installGlobal();
   	XalanEXSLTStringFunctionsInstaller::installGlobal();
   	XalanEXSLTDateTimeFunctionsInstaller::installGlobal();
  -
  -
  -#if defined(XALAN_USE_ICU)
  -	// Install the ICU version of format-number...
  -	XPath::installFunction(
  -			XPathFunctionTable::s_formatNumber,
  -			FunctionICUFormatNumber());
  -#endif
   
   	s_xsltInit = initGuard.release();
   	s_emptyInputSource = inputSourceGuard.release();
  
  
  

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