コード例 #1
0
        /// <summary>
        /// Runs the necessary stylesheet transformations.
        /// </summary>
        /// <param name="context">The IRailsEngineContext containing the necessary transformation parameters.</param>
        /// <param name="controller">The controller.</param>
        /// <param name="templateName">Name of the template to run.</param>
        private void RunStylesheets(IRailsEngineContext context, IController controller, String templateName)
        {
            //Collect arguments
            XsltTransformationArguments arguments = CreateArguments(context, controller);
            //Start new pipeline
            XsltPipeline pipeline = new XsltPipeline(arguments);

            //First stage
            pipeline.AddStage(new XsltPipelineStage(TemplateStore.LoadTemplate(templateName, arguments)));

            //Layout stage
            if (controller.LayoutName != null)
            {
                pipeline.AddStage(new XsltPipelineStage(TemplateStore.LoadTemplate(@"layouts\" + controller.LayoutName, arguments)));
            }
            string xhtmlDocType = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";

            if (XHtmlRendering)
            {
                using (StreamWriter writer = new StreamWriter(context.Response.OutputStream))
                {
                    writer.WriteLine(xhtmlDocType);
                }
            }
            //Execute pipeline
            pipeline.Execute(InputDocument, new XmlTextWriter(context.Response.Output));
        }
コード例 #2
0
		/// <summary>
		/// Runs the necessary stylesheet transformations.
		/// </summary>
		/// <param name="context">The IRailsEngineContext containing the necessary transformation parameters.</param>
		/// <param name="controller">The controller.</param>
		/// <param name="templateName">Name of the template to run.</param>
		private void RunStylesheets(IRailsEngineContext context, IController controller, String templateName)
		{
			//Collect arguments
			XsltTransformationArguments arguments = CreateArguments(context, controller);
			//Start new pipeline
			XsltPipeline pipeline = new XsltPipeline(arguments);
			//First stage
			pipeline.AddStage(new XsltPipelineStage(TemplateStore.LoadTemplate(templateName, arguments)));

			//Layout stage
			if (controller.LayoutName != null)
			{
				pipeline.AddStage(new XsltPipelineStage(TemplateStore.LoadTemplate(@"layouts\" + controller.LayoutName, arguments)));
			}
			string xhtmlDocType = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
			if (XHtmlRendering)
			{
				using (StreamWriter writer = new StreamWriter(context.Response.OutputStream))
                {
					writer.WriteLine(xhtmlDocType);
                }
			}
			//Execute pipeline
			pipeline.Execute(InputDocument, new XmlTextWriter(context.Response.Output));
		}