예제 #1
0
        /// <summary>
        /// Executes the pipeline
        /// </summary>
        /// <param name="input">The input to the first transformation.</param>
        /// <param name="output">The writer to write the output of the final transformationstage to.</param>
        public void Execute(XmlTextReader input, XmlTextWriter output)
        {
            XmlReader    currentInput = input;
            MemoryStream inStream = new MemoryStream(), outStream = inStream;
            XmlWriter    currentOutput;

            for (int i = 0; i < _stages.Count; i++)
            {
                XsltPipelineStage stage = _stages[i];
                if (i == _stages.Count - 1)
                {
                    //Final stage
                    currentOutput = output;
                }
                else
                {
                    //Interim stage, make sure the stream is not closed so
                    //we can read from it later on.
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.CloseOutput = false;
                    currentOutput        = XmlWriter.Create(outStream, settings);
                }
                stage.Execute(currentInput, currentOutput, TransformationArguments);


                if (i != _stages.Count - 1)
                {
                    //Make sure everything is in the memory stream
                    if (currentOutput.WriteState != WriteState.Closed)
                    {
                        currentOutput.Flush();
                    }

                    //reset the output stream
                    inStream = new MemoryStream();
                    outStream.WriteTo(inStream);
                    inStream.Position = 0;
                    outStream.Close();

                    //Ouput -> Input
                    currentInput = new XmlTextReader(inStream);
                    outStream    = new MemoryStream();
                }
                else
                {
                    inStream.Close();
                    outStream.Close();
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Adds the stage.
 /// </summary>
 /// <param name="stage">The stage.</param>
 public void AddStage(XsltPipelineStage stage)
 {
     _stages.Add(stage);
 }
예제 #3
0
		/// <summary>
		/// Adds the stage.
		/// </summary>
		/// <param name="stage">The stage.</param>
		public void AddStage(XsltPipelineStage stage)
		{
			_stages.Add(stage);
		}