当前位置: 首页>>代码示例>>C#>>正文


C# XslCompiledTransform.Load方法代码示例

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


在下文中一共展示了XslCompiledTransform.Load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildNavigator

        public void BuildNavigator(string modelFilePath)
        {
            XmlResolver resolver = new XmlUrlResolver();
            resolver.Credentials = CredentialCache.DefaultCredentials;
            XmlTextReader tr = new XmlTextReader(modelFilePath);
            XslCompiledTransform transform = new XslCompiledTransform();
            transform.Load(this.stylesheetFilesPath + Path.DirectorySeparatorChar + "ModelTree.xsl",null,resolver);
            XmlTextWriter tw = new XmlTextWriter(this.htmlFilesPath + Path.DirectorySeparatorChar + "ModelTree.htm", Encoding.UTF8);
            XsltArgumentList al = new XsltArgumentList();
            al.AddParam("modelBrowser","",this.localizer.GetValue("Globals","ModelBrowser"));
            al.AddParam("glossary","",this.localizer.GetValue("Globals","Glossary"));
            al.AddParam("stakeholders", "", this.localizer.GetValue("Globals", "Stakeholders"));
            transform.Transform(tr,al,tw,null);
            tw.Close();
            tr.Close();

            tr = new XmlTextReader(modelFilePath);
            transform.Load(this.stylesheetFilesPath + Path.DirectorySeparatorChar + "HomePage.xsl",null,resolver);
            tw = new XmlTextWriter(this.htmlFilesPath + Path.DirectorySeparatorChar + "main.htm",Encoding.UTF8);
            al = new XsltArgumentList();
            AssemblyName an = this.GetType().Assembly.GetName();
            al.AddParam("version","",an.Version.ToString(3));
            al.AddParam("model", "", this.localizer.GetValue("Globals", "Model"));
            al.AddParam("author", "", this.localizer.GetValue("Globals", "Author"));
            al.AddParam("company", "", this.localizer.GetValue("Globals", "Company"));
            al.AddParam("creationDate", "", this.localizer.GetValue("Globals", "CreationDate"));
            al.AddParam("exportPrintDate", "", this.localizer.GetValue("Globals", "ExportPrintDate"));
            al.AddParam("now", "", Convert.ToString(DateTime.Now, DateTimeFormatInfo.InvariantInfo));
            al.AddParam("release", "", this.localizer.GetValue("Globals", "Release"));
            transform.Transform(tr,al,tw,null);
            tw.Close();
            tr.Close();
        }
开发者ID:stephen-czetty,项目名称:UseCaseMaker,代码行数:33,代码来源:HTMLConverter.cs

示例2: Load

		/// <summary>
		/// Converts source XML with given transform with applying DSL
		/// </summary>
		/// <param name="xml"> </param>
		/// <returns>XElement with data, converted by transform</returns>
		/// <exception cref="XmlDslLoaderException">
		/// <list type="bullet">
		/// <item><description>cannot find transform file</description></item>
		/// <item><description>any problem with underlined XmlDslDefinition</description></item>
		/// </list>
		/// </exception>
		public XElement Load(XElement xml) {
			if (null == xml.Element("transform")) return xml; //no dsl needed
			var trdef = new XmlDslDefinition().Extract(xml);
			var langfile = Resolver.Resolve(Rootdir+"/" + trdef.LangName + ".xslt", false);
			if (!File.Exists(langfile))
			{
				throw new XmlDslLoaderException("Не возможно найти файл XML языка" + langfile);
			}
			var xsl = new XslCompiledTransform();
			if(trdef.NeedPrepareXslt) {
				var xsltcontent = XElement.Load(langfile);
				xsltcontent = trdef.PrepareXslt(xsltcontent);
				var resolver = new XmlDslRootBasedXmlUrlResolver(langfile);
				xsl.Load(xsltcontent.CreateReader(),XsltSettings.TrustedXslt,resolver);
			}else {
				xsl.Load(langfile, XsltSettings.TrustedXslt, new XmlUrlResolver());
			}
			var args = trdef.CreateArguments();
			var sw = new StringWriter();
			using (var xw = XmlWriter.Create(sw)) {
				xsl.Transform(xml.CreateReader(),args,xw);
				xw.Flush();
			}
			return XElement.Parse(sw.ToString());
		}
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:36,代码来源:XmlDslLoader.cs

示例3: HxS

        public HxS(string workingDir, string hxsFile,
            string title, string copyright, string locale,
            TreeNodeCollection nodes,
            Content contentDataSet,
            Dictionary<string, string> links)
        {
            this.locale = locale;
            this.title = title;
            this.copyright = copyright;
            this.nodes = nodes;
            this.contentDataSet = contentDataSet;
            this.links = links;

            this.outputFile = Path.GetFullPath(hxsFile);
            this.rawDir = Path.Combine(workingDir, "raw");

            // The source shouldn't be hidden away. If an error happens (likely) the user needs to check logs etc.
            //this.hxsDir = Path.Combine(workingDir, "hxs");
            this.hxsDir = GetUniqueDir(hxsFile);
            this.withinHxsDir = Path.Combine(hxsDir, hxsSubDir);
            this.baseFilename = Path.GetFileNameWithoutExtension(hxsFile);
            this.baseFilename = this.baseFilename.Replace(" ", "_");  //replace spaces with _ otherwise we get compile errors

            this.logFile = Path.Combine(hxsDir, this.baseFilename + ".log");
            this.projectFile = Path.Combine(hxsDir, baseFilename + ".hxc");

            if (xform == null)
            {
                xform = new XslCompiledTransform(true);
                xform.Load(transformFile);
            }
        }
开发者ID:mark-s,项目名称:MSDN-to-Kindle,代码行数:32,代码来源:Hxs.cs

示例4: Transform

        private static StringBuilder Transform(string gcmlPath)
        {
            if(!File.Exists(gcmlPath))
            {
                throw new GCMLFileNotFoundException("The GCML File" + gcmlPath + " does not exist.");
            }

            if(!File.Exists(xsltFilePath))
            {
                throw new XSLTFileNotFoundException("The XSLT File" + xsltFilePath + " does not exist.");
            }

            StringBuilder sb = new StringBuilder();
            XmlTextReader xmlSource = new XmlTextReader(gcmlPath);
            XPathDocument xpathDoc = new XPathDocument(xmlSource);
            XslCompiledTransform xsltDoc = new XslCompiledTransform();

            xsltDoc.Load(xsltFilePath);

            StringWriter sw = new StringWriter(sb);
            try
            {
                xsltDoc.Transform(xpathDoc, null, sw);
            }
            catch (XsltException except)
            {
                Console.WriteLine(except.Message);
                throw except;
            }

            return sb;
        }
开发者ID:radtek,项目名称:rrcomssys-team-5,代码行数:32,代码来源:SchemaTransformer.cs

示例5: Transform

        public static string Transform(string xml, string xslPath)
        {
            try
            {
                //create an XPathDocument using the reader containing the XML
                MemoryStream m = new MemoryStream(System.Text.Encoding.Default.GetBytes(xml));

                XPathDocument xpathDoc = new XPathDocument(new StreamReader(m));

                //Create the new transform object
                XslCompiledTransform transform = new XslCompiledTransform();

                //String to store the resulting transformed XML
                StringBuilder resultString = new StringBuilder();

                XmlWriter writer = XmlWriter.Create(resultString);

                transform.Load(xslPath);

                transform.Transform(xpathDoc,writer);
               
                return resultString.ToString();
            }
            catch (Exception e)
            {

                Console.WriteLine("Exception: {0}", e.ToString());
                return e.ToString();
            }
        }
开发者ID:mastronardif,项目名称:AngularAndMVC,代码行数:30,代码来源:MyXML.cs

示例6: 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

示例7: 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

示例8: Main

 private static void Main()
 {
     var xsl = new XslCompiledTransform();
     xsl.Load(Constants.FilePathForXslt);
     xsl.Transform(Constants.FilePathForCatalogue, SaveFilePath);
     Console.WriteLine("Catalogue.xml created in project folder.");
 }
开发者ID:deyantodorov,项目名称:TelerikAcademy,代码行数:7,代码来源:XsltTransformation.cs

示例9: 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

示例10: 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

示例11: Main

 public static void Main()
 {
     XslCompiledTransform xslt = new XslCompiledTransform();
     xslt.Load("../../../14.catalog.xslt");
     xslt.Transform("..\\..\\..\\XmlCatalogDirectory\\text.xml", "../../../14. Catalog.html");
     Console.WriteLine("Successfully transformed!");
 }
开发者ID:Nottyy,项目名称:TelerikAcademy,代码行数:7,代码来源:TransformToHtml.cs

示例12: ExtensionBL

        //--- Class Constructor ---
        static ExtensionBL() {

            // load XSLT for normalizing extensions
            XDoc doc = Plug.New("resource://mindtouch.deki/MindTouch.Deki.Resources.ExtensionConverter.xslt").With(DreamOutParam.TYPE, MimeType.XML.FullType).Get().ToDocument();
            _extensionConverterXslt = new XslCompiledTransform();
            _extensionConverterXslt.Load(new XmlNodeReader(doc.AsXmlNode), null, null);
        }
开发者ID:heran,项目名称:DekiWiki,代码行数:8,代码来源:ExtensionBL.cs

示例13: transform

 public static string transform(this string xml, string xslt, IDictionary parameters)
 {
     var trans = new XslCompiledTransform();
     trans.Load(xslt.asXPathNavigable(), XsltSettings.TrustedXslt, new FilePathXmlResolver(myapp.files));
     var args = XsltStandardExtension.PrepareArgs();
     if (null != parameters)
     {
         foreach (var parameter in parameters.Keys)
         {
             var nameorns = parameter.ToString();
             var paramorext = parameters[parameter];
             bool ext = true;
             if (paramorext is XPathNavigator || paramorext is XPathNavigator || paramorext is string || paramorext is ValueType)
             {
                 ext = false;
             }
             if (ext)
             {
                 args.AddExtensionObject(nameorns, paramorext);
             }
             else
             {
                 args.AddParam(nameorns, string.Empty, paramorext);
             }
         }
     }
     var sw = new StringWriter();
     trans.Transform(xml.asXPathNavigable(), args, sw);
     return sw.ToString();
 }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:30,代码来源:IXmlTest.cs

示例14: XsltTransformer

  public XsltTransformer()
  {
      _xsltTransform = new XslCompiledTransform();
      _xsltTransform.Load(@"..\..\PersonToEmployee.xsl");
      _xsltEnrich = new XslCompiledTransform();
      _xsltEnrich.Load(@"..\..\PersonToPerson.xsl");
 }
开发者ID:huoxudong125,项目名称:GLD.Benchmark.XsltVsNet,代码行数:7,代码来源:XsltTransformer.cs

示例15: TransformTestForm_Load

        // initialize variables
        private void TransformTestForm_Load( object sender, EventArgs e )
        {
            transformer = new XslCompiledTransform(); // create transformer

             // load and compile the style sheet
             transformer.Load( "sports.xsl" );
        }
开发者ID:Kazempour,项目名称:src,代码行数:8,代码来源:TransformTestForm.cs


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