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/05/10 20:45:28 UTC

cvs commit: xml-xalan/c/src/XSLT StylesheetExecutionContext.hpp StylesheetExecutionContextDefault.cpp StylesheetExecutionContextDefault.hpp

dbertoni    01/05/10 11:45:28

  Modified:    c/src/XSLT StylesheetExecutionContext.hpp
                        StylesheetExecutionContextDefault.cpp
                        StylesheetExecutionContextDefault.hpp
  Log:
  Removed option to use Xerces DOM for RTFs.  Added new NodeSorter caching.  Return XUnknown when a variable is not found.
  
  Revision  Changes    Path
  1.53      +92 -5     xml-xalan/c/src/XSLT/StylesheetExecutionContext.hpp
  
  Index: StylesheetExecutionContext.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContext.hpp,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- StylesheetExecutionContext.hpp	2001/05/02 15:55:51	1.52
  +++ StylesheetExecutionContext.hpp	2001/05/10 18:45:21	1.53
  @@ -110,14 +110,11 @@
   
   
   
  +#include <XSLT/KeyTable.hpp>
   #include <XSLT/TopLevelArg.hpp>
   
   
   
  -#include "KeyTable.hpp"
  -
  -
  -
   class CountersTable;
   class ElemTemplateElement;
   class ElemVariable;
  @@ -130,6 +127,7 @@
   class KeyTable;
   class PrefixResolver;
   class NodeRefListBase;
  +class NodeSorter;
   class PrintWriter;
   class QName;
   class SelectionEvent;
  @@ -632,6 +630,30 @@
   	virtual void
   	popContextMarker() = 0;
   
  +	/*
  +	 * A class to manage pushing and popping an element's stack
  +	 * frame context.
  +	 */
  +	class PushAndPopContextMarker
  +	{
  +	public:
  +
  +		PushAndPopContextMarker(StylesheetExecutionContext&		executionContext) :
  +			m_executionContext(executionContext)
  +		{
  +			executionContext.pushContextMarker();
  +		}
  +
  +		~PushAndPopContextMarker()
  +		{
  +			m_executionContext.popContextMarker();
  +		}
  +
  +	private:
  +
  +		StylesheetExecutionContext&		m_executionContext;
  +	};
  +
   	/**
   	 * Resolve the params that were pushed by the caller.
   	 */
  @@ -1174,7 +1196,7 @@
   	 * Return a previously borrowed FormatterToText instance.
   	 *
   	 * @param theFormatter A pointer the to previously borrowed instance.
  -	 * @return true if the formatter was borrowed (at therefore, destroyed), false if not.
  +	 * @return true if the instance was previously borrowed, false if not.
   	 */
   	virtual bool
   	returnFormatterToText(FormatterToText*	theFormatter) = 0;
  @@ -1223,6 +1245,71 @@
   		StylesheetExecutionContext&		m_executionContext;
   
   		FormatterToText*				m_formatter;
  +	};
  +
  +
  +	/**
  +	 * Borrow a cached NodeSorter instance.
  +	 *
  +	 * @return A pointer to the instance.
  +	 */
  +	virtual NodeSorter*
  +	borrowNodeSorter() = 0;
  +
  +	/**
  +	 * Return a previously borrowed NodeSorter instance.
  +	 *
  +	 * @param theSorter A pointer the to previously borrowed instance.
  +	 * @return true if the instance was previously borrowed, false if not.
  +	 */
  +	virtual bool
  +	returnNodeSorter(NodeSorter*	theSorter) = 0;
  +
  +	class BorrowReturnNodeSorter
  +	{
  +	public:
  +
  +		BorrowReturnNodeSorter(StylesheetExecutionContext&	executionContext) :
  +			m_executionContext(executionContext),
  +			m_sorter(executionContext.borrowNodeSorter())
  +		{
  +			assert(m_sorter != 0);
  +		}
  +
  +		~BorrowReturnNodeSorter()
  +		{
  +			assert(m_sorter != 0);
  +
  +			m_executionContext.returnNodeSorter(m_sorter);
  +		}
  +
  +		NodeSorter&
  +		operator*() const
  +		{
  +			assert(m_sorter != 0);
  +
  +			return *m_sorter;
  +		}
  +
  +		NodeSorter*
  +		get() const
  +		{
  +			assert(m_sorter != 0);
  +
  +			return m_sorter;
  +		}
  +
  +		NodeSorter*
  +		operator->() const
  +		{
  +			return get();
  +		}
  +
  +	private:
  +
  +		StylesheetExecutionContext&		m_executionContext;
  +
  +		NodeSorter*						m_sorter;
   	};
   
   
  
  
  
  1.64      +30 -24    xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp
  
  Index: StylesheetExecutionContextDefault.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- StylesheetExecutionContextDefault.cpp	2001/05/02 15:55:53	1.63
  +++ StylesheetExecutionContextDefault.cpp	2001/05/10 18:45:22	1.64
  @@ -151,7 +151,8 @@
   	m_sourceTreeResultTreeFactory(),
   	m_mode(0),
   	m_formatterToTextCache(),
  -	m_formatterToSourceTreeCache()
  +	m_formatterToSourceTreeCache(),
  +	m_nodeSorterCache()
   {
   }
   
  @@ -183,7 +184,8 @@
   	m_sourceTreeResultTreeFactory(),
   	m_mode(0),
   	m_formatterToTextCache(),
  -	m_formatterToSourceTreeCache()
  +	m_formatterToSourceTreeCache(),
  +	m_nodeSorterCache()
   {
   }
   
  @@ -922,8 +924,7 @@
   
   	BorrowReturnResultTreeFrag	theResultTreeFrag(*this);
   
  -#if 1
  -	GetReleaseCachedObject<FormatterToSourceTree>	theGuard(m_formatterToSourceTreeCache);
  +	GetReleaseCachedObject<FormatterToSourceTreeCacheType>	theGuard(m_formatterToSourceTreeCache);
   
   	FormatterToSourceTree* const	theFormatter = theGuard.get();
   	assert(theFormatter != 0);
  @@ -942,24 +943,7 @@
   				theFormatter);
   
   	templateChild.executeChildren(*this, sourceNode);
  -#else
  -	XalanSourceTreeDocument* const	theDocument = getSourceTreeFactory();
  -
  -	FormatterToSourceTree	tempFormatter(
  -					theDocument,
  -					theResultTreeFrag.get());
  -
  -	tempFormatter.setPrefixResolver(m_xsltProcessor);
  -
  -	theResultTreeFrag->setOwnerDocument(theDocument);
  -
  -	StylesheetExecutionContext::OutputContextPushPop	theOutputContextPushPop(
  -				*this,
  -				&tempFormatter);
   
  -	templateChild.executeChildren(*this, sourceNode);
  -#endif
  -
   	return getXObjectFactory().createResultTreeFrag(theResultTreeFrag);
   }
   
  @@ -1221,6 +1205,22 @@
   
   
   
  +NodeSorter*
  +StylesheetExecutionContextDefault::borrowNodeSorter()
  +{
  +	return m_nodeSorterCache.get();
  +}
  +
  +
  +
  +bool
  +StylesheetExecutionContextDefault::returnNodeSorter(NodeSorter*		theSorter)
  +{
  +	return m_nodeSorterCache.release(theSorter);
  +}
  +
  +
  +
   StylesheetExecutionContextDefault::XalanNumberFormatAutoPtr
   StylesheetExecutionContextDefault::createXalanNumberFormat()
   {
  @@ -1665,14 +1665,20 @@
   
   	const XObjectPtr	theValue(m_variablesStack.getVariable(name, *this, fFound));
   
  -	if(fFound == false)
  +	if(fFound == true)
   	{
  +		assert(theValue.null() == false);
  +
  +		return theValue;
  +	}
  +	else
  +	{
   		warn(
   			TranscodeFromLocalCodePage("Variable reference given for variable out of context or without definition!  Name = ") +
   			name.getLocalPart());
  -	}
   
  -	return theValue;
  +		return getXObjectFactory().createUnknown(name.getLocalPart());
  +	}
   }
   
   
  
  
  
  1.58      +20 -7     xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp
  
  Index: StylesheetExecutionContextDefault.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- StylesheetExecutionContextDefault.hpp	2001/05/02 15:55:56	1.57
  +++ StylesheetExecutionContextDefault.hpp	2001/05/10 18:45:23	1.58
  @@ -94,6 +94,7 @@
   
   
   #include <XSLT/CountersTable.hpp>
  +#include <XSLT/NodeSorter.hpp>
   #include <XSLT/Stylesheet.hpp>
   #include <XSLT/VariablesStack.hpp>
   
  @@ -552,6 +553,12 @@
   	virtual bool
   	returnFormatterToText(FormatterToText*	theFormatter);
   
  +	virtual NodeSorter*
  +	borrowNodeSorter();
  +
  +	virtual bool
  +	returnNodeSorter(NodeSorter*	theSorter);
  +
   	virtual XalanNumberFormatAutoPtr
   	createXalanNumberFormat();
   
  @@ -1016,18 +1023,24 @@
   	// non-conforming behavior.
   	bool								m_ignoreHTMLElementNamespaces;
   
  -	// Holds the current mode.
  -	const QName*	                    m_mode;
  -
  -	XalanObjectCacheDefault<FormatterToText>		m_formatterToTextCache;
  -
  -	XalanObjectCacheDefault<FormatterToSourceTree>	m_formatterToSourceTreeCache;
  -
   	/**
   	 * The factory that will be used to create result tree fragments based on our
   	 * proprietary source tree.
   	 */
   	mutable XalanAutoPtr<XalanSourceTreeDocument>	m_sourceTreeResultTreeFactory;
  +
  +	// Holds the current mode.
  +	const QName*	                    m_mode;
  +
  +	typedef XalanObjectCacheDefault<FormatterToText>		FormatterToTextCacheType;
  +	typedef XalanObjectCacheDefault<FormatterToSourceTree>	FormatterToSourceTreeCacheType;
  +	typedef XalanObjectCacheDefault<NodeSorter>				NodeSorterCacheType;
  +
  +	FormatterToTextCacheType			m_formatterToTextCache;
  +
  +	FormatterToSourceTreeCacheType		m_formatterToSourceTreeCache;
  +
  +	NodeSorterCacheType					m_nodeSorterCache;
   
   	static XalanNumberFormatFactory		s_defaultXalanNumberFormatFactory;
   
  
  
  

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