示例#1
0
 /// <summary> Transforms the XML data in the XPathNavigator using the specified args and outputs the result to an MultiXmlTextWriter</summary>
 public void Transform(XPathNavigator navigator, XsltArgumentList arglist, MultiXmlTextWriter writer)
 { 
     this.xslTransform.Transform(navigator, this.AddExsltExtensionObjects(arglist), writer); 
 }
示例#2
0
        /// <summary>
        /// Transforms given <see cref="XmlInput"/> into <see cref="XmlOutput"/>.
        /// The <see cref="XsltArgumentList"/> provides additional runtime arguments.
        /// </summary>
        /// <param name="input">Default input XML document.</param>
        /// <param name="arguments">An <see cref="XsltArgumentList"/> containing the namespace-qualified 
        /// arguments used as input to the transform. This value can be a null reference (Nothing in Visual Basic).</param>
        /// <param name="output">Represents the transformation's output.</param>
        /// <returns>Transformation output.</returns>
        public XmlOutput Transform(XmlInput input, XsltArgumentList arguments, XmlOutput output)
        {
            if (input == null) throw new ArgumentNullException("defaltDocument");
            XmlWriter xmlWriter = output.destination as XmlWriter;
            bool closeWriter = false;
            if (xmlWriter == null)
            {
                closeWriter = true;
                while (true)
                {
                    TextWriter txtWriter = output.destination as TextWriter;
                    if (txtWriter != null)
                    {
                        if (multiOutput)
                        {
                            MultiXmlTextWriter mw = new MultiXmlTextWriter(txtWriter, output.XmlResolver);

                            if (this.compiledTransform.OutputSettings.Indent)
                            {
                                mw.Formatting = Formatting.Indented;
                            }
                            xmlWriter = mw;
                        }
                        else
                        {
                            xmlWriter = XmlWriter.Create(txtWriter, this.compiledTransform.OutputSettings);
                        }
                        break;
                    }
                    Stream strm = output.destination as Stream;
                    if (strm != null)
                    {
                        if (multiOutput)
                        {

                            MultiXmlTextWriter mw = new MultiXmlTextWriter(strm, this.compiledTransform.OutputSettings.Encoding, output.XmlResolver);
                            if (this.compiledTransform.OutputSettings.Indent)
                            {
                                mw.Formatting = Formatting.Indented;
                            }
                            xmlWriter = mw;
                        }
                        else
                        {
                            xmlWriter = XmlWriter.Create(strm, this.compiledTransform.OutputSettings);
                        }
                        break;
                    }
                    String str = output.destination as String;
                    if (str != null)
                    {
                        if (multiOutput)
                        {
                            MultiXmlTextWriter mw = new MultiXmlTextWriter(str, this.compiledTransform.OutputSettings.Encoding);
                            if (this.compiledTransform.OutputSettings.Indent)
                            {
                                mw.Formatting = Formatting.Indented;
                            }
                            xmlWriter = mw;
                        }
                        else
                        {
                            XmlWriterSettings outputSettings = this.compiledTransform.OutputSettings.Clone();
                            outputSettings.CloseOutput = true;
                            // BugBug: We should read doc before creating output file in case they are the same
                            xmlWriter = XmlWriter.Create(str, outputSettings);
                        }
                        break;
                    }
                    throw new Exception("Unexpected XmlOutput");
                }
            }
            try
            {
                TransformToWriter(input, arguments, xmlWriter);
            }
            finally
            {
                if (closeWriter)
                {
                    xmlWriter.Close();
                }
            }
            return output;
        }
示例#3
0
 /// <summary> Transforms the XML data in the XPathNavigator using the specified args and outputs the result to an MultiXmlTextWriter</summary>
 public void Transform(XPathNavigator navigator, XsltArgumentList arglist, MultiXmlTextWriter writer)
 {
     this.xslTransform.Transform(navigator, this.AddExsltExtensionObjects(arglist), writer);
 }