本文整理汇总了C#中System.Xml.Xsl.XslCompiledTransform.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# XslCompiledTransform.GetType方法的具体用法?C# XslCompiledTransform.GetType怎么用?C# XslCompiledTransform.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Xsl.XslCompiledTransform
的用法示例。
在下文中一共展示了XslCompiledTransform.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteTask
//.........这里部分代码省略.........
XmlReader xmlReader = null;
XmlReader xslReader = null;
TextWriter writer = null;
try {
// store current directory
string originalCurrentDirectory = Directory.GetCurrentDirectory();
// initialize XPath document holding input XML
XPathDocument xml = null;
try {
// change current directory to directory containing
// XSLT file, to allow includes to be resolved
// correctly
Directory.SetCurrentDirectory(srcInfo.DirectoryName);
// load the xml that needs to be transformed
Log(Level.Verbose, "Loading XML file '{0}'.",
srcInfo.FullName);
xmlReader = CreateXmlReader(new Uri(srcInfo.FullName));
xml = new XPathDocument(xmlReader);
} finally {
// restore original current directory
Directory.SetCurrentDirectory(originalCurrentDirectory);
}
// initialize xslt parameters
XsltArgumentList xsltArgs = new XsltArgumentList();
// set the xslt parameters
foreach (XsltParameter parameter in Parameters) {
if (IfDefined && !UnlessDefined) {
xsltArgs.AddParam(parameter.ParameterName,
parameter.NamespaceUri, parameter.Value);
}
}
// create extension objects
foreach (XsltExtensionObject extensionObject in ExtensionObjects) {
if (extensionObject.IfDefined && !extensionObject.UnlessDefined) {
object extensionInstance = extensionObject.CreateInstance();
xsltArgs.AddExtensionObject(extensionObject.NamespaceUri,
extensionInstance);
}
}
try {
if (XsltFile.IsFile) {
// change current directory to directory containing
// XSLT file, to allow includes to be resolved
// correctly
FileInfo fileInfo = new FileInfo(XsltFile.LocalPath);
Directory.SetCurrentDirectory(fileInfo.DirectoryName);
}
// load the stylesheet
Log(Level.Verbose, "Loading stylesheet '{0}'.", XsltFile);
xslReader = CreateXmlReader(XsltFile);
// create writer for the destination xml
writer = CreateWriter(destInfo.FullName);
// do the actual transformation
Log(Level.Info, "Processing '{0}' to '{1}'.",
srcInfo.FullName, destInfo.FullName);
XslCompiledTransform xslt = new XslCompiledTransform();
string xslEngineName = xslt.GetType().Name;
Log(Level.Verbose, "Using {0} to load '{1}'.",
xslEngineName, XsltFile);
xslt.Load(xslReader, new XsltSettings(true, true), new XmlUrlResolver() );
Log(Level.Verbose, "Using {0} to process '{1}' to '{2}'.",
xslEngineName, srcInfo.FullName, destInfo.FullName);
xslt.Transform(xml, xsltArgs, writer);
} finally {
// restore original current directory
Directory.SetCurrentDirectory(originalCurrentDirectory);
}
} catch (Exception ex) {
throw new BuildException(string.Format(CultureInfo.InvariantCulture,
ResourceUtils.GetString("NA1151"), srcInfo.FullName, XsltFile),
Location, ex);
} finally {
// ensure file handles are closed
if (xmlReader != null) {
xmlReader.Close();
}
if (xslReader != null) {
xslReader.Close();
}
if (writer != null) {
writer.Close();
}
}
}
}
}