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


C# XslTransform.Load方法代码示例

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


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

示例1: GetDataSummary

        protected virtual string GetDataSummary(Stream xsltStream)
        {
            DataSet data = this.GetDataSet;
            if (xsltStream == null || data == null)
                return null;

            Stream dsStream = new MemoryStream();
            data.WriteXml(dsStream);

            TextWriter tw = new StringWriter();

            try
            {
                XslTransform xsl = new XslTransform();

                XmlDocument XSLTDoc = new XmlDocument();
                XSLTDoc.Load(xsltStream);
                XmlDocument dataDoc = new XmlDocument();
                dataDoc.LoadXml(data.GetXml());

                XPathNavigator stylesheet = XSLTDoc.CreateNavigator();
                xsl.Load(stylesheet, null, null);
                XPathNavigator dataNav = dataDoc.CreateNavigator();

                xsl.Transform(dataNav, null, tw, null);
            }
            catch (Exception ex)
            {
                return null;
            }

            return tw.ToString();
        }
开发者ID:mbmccormick,项目名称:Ximura,代码行数:33,代码来源:DataContent_IDataContentSummary.cs

示例2: InvalidStylesheet

		public void InvalidStylesheet ()
		{
			XmlDocument doc = new XmlDocument ();
			doc.LoadXml ("<xsl:element xmlns:xsl='http://www.w3.org/1999/XSL/Transform' />");
			XslTransform t = new XslTransform ();
			t.Load (doc);
		}
开发者ID:zxlin25,项目名称:mono,代码行数:7,代码来源:XslTransformTests.cs

示例3: Transform

        public static string Transform(string xml,string xslFile)
        {
            XslTransform transform = new XslTransform();
            XsltArgumentList args = new XsltArgumentList();
            //define the xslt rendering file
            //get the iterators for the root and context item
            XPathDocument xmlDoc = new XPathDocument(new StringReader(xml));
            XPathNavigator iter = xmlDoc.CreateNavigator();

            //define and add the xslt extension classes
            //Sitecore.Xml.Xsl.XslHelper sc = new Sitecore.Xml.Xsl.XslHelper();
            XsltHelper xslt = new XsltHelper();
            args.AddExtensionObject("http://www.rlmcore.vn/helper", xslt);

            //add parameters
            args.AddParam("item", "", iter);
            args.AddParam("currentitem", "", iter.Select("."));
            //define the stream which will contain the result of xslt transformation
            //StringBuilder sb = new StringBuilder();
            //TextWriter stream = new FileStream(new MemoryStream(Encoding.ASCII.GetBytes(sb.ToString())));
            System.IO.StringWriter stream = new System.IO.StringWriter();

            //load xslt rendering to XslTransform class
            transform.Load(xslFile);
            //perform a transformation with the rendering
            transform.Transform(iter, args, stream);

            return stream.ToString();
        }
开发者ID:vinasourcetutran,项目名称:searchengine,代码行数:29,代码来源:XsltHelper.cs

示例4: Main

 static void Main(string[] args)
 {
     XslTransform xslt = new XslTransform();
             xslt.Load(@"..\Transforms\PAWSSKHtmlMapper.xsl");
     string[] astrFiles;
     astrFiles = Directory.GetFiles(".", "*.xml");
     if (astrFiles.Length > 0)
     {
         foreach (string strFile in astrFiles)
         {
             try
             {
                 string strDestFile = Path.Combine(@"..\HTMs",
              Path.GetFileNameWithoutExtension(strFile));
     strDestFile += ".htm";
                 Console.WriteLine("Making {0} from {1}", strDestFile, strFile);
                 xslt.Transform(strFile, strDestFile);
             }
             catch (Exception exc)
             {
                 Console.WriteLine("Error: " + exc);
                 return;
             }
         }
     }
 }
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:26,代码来源:MakeHtms.cs

示例5: ViewGui

        public ViewGui()
        {
            Stetic.Gui.Build(this, typeof(Sofia.Views.WelcomeView.ViewGui));

            //Ajout d'une page d'accueil avec un navigateur web
            htmlControl = new MozillaControl();
            this.Add(htmlControl);
            htmlControl.Show();

            string datadir = Directory.GetCurrentDirectory() + "/";

            // build simple xml which XSLT will process into XHTML
            string myxml = 	"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" +
                            "<WelcomePage>" +
                            "<ResourcePath>" + datadir + "</ResourcePath>" +
                            BuildRecentFoldersXml() +
                            "</WelcomePage>";

            XmlDocument inxml = new XmlDocument();
            inxml.LoadXml(myxml);

            XslTransform xslt = new XslTransform();
            xslt.Load(datadir + "WelcomePage.xsl");
            StringWriter fs = new StringWriter();
            xslt.Transform(inxml, null, fs, null);

            htmlControl.Html = fs.ToString();
        }
开发者ID:BackupTheBerlios,项目名称:sofia-svn,代码行数:28,代码来源:ViewGui.cs

示例6: GetStatesXMLString

		/// <summary>
		/// This function retuns list of states for a given country as XML Document in a string 
		/// and this value is used in client side java script to populate state combo box.
		/// Functionality: Transform the CountriesAndStates xml string into another XML string having the single country 
		/// and states under that country. 
		/// </summary>
		public string GetStatesXMLString(string countryName)
		{
			//Creates a XslTransform object and load the CountriesAndStates.xsl file
			XslTransform transformToCountryNode = new XslTransform();
			transformToCountryNode.Load(new XPathDocument(HttpContext.Current.Server.MapPath("~/xmlxsl/CountriesAndStates.xsl")).CreateNavigator(), new XmlUrlResolver());
			//TransformToCountryNode.Load(new XPathDocument(HttpContext.Current.Server.MapPath("~/xmlxsl/CountriesAndStates.xsl")).CreateNavigator(), new XmlUrlResolver(), this.GetType().Assembly.Evidence);

			//Creating the XSLT parameter country-name and setting the value
			XsltArgumentList xslArgs = new XsltArgumentList();
			xslArgs.AddParam("country-name", "", countryName);
				
			// Memory stream to store the result of XSL transform 
			MemoryStream countryNodeMemoryStream = new MemoryStream(); 
			XmlTextWriter countryNodeXmlTextWriter = new XmlTextWriter(countryNodeMemoryStream, Encoding.UTF8); 
			countryNodeXmlTextWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");

			//transforming the current XML string to get the state XML string
			transformToCountryNode.Transform(xPathDoc, xslArgs,  countryNodeXmlTextWriter);
			//TransformToCountryNode.Transform(XPathDoc, XslArgs,  CountryNodeXmlTextWriter, null);

			//reading the XML string using StreamReader and return the same
			countryNodeXmlTextWriter.Flush(); 
			countryNodeMemoryStream.Position = 0; 
			StreamReader countryNodeStreamReader = new StreamReader(countryNodeMemoryStream); 
			return  countryNodeStreamReader.ReadToEnd(); 
		}
开发者ID:TestRvSlv,项目名称:reporting,代码行数:32,代码来源:CountryStateXml.cs

示例7: TransformingTest

		public void TransformingTest() 
		{
			XslTransform tx = new XslTransform();
			tx.Load(new XmlTextReader(
				Globals.GetResource(this.GetType().Namespace + ".test.xsl")));

			XmlReader xtr = new XmlTransformingReader(
				new XmlTextReader(
				Globals.GetResource(this.GetType().Namespace + ".input.xml")),
				tx);

			//That's it, now let's dump out XmlTransformingReader to see what it returns
			StringWriter sw = new StringWriter();
			XmlTextWriter w = new XmlTextWriter(sw);
			w.Formatting = Formatting.Indented;
			w.WriteNode(xtr, false);
			xtr.Close();
			w.Close();

			Assert.AreEqual(sw.ToString(), @"<parts>
  <item SKU=""1001"" name=""Lawnmower"" price=""299.99"" />
  <item SKU=""1001"" name=""Electric drill"" price=""99.99"" />
  <item SKU=""1001"" name=""Hairdrier"" price=""39.99"" />
</parts>");
		}
开发者ID:zanyants,项目名称:mvp.xml,代码行数:25,代码来源:Tests.cs

示例8: BindAuto

        private void BindAuto(Rubric rub)
        {
            Result.ResultList ress =
                new Rubrics(Globals.CurrentIdentity).GetResults(rub.ID, GetCurrentSub());

            if (ress.Count == 0) {
                divAuto.InnerHtml = "<i>There are no results for this evaluation item</i>";
                return;
            }

            AutoResult res = ress[0] as AutoResult;
            MemoryStream xmlstr = new MemoryStream(Encoding.ASCII.GetBytes(res.XmlResult));

            XslTransform xslt = new XslTransform();

            XPathDocument xpathdoc = new XPathDocument(xmlstr);
            XPathNavigator nav = xpathdoc.CreateNavigator();

            XPathDocument xsldoc = new XPathDocument(
                Path.Combine(Globals.WWWDirectory, "Xml/reshtml.xslt"));

            StringBuilder strb = new StringBuilder();
            xslt.Load(xsldoc, null, null);
            xslt.Transform(xpathdoc, null, new XmlTextWriter(new StringWriter(strb)) , (XmlResolver)null);

            divAuto.InnerHtml = strb.ToString();
        }
开发者ID:padilhalino,项目名称:FrontDesk,代码行数:27,代码来源:results.ascx.cs

示例9: Parse

		public static void Parse(
			XmlDocument		xmlMetadata_in, 
			string			xsltTemplateURL_in, 
			Hashtable		xsltParameters_in, 

			StringWriter	parsedOutput_in
		) {
			#region XsltArgumentList _xsltparameters = new XsltArgumentList().AddParam(...);
			XsltArgumentList _xsltparameters = new XsltArgumentList();
			IDictionaryEnumerator _denum = xsltParameters_in.GetEnumerator();
			_denum.Reset();
			while (_denum.MoveNext()) {
				_xsltparameters.AddParam(
					_denum.Key.ToString(), 
					"", 
					System.Web.HttpUtility.UrlEncode(
						_denum.Value.ToString()
					)
				);
			}
			#endregion

			XPathNavigator _xpathnav = xmlMetadata_in.CreateNavigator();
			XslTransform _xslttransform = new XslTransform();
			_xslttransform.Load(
				xsltTemplateURL_in
			);
			_xslttransform.Transform(
				_xpathnav, 
				_xsltparameters, 
				parsedOutput_in, 
				null
			);
		}
开发者ID:katshann,项目名称:ogen,代码行数:34,代码来源:ParserXSLT.cs

示例10: RunXSLT

        /* KCS: 2012/03/19 - Changed to be able to pass args to the template.
         *
         * xslt <xsltFile> <inputXml> <outputFile> <parm1Name> = <parm1Value>  <parm2Name> = <parm2Value> .....
         */
        public void RunXSLT(String xsltFile, String xmlDataFile, String outFile, XsltArgumentList xsltArgs )
        {
            XPathDocument input = new XPathDocument(xmlDataFile);

            XslTransform myXslTrans = new XslTransform();
            XmlTextWriter output = null;
            try
            {

                myXslTrans.Load(xsltFile);

                output = new XmlTextWriter(outFile, null);
                output.Formatting = Formatting.Indented;

                myXslTrans.Transform(input, xsltArgs, output);

            }
            catch (Exception e)
            {

                Console.WriteLine(e.StackTrace);
                Console.WriteLine("Error: " + e.Message);

            }
            finally
            {
                try { output.Close(); }
                catch (Exception) { }
            }
        }
开发者ID:kcsampson,项目名称:Kexplorer,代码行数:34,代码来源:XSLT.cs

示例11: RunXslt

        public void RunXslt(String xsltFile, String xmlDataFile, String outputXml)
        {
            XPathDocument input = new XPathDocument(xmlDataFile);

            XslTransform myXslTrans = new XslTransform() ;
            XmlTextWriter output = null;
            try
            {
                myXslTrans.Load(xsltFile);

                output = new XmlTextWriter(outputXml, null);
                output.Formatting = Formatting.Indented;

                myXslTrans.Transform(input, null, output);

            }
            catch (Exception e)
            {
                String msg = e.Message;
                if (msg.IndexOf("InnerException") >0)
                {
                    msg = e.InnerException.Message;
                }

                MessageBox.Show("Error: " + msg + "\n" + e.StackTrace, "Xslt Error File: " + xsltFile, MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
            finally
            {
                try { output.Close(); }
                catch (Exception) { }
            }
        }
开发者ID:kcsampson,项目名称:Kexplorer,代码行数:33,代码来源:XSLTRunScript.cs

示例12: MatchRoot

        public void MatchRoot()
        {
            XmlDocument xsltDoc = new XmlDocument();
            xsltDoc.LoadXml( @"
                <xsl:stylesheet version='1.0'
                    xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
                <xsl:output method='xml' omit-xml-declaration='no' encoding='UTF-8'/>

                <xsl:template match='/'><root>Matched</root></xsl:template>

                </xsl:stylesheet>
            " );
            XslTransform xslt = new XslTransform();
            xslt.Load( xsltDoc );

            StringBuilder builder = new StringBuilder();
            XmlWriter writer = new XmlTextWriter( new StringWriter( builder ) );

            CollectionOfSimple c = new CollectionOfSimple( true );
            ObjectXPathContext context = new ObjectXPathContext();
            context.DetectLoops = true;
            XPathNavigator nav = context.CreateNavigator( c );

            xslt.Transform( nav, null, writer, null );
            writer.Close();

            Assert.AreEqual( "<root>Matched</root>", builder.ToString() );
        }
开发者ID:hjarvard,项目名称:ObjectXPathNavigator,代码行数:28,代码来源:XsltTest.cs

示例13: Xml

		static Xml ()
		{
			XmlTextReader reader = new XmlTextReader (new StringReader("<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>"));

			defaultTransform = new XslTransform();
#if NET_1_0
			defaultTransform.Load (reader);
#else
			defaultTransform.Load (reader, null, null);
#endif
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:16,代码来源:Xml.cs

示例14: TransformDirectory

        public static bool TransformDirectory(string source)
        {
            string stylesheet = "mn2db.xsl";
            string destination = "docbook" + Path.DirectorySeparatorChar;
            // create destination directory if needed
            string destdir = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + destination;

            try {
                if(!Directory.Exists(destdir)) {
                    Directory.CreateDirectory(destdir);
                }
                // transform the documents in the directory
                string[] filelist = Directory.GetFiles(source,"*.xml");
                XslTransform transform = new XslTransform();
                transform.Load(stylesheet);
                foreach(string sourcefile in filelist) {
                    string destfile = destdir + Path.GetFileName(sourcefile);
                    Console.WriteLine("Transforming {0}",sourcefile);
                    transform.Transform(sourcefile, destfile);
                }
            } catch(Exception e) {
                    throw new Mn2DbTransformException(e.ToString());
                }
            return true;
        }
开发者ID:olea,项目名称:LuCAS,代码行数:25,代码来源:mn2db.cs

示例15: Main

 static void Main(string[] args)
 {
     XPathDocument myXPathDoc = new XPathDocument("..\\..\\..\\..\\SchoolJournal\\SchoolJournal\\Displaying\\entry.xml");
     XslTransform myXslTrans = new XslTransform();
     myXslTrans.Load("..\\..\\..\\..\\SchoolJournal\\SchoolJournal\\Displaying\\style1.xsl");
     XmlTextWriter myWriter = new XmlTextWriter("..\\..\\result.html", null);
     myXslTrans.Transform(myXPathDoc, null, myWriter);
 }
开发者ID:a-pinch,项目名称:andrewtroyan,代码行数:8,代码来源:Program.cs


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