本文整理汇总了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();
}
示例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());
}
示例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);
}
}
示例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;
}
示例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();
}
}
示例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();
}
示例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();
}
}
}
示例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.");
}
示例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");
}
示例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);
}
示例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!");
}
示例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);
}
示例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();
}
示例14: XsltTransformer
public XsltTransformer()
{
_xsltTransform = new XslCompiledTransform();
_xsltTransform.Load(@"..\..\PersonToEmployee.xsl");
_xsltEnrich = new XslCompiledTransform();
_xsltEnrich.Load(@"..\..\PersonToPerson.xsl");
}
示例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" );
}