本文整理汇总了C#中System.Xml.Xsl.XslTransform类的典型用法代码示例。如果您正苦于以下问题:C# XslTransform类的具体用法?C# XslTransform怎么用?C# XslTransform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XslTransform类属于System.Xml.Xsl命名空间,在下文中一共展示了XslTransform类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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
示例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: 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
示例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: 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
示例6: 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
示例7: 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
示例8: 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
示例9: 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
示例10: 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
示例11: 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
示例12: 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
示例13: 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
示例14: XmlTransformingReader
/// <summary>
/// Creates XmlTransformingReader with given XmlReader, stylesheet URI,
/// XsltArgumentList and Xmlresolver.
/// </summary>
/// <param name="parentReader">Source XML as XmlReader</param>
/// <param name="transformSource">URI of the stylesheet to transform the source</param>
/// <param name="args">Arguments to the transformation</param>
/// <param name="resolver">XmlResolver to resolve URIs in document() function</param>
public XmlTransformingReader(XmlReader parentReader,
string transformSource, XsltArgumentList args, XmlResolver resolver)
{
XPathDocument doc = new XPathDocument(parentReader);
XslTransform xslt = new XslTransform();
xslt.Load(transformSource);
_outReader = xslt.Transform(doc, args, resolver);
}
开发者ID:zanyants,项目名称:mvp.xml,代码行数:16,代码来源:XmlTransformingReader.cs
示例15: Init
public new void Init(object objParam)
{
#pragma warning disable 0618
xsltSameInstance = new XslTransform();
#pragma warning restore 0618
_strPath = Path.Combine(@"TestFiles\", FilePathUtil.GetTestDataPath(), @"XsltApi\");
return;
}
开发者ID:geoffkizer,项目名称:corefx,代码行数:8,代码来源:CXslTransformMultith.cs
示例16: 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
示例17: Toc2Html
public Toc2Html ()
{
transform = new XslTransform ();
var assembly = Assembly.GetCallingAssembly ();
var stream = assembly.GetManifestResourceStream ("toc-html.xsl");
XmlReader xml_reader = new XmlTextReader (stream);
transform.Load (xml_reader, null, null);
}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:Toc2Html.cs
示例18: XSLTRulesFileDriver
public XSLTRulesFileDriver(string xmlFileURI, XslTransform xslt)
: base(xmlFileURI)
{
if (xslt == null)
throw new BRERuleFatalException("Null is not a valid XslTransform");
this.xslt = xslt;
}
开发者ID:Ghasan,项目名称:NxBRE,代码行数:8,代码来源:XSLTRulesFileDriver.cs
示例19: XmlOutput
internal XmlOutput(XslTransform transform, XsltArgumentList xsltArgs,
XPathNavigator navigator, XmlResolver resolverForXmlTransformed,
XmlReader[] readersToClose) {
_transform = transform;
_xsltArgs = xsltArgs;
_navigator = navigator;
_resolverForXmlTransformed = resolverForXmlTransformed;
_readersToClose = readersToClose;
}
开发者ID:timonela,项目名称:mb-unit,代码行数:9,代码来源:XmlOutput.cs
示例20: generateHtml
public string generateHtml(string xmlpath)
{
string xslpath = ranker.lib.libConfig.GetConfigPath() + Path.DirectorySeparatorChar + "result.xsl";
XslTransform xslt = new XslTransform();
xslt.Load(xslpath);
string htmlpath = ranker.lib.libConfig.GetConfigPath() + Path.DirectorySeparatorChar +"temp.html";
xslt.Transform(xmlpath,htmlpath );
return htmlpath;
}
开发者ID:BackupTheBerlios,项目名称:gtkranker-svn,代码行数:9,代码来源:libResults.cs
注:本文中的System.Xml.Xsl.XslTransform类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论