• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Xsl.XslCompiledTransform类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Xml.Xsl.XslCompiledTransform的典型用法代码示例。如果您正苦于以下问题:C# XslCompiledTransform类的具体用法?C# XslCompiledTransform怎么用?C# XslCompiledTransform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



XslCompiledTransform类属于System.Xml.Xsl命名空间,在下文中一共展示了XslCompiledTransform类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ProcessRecord

        /// <summary>
        /// Processes the record.
        /// </summary>
        protected override void ProcessRecord()
        {
            this.WriteVerbose("Formatting log");
            using (var xmlReader = new StringReader(this.Log))
            {
                var xpath = new XPathDocument(xmlReader);
                using (var writer = new StringWriter())
                {
                    var transform = new XslCompiledTransform();
                    Func<string, string> selector = file => !Path.IsPathRooted(file) ? Path.Combine(Environment.CurrentDirectory, file) : file;
                    foreach (var fileToLoad in this.FormatFile.Select(selector))
                    {
                        this.WriteVerbose("Loading format file " + fileToLoad);
                        using (var stream = File.OpenRead(fileToLoad))
                        {
                            using (var reader = XmlReader.Create(stream))
                            {
                                transform.Load(reader);
                                transform.Transform(xpath, null, writer);
                            }
                        }
                    }

                    this.WriteObject(writer.GetStringBuilder().ToString(), false);
                }
            }
        }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:30,代码来源:FormatLog.cs


示例2: Transform

        public static string Transform (string xml, string xslFile, IDictionary<string, string> xslParams)
        {
            XslCompiledTransform xslTrans = new XslCompiledTransform ();
            xslTrans.Load (xslFile);

            return Transform (xml, xslTrans, xslParams);
        }
开发者ID:aqueduct,项目名称:Aqueduct.SitecoreLib,代码行数:7,代码来源:XmlHelpers.cs


示例3: Main

 public static void Main()
 {
     XslCompiledTransform xsltStyle = new XslCompiledTransform();
     xsltStyle.Load("../../catalogstyle.xslt");
     xsltStyle.Transform("../../catalog.xml", "../../catalog.html");
     Console.WriteLine("catalog.html created");
 }
开发者ID:Vyara,项目名称:Telerik-Academy,代码行数:7,代码来源:XSLTStyleMain.cs


示例4: GenerateReport

        public bool GenerateReport(string fileName)
        {
            bool retCode = false;
            ResetReportViwer();

            XslCompiledTransform xslt = new XslCompiledTransform();
            xslt.Load(rptXslPath);

            if ( File.Exists(fileName) == true)
            {
                XPathDocument myXPathDoc = new XPathDocument(fileName);
                StringWriter sw = new StringWriter();
                XmlWriter xmlWriter = new XmlTextWriter(sw);

                // using makes sure that we flush the writer at the end
                xslt.Transform(myXPathDoc, null, xmlWriter);
                xmlWriter.Flush();
                xmlWriter.Close();

                string xml = sw.ToString();

                HtmlDocument htmlDoc = axBrowser.Document;
                htmlDoc.Write(xml);
                retCode = true;
            }
            else
            {

                retCode = false;
            }

            return retCode;
        }
开发者ID:5dollartools,项目名称:NAM,代码行数:33,代码来源:ReportViewer.cs


示例5: Main

        static int Main(string[] args)
        {
            Console.WriteLine("XMLTo v0.1 [www.mosa-project.org]");
            Console.WriteLine("Copyright 2009 by the MOSA Project. Licensed under the New BSD License.");
            Console.WriteLine("Written by Philipp Garcia ([email protected])");
            Console.WriteLine();
            Console.WriteLine("Usage: XMLTo <xml file> <xsl file> <output file>");
            Console.WriteLine();

            if (args.Length < 3)
             {
                Console.Error.WriteLine("ERROR: Missing arguments");
                return -1;
            }

            try {
                XPathDocument myXPathDoc = new XPathDocument(args[0]);
                XslCompiledTransform myXslTrans = new XslCompiledTransform();
                myXslTrans.Load(args[1]);
                XmlTextWriter myWriter = new XmlTextWriter(args[2], null);
                myXslTrans.Transform(myXPathDoc, null, myWriter);

                return 0;
            }
            catch (Exception e) {
                Console.Error.WriteLine("Exception: {0}", e.ToString());
                return -1;
            }
        }
开发者ID:hj1980,项目名称:Mosa,代码行数:29,代码来源:Program.cs


示例6: MigrateUsingXslt

		protected static void MigrateUsingXslt(TextReader xslStream, TextReader xmlStream, string destinationFilePath)
		{
			var transform = new XslCompiledTransform();
			using (xslStream)
			{
				using (xmlStream)
				{
					using (var destinationStream = new StreamWriter(destinationFilePath))
					{
						var xslReader = XmlReader.Create(xslStream);
						transform.Load(xslReader);
						xslReader.Close();
						xslStream.Close();

						var reader = XmlReader.Create(xmlStream);

						var settings = new XmlWriterSettings { Indent = true };
						var writer = XmlWriter.Create(destinationStream, settings);

						transform.Transform(reader, writer);

						var tempfiles = transform.TemporaryFiles;
						if (tempfiles != null) // tempfiles will be null when debugging is not enabled
						{
							tempfiles.Delete();
						}
						writer.Close();
						reader.Close();
						destinationStream.Close();
					}
					xmlStream.Close();
				}
			}
		}
开发者ID:JohnThomson,项目名称:libpalaso,代码行数:34,代码来源:XslMigrationStrategy.cs


示例7: SparqlXsltWriter

 /// <summary>
 /// Creates a new SPARQL XSLT Writer
 /// </summary>
 /// <param name="stylesheetUri">Stylesheet URI</param>
 public SparqlXsltWriter(String stylesheetUri)
 {
     //Load the Transform
     this._transform = new XslCompiledTransform();
     XsltSettings settings = new XsltSettings();
     this._transform.Load(stylesheetUri, settings, null);
 }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:11,代码来源:SparqlXsltWriter.cs


示例8: TransformXml

        /// <summary>
        /// Perform the xml translation
        /// </summary>
        /// <param name="xmlRaw"></param>
        /// <param name="xslSheet"></param>
        /// <returns></returns>
        public static XmlDocument TransformXml(XmlDocument xmlRawClean, XslCompiledTransform xslSheet)
        {
            XmlDocument xmlTransform = null;
            XmlTextWriter xmlWriter = null;

            try
            {
                XPathDocument xmlClean = ConvertXmlDocumentToXPathDocument(xmlRawClean);

                string sTempPath = FileUtilities.GetUniqueTempFileName();
                xmlWriter = new XmlTextWriter(sTempPath, null);
                xslSheet.Transform(xmlClean, null, xmlWriter);
                xmlWriter.Close();

                xmlTransform = new XmlDocument();
                xmlTransform.Load(sTempPath);

                // try to clean up the file we created
                try
                {
                    File.Delete(sTempPath);
                }
                catch
                {

                }
            }
            catch (Exception ex)
            {
                throw new Exception("TransformXml", ex.InnerException);
            }

            return xmlTransform;
        }
开发者ID:chambleton,项目名称:datafile-to-xml-converter,代码行数:40,代码来源:XmlTranslator.cs


示例9: TransformXml

        public static String TransformXml(XmlTextReader xsltReader, XmlTextReader xmlReader)
        {
            // Create required writer for output
            StringWriter stringWriter = new StringWriter();
            XmlTextWriter transformedXml = new XmlTextWriter(stringWriter);

            // Create a XslCompiledTransform to perform transformation
            XslCompiledTransform xsltTransform = new XslCompiledTransform();

            try
            {
                xsltTransform.Load(xsltReader);
                xsltTransform.Transform(xmlReader, new XsltArgumentList(), transformedXml);
            }
            catch (XmlException xmlEx)
            {
                // TODO : log - "Could not load XSL transform: \n\n" + xmlEx.Message
                throw;
            }
            catch (XsltException xsltEx)
            {
                // TODO : log - "Could not process the XSL: \n\n" + xsltEx.Message + "\nOn line " + xsltEx.LineNumber + " @ " + xsltEx.LinePosition)
                throw;
            }
            catch (Exception ex)
            {
                // TODO : log
                throw;
            }

            return stringWriter.ToString();
        }
开发者ID:camrydash,项目名称:postmark-email-api,代码行数:32,代码来源:XsltUtility.cs


示例10: Main

        static void Main(string[] args)
        {
            if (args.Length != 3)
            {
                Console.WriteLine("You have not entered the correct parameters");
                return;
            }

            string xmlfile = args[0];
            string xslfile = args[1];
            string outfile = args[2];

            try
            {
                var doc = new XPathDocument(xmlfile);
                var transform = new XslCompiledTransform();
                var settings = new XsltSettings(true, true);
                transform.Load(xslfile, settings, new XmlUrlResolver());
                var writer = new XmlTextWriter(outfile, null);
                transform.Transform(doc, null, writer);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
        }
开发者ID:ayezutov,项目名称:NDistribUnit,代码行数:27,代码来源:Program.cs


示例11: ShouldAllowAnXsltToBeRunSuccessfully

        public void ShouldAllowAnXsltToBeRunSuccessfully()
        {
            string xhtmlPage = "http://localhost/webdriver/xhtmlTest.html";
            driver.Get(xhtmlPage);

            XPathNavigator navigator = driver.CreateNavigator();
            XmlDocument xslDoc = new XmlDocument();
            xslDoc.LoadXml(
              @"<?xml version=""1.0""?>
                <xsl:stylesheet version=""1.0"" xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"">
                    <xsl:template match=""/"">
                        <xsl:copy-of select="".""/>
                    </xsl:template>
                </xsl:stylesheet>");

            XslCompiledTransform xsl = new XslCompiledTransform();
            xsl.Load(xslDoc);

            StringBuilder output = new StringBuilder();
            xsl.Transform(navigator, new XsltArgumentList(), new StringWriter(output));

            String result = output.ToString();

            // Do we get text in the body of the transformed document?
            Assert.IsTrue(result.Contains("XHTML Might Be The Future"), "No text from the body of the page");

            // Do we get tag's?
            Assert.IsTrue(result.Contains("<"), "No tags appear to have been opened");
            Assert.IsTrue(result.Contains("</body"), "The body tag has not been closed. Check that tags are being output");

            // Do we get the page's title?
            Assert.IsTrue(result.Contains("XHTML Test Page"), "No title seen");
        }
开发者ID:santiycr,项目名称:selenium,代码行数:33,代码来源:XPathTest.cs


示例12: BeforeSendRequest

        public object BeforeSendRequest(ref Message request, IClientChannel channel)
        {
            if (!request.IsEmpty)
            {
                XmlReader bodyReader = request.GetReaderAtBodyContents().ReadSubtree();

                MemoryStream stream = new MemoryStream();
                XmlWriter writer = XmlWriter.Create(stream);

                if (transform == null)
                {
                    transform = new XslCompiledTransform(true);
                    var reader = XmlReader.Create(new StringReader(Properties.Resources.XmlCleaner));
                    transform.Load(reader);
                }
                transform.Transform(bodyReader, writer);

                stream.Flush();
                stream.Seek(0, SeekOrigin.Begin);

                bodyReader = XmlReader.Create(stream);

                Message changedMessage = Message.CreateMessage(request.Version, null, bodyReader);
                changedMessage.Headers.CopyHeadersFrom(request.Headers);
                changedMessage.Properties.CopyProperties(request.Properties);
                request = changedMessage;
            }

            return null;
        }
开发者ID:spardo,项目名称:dotnet37signals,代码行数:30,代码来源:RestClientMessageInspector.cs


示例13: Main

 static void Main()
 {
     XslCompiledTransform xslt = new XslCompiledTransform();
     xslt.Load("../../style.xslt");
     xslt.Transform("../../../CatalogHolder/catalogue.xml", "../../catalogue.html");
     Console.WriteLine("result saved as catalogue.html");
 }
开发者ID:LafForce,项目名称:TelerikAcademyHWs,代码行数:7,代码来源:ProgrXMLtoHTMLam.cs


示例14: ToHtml

        private string ToHtml()
        {
            if (Services.StrandsCache.Contains(this))
            {
                return Services.StrandsCache.Read(this);
            }
            else
            {
                var transform = new XslCompiledTransform(true);
                var arguments = new XsltArgumentList();
                var settings = new XsltSettings();
                var readersettings = new XmlReaderSettings();
                //string xslsrc = (!string.IsNullOrEmpty(this.DisplayType)) ? "/XMLList.xsl" : "/Strands.xsl";
                //var xslfile = (this.Name == "themes") ? HttpContext.Current.Server.MapPath(this._xslAppUrl + "/StrandList.xsl") : HttpContext.Current.Server.MapPath(this._xslAppUrl + xslsrc);
                var xslfile = HttpContext.Current.Server.MapPath(this._xslAppUrl + ((!string.IsNullOrEmpty(this.DisplayType)) ? "XMLList.xsl" : this.XslName));

                settings.EnableDocumentFunction = true;
                settings.EnableScript = true;
                readersettings.DtdProcessing = DtdProcessing.Parse;
                readersettings.ValidationType = ValidationType.None;
                transform.Load(xslfile, settings, new XmlUrlResolver());
                arguments = TransformArguments(this);
                using (XmlReader reader = XmlReader.Create(this.GetDirectoryPath(), readersettings))
                {
                    System.IO.StringWriter writer = new System.IO.StringWriter();

                    transform.Transform(reader, arguments, writer);
                    return Services.StrandsCache.Write(this, writer.ToString());
                }
            }
        }
开发者ID:jbunzel,项目名称:MvcStrands_git,代码行数:31,代码来源:StrandsRepository.cs


示例15: TransformClaimDocumentToFoXml

        public string TransformClaimDocumentToFoXml(ClaimDocument document)
        {
            FormDocument form = new FormDocument();

            foreach (var claim in document.Claims)
            {
                if (claim.Type == ClaimTypeEnum.Professional)
                {
                    var pages = _professionalTransformation.TransformClaimToClaimFormFoXml(claim);
                    form.Pages.AddRange(pages);
                }
                else if (claim.Type == ClaimTypeEnum.Institutional)
                {
                    var pages = _institutionalTransformation.TransformClaimToClaimFormFoXml(claim);
                    form.Pages.AddRange(pages);
                }
                else
                    form.Pages.AddRange(_dentalTransformation.TransformClaimToClaimFormFoXml(claim));
            }

            var xml = form.Serialize();

            var transformStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OopFactory.X12.Hipaa.Claims.Services.Xsl.FormDocument-To-FoXml.xslt");

            var transform = new XslCompiledTransform();
            if (transformStream != null) transform.Load(XmlReader.Create(transformStream));

            var outputStream = new MemoryStream();

            transform.Transform(XmlReader.Create(new StringReader(xml)), new XsltArgumentList(), outputStream);
            outputStream.Position = 0;
            return new StreamReader(outputStream).ReadToEnd();
        }
开发者ID:hitgeek,项目名称:OopFactoryX12Parser,代码行数:33,代码来源:ClaimFormTransformationService.cs


示例16: Main

 public static void Main()
 {
     XslCompiledTransform xslt = new XslCompiledTransform();
     xslt.Load(XsltPath);
     xslt.Transform(CataloguePath, HtmlPath);
     Console.WriteLine("Successfully transformed in catalogue.html");
 }
开发者ID:AYankova,项目名称:Databases,代码行数:7,代码来源:Program.cs


示例17: Transform

        public void Transform(string inputFilePath, string outputFilePath, KeyValueConfigurationCollection settings)
        {
            var xsltTemplateReader = new XmlTextReader(inputFilePath);
            var emptyDocumentReader = XmlReader.Create(new System.IO.StringReader("<empty />"));

            var writerSettings = new XmlWriterSettings();
            //settings.ConformanceLevel = ConformanceLevel.Fragment;
            writerSettings.Indent = true;

            using (var outputWriter = XmlWriter.Create(outputFilePath, writerSettings))
            {
                var xsltSettings = new XsltSettings();

                XsltArgumentList argumentList = new XsltArgumentList();

                var extensions = new XsltExtensionMethods(settings);

                argumentList.AddExtensionObject("http://core.com/config", extensions);
                argumentList.AddExtensionObject("http://setty.net/config", extensions);

                var transformer = new XslCompiledTransform(true);
                transformer.Load(xsltTemplateReader, xsltSettings, null);
                transformer.Transform(emptyDocumentReader, argumentList, outputWriter);
            }
        }
开发者ID:paralect,项目名称:setty,代码行数:25,代码来源:XsltTransformer.cs


示例18: Main

		static int Main (string [] args)
		{
			if (args.Length != 2) {
				Console.WriteLine ("Usage: mono gen-apidiff-html.exe <diff_dir> <html_file>");
				return 1;
			}

			string diff_dir = args[0];
			string out_file = args[1];

			var all = new XmlDocument ();
			all.AppendChild(all.CreateElement ("assemblies"));
			foreach (string file in Directory.EnumerateFiles(diff_dir, "*.apidiff")) {
				Console.WriteLine ("Merging " + file);
				var doc = new XmlDocument ();
				doc.Load (file);
				foreach (XmlNode child in doc.GetElementsByTagName ("assembly")) {
					XmlNode imported = all.ImportNode (child, true);
					all.DocumentElement.AppendChild (imported);
				}
			}

			var transform = new XslCompiledTransform ();
			transform.Load ("mono-api.xsl");
			var writer = new StreamWriter (out_file);

			Console.WriteLine (String.Format ("Transforming to {0}...", out_file));
			transform.Transform (all.CreateNavigator (), null, writer);
			writer.Close ();

			return 0;
		}
开发者ID:akrisiun,项目名称:gtk-sharp,代码行数:32,代码来源:gen-apidiff-html.cs


示例19: Transform

        public void Transform()
        {
            var xsltTemplateReader = new XmlTextReader(_xsltPath);
            var emptyDocumentReader = XmlReader.Create(new System.IO.StringReader("<empty />"));

            var settings = new XmlWriterSettings();
            //settings.ConformanceLevel = ConformanceLevel.Fragment;
            settings.Indent = true;

            using (var outputWriter = XmlWriter.Create(_outputPath, settings))
            {
                var xsltSettings = new XsltSettings();

                XsltArgumentList argumentList = new XsltArgumentList();

                var extensions = new XsltExtensionMethods(_settings);

                argumentList.AddExtensionObject("http://core.com/config", extensions);
                argumentList.AddExtensionObject("http://paralect.com/config", extensions);

                var transformer = new XslCompiledTransform(true);
                transformer.Load(xsltTemplateReader, xsltSettings, null);
                transformer.Transform(emptyDocumentReader,argumentList, outputWriter);
            }
        }
开发者ID:paralect,项目名称:Paralect.Config,代码行数:25,代码来源:XsltTransformer.cs


示例20: GetSearchResultsHtml

		public string GetSearchResultsHtml(string term, int skip, int take)
		{
			var response = new StringBuilder();

			var xmlResults = this.SearchData.GetSearchResultsXML(term, skip, take);

			if (xmlResults != null)
			{
				using (var xmlReader = XmlReader.Create(new StringReader(xmlResults.OuterXml)))
				{
					using (var xslReader = XmlReader.Create(HttpContext.Current.Server.MapPath(XSLTTransformFile)))
					{
						using (var xmlWriter = XmlWriter.Create(response, new XmlWriterSettings
						{
							OmitXmlDeclaration = true
						}))
						{
							var xslTransformer = new XslCompiledTransform();

							xslTransformer.Load(xslReader, new XsltSettings(true, true), new XmlUrlResolver
							{
								Credentials = CredentialCache.DefaultCredentials
							});

							xslTransformer.Transform(xmlReader, xmlWriter);
						}
					}
				}
			}

			return response.ToString();
		}
开发者ID:Eugene-Murray,项目名称:Contract_Validus,代码行数:32,代码来源:SearchBusinessModule.cs



注:本文中的System.Xml.Xsl.XslCompiledTransform类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Xsl.XslTransform类代码示例发布时间:2022-05-26
下一篇:
C# Xsl.Compiler类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap