本文整理汇总了C#中System.Xml.XmlUrlResolver类的典型用法代码示例。如果您正苦于以下问题:C# XmlUrlResolver类的具体用法?C# XmlUrlResolver怎么用?C# XmlUrlResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlUrlResolver类属于System.Xml命名空间,在下文中一共展示了XmlUrlResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DotNetCompiledTransform
public DotNetCompiledTransform(string sTransformName, string sTargetLanguageCode)
: base(sTargetLanguageCode)
{
var resolver = new XmlUrlResolver();
resolver.Credentials = System.Net.CredentialCache.DefaultCredentials;
m_transformer.Load(sTransformName, XsltSettings.TrustedXslt, resolver);
}
示例2: 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();
}
示例3: XslCompiler
/// <summary>
/// Initializes a new instance of the <see cref="XslCompiler">XslCompiler</see> class.
/// </summary>
public XslCompiler(string path, string assemblyFilename)
{
Path = path;
Filename = assemblyFilename;
TargetProcessor = ImageFileMachine.I386;
XsltSettings = new XsltSettings();
XmlResolver = new XmlUrlResolver();
XmlResolver.Credentials = CredentialCache.DefaultCredentials;
}
示例4: ImportXmiStream
public Stream ImportXmiStream(string filename)
{
XmlDocument input = GetInputFile (filename);
XmlResolver res = new XmlUrlResolver ();
XslTransform xslt = GetXslt (input, null, res);
MemoryStream output = new MemoryStream ();
xslt.Transform (input, new XsltArgumentList (), output, res);
return output;
}
示例5: Transform
public void Transform(string modelFilePath)
{
XmlResolver resolver = new XmlUrlResolver();
resolver.Credentials = CredentialCache.DefaultCredentials;
XmlTextReader doc = new XmlTextReader(modelFilePath);
XslCompiledTransform transform = new XslCompiledTransform();
transform.Load(this.stylesheetFilesPath + Path.DirectorySeparatorChar + "XMI11Export.xsl",null,resolver);
transform.Transform(doc,null,new XmlTextWriter(this.xmiFilesPath,Encoding.UTF8),resolver);
}
示例6: BuildPages
public void BuildPages(string modelFilePath)
{
XmlResolver resolver = new XmlUrlResolver();
resolver.Credentials = CredentialCache.DefaultCredentials;
XmlDocument doc = new XmlDocument();
doc.XmlResolver = resolver;
doc.Load(modelFilePath);
XmlNode modelNode = doc.SelectSingleNode("//Model");
this.RecurseNode(modelFilePath, resolver, modelNode,"Package.xsl");
}
示例7: ImportXmi
public XmlDocument ImportXmi(string filename)
{
XmlDocument input = GetInputFile (filename);
XmlResolver res = new XmlUrlResolver ();
XslTransform xslt = GetXslt (input, null, res);
XmlReader reader = xslt.Transform (input, new XsltArgumentList (), res);
XmlDocument output = new XmlDocument ();
output.Load (reader);
return output;
}
示例8: GetEntity
public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn)
{
string name = absoluteUri.AbsoluteUri.Split(new char[] { '/' }).Last<string>();
byte[] stream = _schemas[name];
if (stream != null)
{
return new MemoryStream(stream);;
}
XmlUrlResolver resolver = new XmlUrlResolver();
return resolver.GetEntity(absoluteUri, role, ofObjectToReturn);
}
示例9: Transform
public void Transform(string modelFilePath)
{
XmlResolver resolver = new XmlUrlResolver();
resolver.Credentials = CredentialCache.DefaultCredentials;
XmlDocument doc = new XmlDocument();
doc.XmlResolver = resolver;
doc.Load(modelFilePath);
XslTransform transform = new XslTransform();
transform.Load(this.stylesheetFilesPath + Path.DirectorySeparatorChar + "XMI11Export.xsl",resolver);
StreamWriter sw = new StreamWriter(this.xmiFilesPath,false);
transform.Transform(doc,null,sw,null);
sw.Close();
}
示例10: SendEmail
public static bool SendEmail(SPWeb web, string emailTo, string xslt, IDictionary xslValues)
{
XmlDocument xmlDoc;
XPathNavigator xpathNavigator;
XslCompiledTransform xslEmailTransform = new XslCompiledTransform();
XsltArgumentList xslArguments;
StringBuilder sbEmail;
XmlTextWriter xmlWriter;
XmlNode xmlNodeTitle;
XmlDocument xmlEmail;
XsltSettings settings = new XsltSettings(true, true);
XmlUrlResolver resolver = new XmlUrlResolver();
string subject = string.Empty;
try
{
xslEmailTransform.Load(new XmlTextReader(xslt, XmlNodeType.Document, null), settings, resolver);
xmlDoc = new XmlDocument();
xmlDoc.AppendChild(xmlDoc.CreateElement("DocumentRoot"));
xpathNavigator = xmlDoc.CreateNavigator();
xslArguments = new XsltArgumentList();
if (xslValues != null)
{
foreach (DictionaryEntry xslEntry in xslValues)
{
xslArguments.AddExtensionObject(xslEntry.Key.ToString(), xslEntry.Value);
}
}
sbEmail = new StringBuilder();
xmlWriter = new XmlTextWriter(new StringWriter(sbEmail));
xslEmailTransform.Transform(xpathNavigator, xslArguments, xmlWriter);
xmlEmail = new XmlDocument();
xmlEmail.LoadXml(sbEmail.ToString());
xmlNodeTitle = xmlEmail.SelectSingleNode("//title");
subject = xmlNodeTitle.InnerText;
return SendEmail(web, emailTo, subject, sbEmail.ToString());
}
catch (Exception ex)
{
Utils.LogError(ex);
return false;
}
}
示例11: openToolStripMenuItem_Click
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*";
if (dialog.ShowDialog() == DialogResult.OK)
{
XmlDataDocument xmldoc = new XmlDataDocument();
XmlReaderSettings settings = new XmlReaderSettings();
settings.IgnoreWhitespace = true;
settings.ProhibitDtd = false;
XmlUrlResolver resolver = new XmlUrlResolver();
resolver.Credentials = CredentialCache.DefaultCredentials;
settings.XmlResolver = resolver;
XmlReader render = XmlReader.Create(dialog.FileName, settings);
try
{
try
{
xmldoc.Load(render);
}
catch (Exception ex)
{
MessageBox.Show(this, ex.Message, "Parse Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
finally
{
render.Close();
}
GridBuilder builder = new GridBuilder();
if (xmlGrid.ShowColumnHeader)
{
GridCellGroup xmlgroup = new GridCellGroup();
xmlgroup.Flags = GroupFlags.Overlapped | GroupFlags.Expanded;
builder.ParseNodes(xmlgroup, null, xmldoc.ChildNodes);
GridCellGroup root = new GridCellGroup();
root.Table.SetBounds(1, 2);
root.Table[0, 0] = new GridHeadLabel();
root.Table[0, 0].Text = dialog.FileName;
root.Table[0, 1] = xmlgroup;
xmlGrid.Cell = root;
}
else
{
GridCellGroup root = new GridCellGroup();
builder.ParseNodes(root, null, xmldoc.ChildNodes);
xmlGrid.Cell = root;
}
}
}
示例12: Init
private void Init (HttpContext context) {
AppSettings baseXslt = new AppSettings();
String xsltUri = context.Server.MapPath(baseXslt.GetSetting("baseTemplate"));
Uri xUri = new Uri(xsltUri);
this._Resolver = new XmlUrlResolver();
this._Resolver.Credentials = CredentialCache.DefaultCredentials;
this._TemplateStream = (Stream)this._Resolver.GetEntity(xUri, null, typeof(Stream));
this._Processor = new Processor();
this._Compiler = _Processor.NewXsltCompiler();
this._Compiler.BaseUri = xUri;
this._Template = this._Compiler.Compile(_TemplateStream);
this._IS_INITIALIZED = true;
}
示例13: ProcessRequest
public void ProcessRequest(HttpContext context) {
_requestMethod = context.Request.HttpMethod;
_writer = context.Response.Output;
_context = context;
_processor = (Processor)context.Application["processor"];
_compiler = (XsltCompiler)context.Application["compiler"];
_serializer = (Serializer)context.Application["serializer"];
_resolver = (XmlUrlResolver)context.Application["resolver"];
_globalXsltParams = (Hashtable)context.Application["globalXsltParams"];
_sessionXsltParams = (Hashtable)context.Application["sessionXsltParams"];
_requestXsltParams = (Hashtable)context.Application["requestXsltParams"];
Hashtable xsltParams = new Hashtable();
foreach (DictionaryEntry param in _globalXsltParams) {
xsltParams[param.Key] = param.Value;
}
foreach (DictionaryEntry param in _sessionXsltParams) {
xsltParams[param.Key] = param.Value;
}
foreach (DictionaryEntry param in _requestXsltParams) {
xsltParams[param.Key] = param.Value;
}
_transformContext = new Context(context, _processor, _compiler, _serializer, _resolver, xsltParams);
switch (_requestMethod) {
case "GET": {
new Transform().Process(_transformContext);
break;
}
case "PUT": {
new Transform().Process(_transformContext);
break;
}
case "POST": {
new Transform().Process(_transformContext);
break;
}
case "DELETE": {
new Transform().Process(_transformContext);
break;
}
default: {
new Transform().Process(_transformContext);
break;
}
}
}
示例14: TransformFromData
/// <summary>
/// Transform data.
/// </summary>
/// <param name="xmlData"> The xml data to load.</param>
/// <param name="stylesheet"> The style sheet data to load.</param>
/// <returns> A string containing the html report.</returns>
public string TransformFromData(string xmlData, string stylesheet)
{
// new XmlDocument, adds a xml using GetXml()
XmlDocument root = new XmlDocument();
root.LoadXml(xmlData);
XPathNavigator nav = root.CreateNavigator();
// xml resolver
XmlUrlResolver resolver = new XmlUrlResolver();
resolver.Credentials=System.Net.CredentialCache.DefaultCredentials;
// evidence
//Evidence ev = XmlSecureResolver.CreateEvidenceForUrl(stylesheet);
StringWriter output = null;
XmlTextReader reader = null;
try
{
// XmlReader
//StreamReader stm = new StreamReader(st,System.Text.Encoding.Default);
StringReader sreader = new StringReader(stylesheet);
reader = new XmlTextReader(sreader);
XslTransform xslt = new XslTransform();
output = new StringWriter();
// load
xslt.Load(reader, resolver, null);
// transform
xslt.Transform(nav,null,output,resolver);
return output.ToString();
}
catch
{
throw;
}
finally
{
if ( output != null )
output.Close();
if ( reader != null )
reader.Close();
}
}
示例15: Form1
public Form1()
{
InitializeComponent();
XmlUrlResolver resolver = new XmlUrlResolver();
Uri myUri = new Uri("http://dgcsc.org/goldprices.xml");
Stream s = (Stream)resolver.GetEntity(myUri, null, typeof(Stream));
// Construct a reader using the Stream object.
XmlTextReader xmlTextReader = new XmlTextReader(s);
XmlDataDocument xdoc1 = new XmlDataDocument();
xdoc1.DataSet.ReadXml(xmlTextReader, XmlReadMode.Auto);
DataSet ds = xdoc1.DataSet;
//DataTable dt = ds;
dataGridView1.DataSource = ds.Tables[1];
}