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...@locus.apache.org on 2000/08/01 21:44:35 UTC

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

dbertoni    00/08/01 12:44:35

  Modified:    c/src/XSLT StylesheetRoot.cpp StylesheetRoot.hpp
  Log:
  Moved code that sets up the FormatterListener to a separate function, and inlined some functions.
  
  Revision  Changes    Path
  1.20      +51 -105   xml-xalan/c/src/XSLT/StylesheetRoot.cpp
  
  Index: StylesheetRoot.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetRoot.cpp,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- StylesheetRoot.cpp	2000/07/21 19:52:57	1.19
  +++ StylesheetRoot.cpp	2000/08/01 19:44:34	1.20
  @@ -204,14 +204,59 @@
   
   	executionContext.setStylesheetRoot(this);
   
  -	FormatterListener* flistener = 0;
  +	setupFormatterListener(outputTarget, executionContext);
   
  -#if !defined(XALAN_NO_NAMESPACES)
  -	using std::auto_ptr;
  -#endif
  +	executionContext.resetCurrentState(sourceTree, sourceTree);
   
  -	Writer* pw = 0;
  +	executionContext.setRootDocument(sourceTree);
  +		
  +	if(executionContext.doDiagnosticsOutput())
  +	{
  +		executionContext.diag(XALAN_STATIC_UCODE_STRING("============================="));
  +		executionContext.diag(XALAN_STATIC_UCODE_STRING("Transforming..."));
  +		executionContext.pushTime(&sourceTree);
  +	}
  +
  +	try
  +	{
  +		executionContext.resolveTopLevelParams();
  +	}
  +	// java: catch(Exception e)
  +	catch(...)
  +	{
  +		throw SAXException("StylesheetRoot.process error");
  +	}
  +
  +	executionContext.startDocument();
  +
  +	// Output the action of the found root rule.	All processing
  +	// occurs from here.	buildResultFromTemplate is highly recursive.
  +	rootRule->execute(executionContext, sourceTree, sourceTree, QName());
  +
  +	executionContext.endDocument();
   
  +	// Reset the top-level params for the next round.
  +	executionContext.clearTopLevelParams();
  +
  +	if(executionContext.doDiagnosticsOutput())
  +	{
  +		executionContext.diag(XALAN_STATIC_UCODE_STRING(""));
  +		executionContext.displayDuration(XALAN_STATIC_UCODE_STRING("transform"), &sourceTree);
  +		executionContext.diag(XALAN_STATIC_UCODE_STRING(""));
  +	}
  +}
  +
  +
  +
  +FormatterListener*
  +StylesheetRoot::setupFormatterListener(
  +			XSLTResultTarget&				outputTarget,
  +			StylesheetExecutionContext&		executionContext) const
  +{
  +	FormatterListener*	flistener = 0;
  +
  +	Writer*				pw = 0;
  +
   	flistener = outputTarget.getFormatterListener();
   
   	if(flistener == 0)
  @@ -358,86 +403,12 @@
   	}
   
   	executionContext.setFormatterListener(flistener);
  -	executionContext.resetCurrentState(sourceTree, sourceTree);
  -
  -	executionContext.setRootDocument(sourceTree);
  -		
  -	if(executionContext.doDiagnosticsOutput())
  -	{
  -		executionContext.diag(XALAN_STATIC_UCODE_STRING("============================="));
  -		executionContext.diag(XALAN_STATIC_UCODE_STRING("Transforming..."));
  -		executionContext.pushTime(&sourceTree);
  -	}
   
  -	try
  -	{
  -		executionContext.resolveTopLevelParams();
  -	}
  -	// java: catch(Exception e)
  -	catch(...)
  -	{
  -		throw SAXException("StylesheetRoot.process error");
  -	}
  -
  -	executionContext.startDocument();
  -
  -	// Output the action of the found root rule.	All processing
  -	// occurs from here.	buildResultFromTemplate is highly recursive.
  -	rootRule->execute(executionContext, sourceTree, sourceTree, QName());
  -
  -	executionContext.endDocument();
  -
  -	// Reset the top-level params for the next round.
  -	executionContext.clearTopLevelParams();
  -
  -	if(executionContext.doDiagnosticsOutput())
  -	{
  -		executionContext.diag(XALAN_STATIC_UCODE_STRING(""));
  -		executionContext.displayDuration(XALAN_STATIC_UCODE_STRING("transform"), &sourceTree);
  -		executionContext.diag(XALAN_STATIC_UCODE_STRING(""));
  -	}
  -}
  -
  -
  -
  -/** 
  - * Return the output method that was specified in the stylesheet. 
  - * The returned value is one of Formatter.OUTPUT_METH_XML,
  - * Formatter.OUTPUT_METH_HTML, or Formatter.OUTPUT_METH_TEXT.
  - */
  -FormatterListener::eFormat
  -StylesheetRoot::getOutputMethod() const
  -{ 
  -	return m_outputMethod; 
  -}
  -
  -
  -
  -/** Get the version string that was specified in the stylesheet. */
  -XalanDOMString 
  -StylesheetRoot::getOutputVersion() const
  -{ 
  -	return m_version; 
  +	return flistener;
   }
   
   
  -/** Get the media-type string that was specified in the stylesheet. */
  -bool 
  -StylesheetRoot::getOutputIndent() const
  -{ 
  -	return m_indentResult;
  -}
  -
  -
  -/** Get the encoding string that was specified in the stylesheet. */
  -XalanDOMString 
  -StylesheetRoot::getOutputEncoding() const
  -{ 
  -    return m_encoding; 
  -}
  -
   
  -/** Get the encoding string that was specified in the stylesheet. */
   XalanDOMString 
   StylesheetRoot::getJavaOutputEncoding() const 
   { 
  @@ -459,32 +430,7 @@
   }
   
   
  -/** Get the media-type string that was specified in the stylesheet. */
  -XalanDOMString 
  -StylesheetRoot::getOutputMediaType() const 
  -{ 
  -	return m_mediatype; 
  -}
  -
  -
  -/** Get the doctype-system-id string that was specified in the stylesheet. */
  -XalanDOMString 
  -StylesheetRoot::getOutputDoctypeSystem() const 
  -{ 
  -	return m_doctypeSystem; 
  -}
  -
  -
  -/** Get the doctype-public-id string that was specified in the stylesheet. */
  -XalanDOMString 
  -StylesheetRoot::getOutputDoctypePublic() const
  -{ 
  -	return m_doctypePublic; 
  -}
   
  -/**
  - * Process the xsl:output element.
  - */
   void 
   StylesheetRoot::processOutputSpec(
   			const XalanDOMChar*				name, 
  
  
  
  1.11      +51 -13    xml-xalan/c/src/XSLT/StylesheetRoot.hpp
  
  Index: StylesheetRoot.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetRoot.hpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- StylesheetRoot.hpp	2000/05/24 19:38:49	1.10
  +++ StylesheetRoot.hpp	2000/08/01 19:44:34	1.11
  @@ -113,10 +113,27 @@
   	 */
   	void
   	process(
  -			XalanNode*						sourceTree, 
  +			XalanNode*						sourceTree,
   			XSLTResultTarget&				outputTarget,
   			StylesheetExecutionContext&		executionContext) const;
   
  +	/**
  +	 * Have the stylesheet create the appropriate FormatterListener,
  +	 * based on the XSLTResultTarget provided.  setupFormatterListener
  +	 * also calls setFormatterListener() on the execution context
  +	 * instance.  setupFormatterListener() is done automatically by
  +	 * process(), but this is provided as an escape, to allow for
  +	 * changing the FormatterListener on-the-fly.
  +	 *
  +	 * @param outputTarget The output source tree
  +	 * @param constructionContext context for construction of object
  +	 * @return a pointer to the new FormatterListener instance.
  +	 */
  +	FormatterListener*
  +	setupFormatterListener(
  +			XSLTResultTarget&				outputTarget,
  +			StylesheetExecutionContext&		executionContext) const;
  +
   	/** 
   	 * Return the output method that was specified in the stylesheet. 
   	 * The returned value is one of FormatterLister::eFormat values.
  @@ -124,7 +141,10 @@
   	 * @return value of output method
   	 */
   	FormatterListener::eFormat
  -	getOutputMethod() const;
  +	getOutputMethod() const
  +	{
  +		return m_outputMethod;
  +	}
   
   	bool
   	isOutputMethodSet() const
  @@ -139,7 +159,10 @@
   	 * @return output version string
   	 */
   	XalanDOMString
  -	getOutputVersion() const;
  +	getOutputVersion() const
  +	{ 
  +		return m_version;
  +	}
   
   	/**
   	 * Determine if output indenting was specified in the
  @@ -148,7 +171,10 @@
   	 * @return true to indent
   	 */
   	bool 
  -	getOutputIndent() const;
  +	getOutputIndent() const
  +	{
  +		return m_indentResult;
  +	}
   
   	/**
   	 * Get the output encoding string that was specified in the
  @@ -157,7 +183,10 @@
   	 * @return encoding string
   	 */
   	XalanDOMString 
  -	getOutputEncoding() const;
  +	getOutputEncoding() const
  +	{
  +		return m_encoding;
  +	}
   
   	/**
   	 * Get the java output encoding string that was specified in the
  @@ -169,23 +198,29 @@
   	getJavaOutputEncoding() const;
   
   	/**
  -	 * Get the doctype-system-id string that was specified in the 
  +	 * Get the media-type string that was specified in the 
   	 * xsl:output element
   	 *
  -	 * @return document type string
  +	 * @return media type string
   	 */
   	XalanDOMString 
  -	getOutputDoctypeSystem() const;
  +	getOutputMediaType() const
  +	{
  +		return m_mediatype;
  +	}
   
   	/**
  -	 * Get the media-type string that was specified in the 
  +	 * Get the doctype-system-id string that was specified in the 
   	 * xsl:output element
   	 *
  -	 * @return media type string
  +	 * @return document type string
   	 */
   	XalanDOMString 
  -	getOutputMediaType() const;
  -	
  +	getOutputDoctypeSystem() const
  +	{
  +		return m_doctypeSystem;
  +	}
  +
   	/**
   	 * Get the doctype-public-id string that was specified in the 
   	 * xsl:output element
  @@ -193,7 +228,10 @@
   	 * @return document type public id string
   	 */
   	XalanDOMString 
  -	getOutputDoctypePublic() const;
  +	getOutputDoctypePublic() const
  +	{
  +		return m_doctypePublic;
  +	}
   
   	/**
   	 * Determine whether to output XML declarations.