本文整理汇总了C#中System.Xml.XmlUrlResolver.GetEntity方法的典型用法代码示例。如果您正苦于以下问题:C# XmlUrlResolver.GetEntity方法的具体用法?C# XmlUrlResolver.GetEntity怎么用?C# XmlUrlResolver.GetEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlUrlResolver
的用法示例。
在下文中一共展示了XmlUrlResolver.GetEntity方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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];
}
示例3: GetEntity
public override object GetEntity(Uri absoluteUri, string role,
Type ofObjectToReturn)
{
Object entityObj = null;
String strURI = absoluteUri.AbsoluteUri;
System.IO.MemoryStream msStream = null;
switch (strURI.ToLower())
{
case "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd":
msStream = new MemoryStream(ResourceDTD.xhtml1_transitional);
break;
case "http://www.w3.org/tr/xhtml1/dtd/xhtml1.dcl":
msStream = new MemoryStream(ResourceDTD.xhtml1);
break;
case "http://www.w3.org/tr/xhtml1/dtd/xhtml-lat1.ent":
msStream = new MemoryStream(ResourceDTD.xhtml_lat1);
break;
case "http://www.w3.org/tr/xhtml1/dtd/xhtml-special.ent":
msStream = new MemoryStream(ResourceDTD.xhtml_special);
break;
case "http://www.w3.org/tr/xhtml1/dtd/xhtml-symbol.ent":
msStream = new MemoryStream(ResourceDTD.xhtml_symbol);
break;
case "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd":
msStream = new MemoryStream(ResourceDTD.xhtml1_strict);
break;
case "http://www.w3.org/tr/xhtml1/dtd/xhtml1-frameset.dtd":
msStream = new MemoryStream(ResourceDTD.xhtml1_frameset);
break;
case "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd":
msStream = new MemoryStream(ResourceDTD.xhtml11);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-inlstyle-1.mod":
msStream = new MemoryStream(ResourceDTD.xhtml_inlstyle_1);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-framework-1.mod":
msStream = new MemoryStream(ResourceDTD.xhtml_framework_1);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-datatypes-1.mod":
msStream = new MemoryStream(ResourceDTD.xhtml_datatypes_1);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-qname-1.mod":
msStream = new MemoryStream(ResourceDTD.xhtml_qname_1);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-events-1.mod":
msStream = new MemoryStream(ResourceDTD.xhtml_events_1);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-attribs-1.mod":
msStream = new MemoryStream(ResourceDTD.xhtml_attribs_1);
break;
case "http://www.w3.org/tr/xhtml11/dtd/xhtml11-model-1.mod":
msStream = new MemoryStream(ResourceDTD.xhtml11_model_1);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-charent-1.mod":
msStream = new MemoryStream(ResourceDTD.xhtml_charent_1);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-lat1.ent":
msStream = new MemoryStream(ResourceDTD.xhtml_lat11);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-symbol.ent":
msStream = new MemoryStream(ResourceDTD.xhtml_symbol11);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-special.ent":
msStream = new MemoryStream(ResourceDTD.xhtml_special11);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-text-1.mod":
msStream = new MemoryStream(ResourceDTD.xhtml_text_1);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-inlstruct-1.mod":
msStream = new MemoryStream(ResourceDTD.xhtml_inlstruct_1);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-inlphras-1.mod":
msStream = new MemoryStream(ResourceDTD.xhtml_inlphras_1);
break;
case "http://www.w3.org/tr/ruby/xhtml-ruby-1.mod":
msStream = new MemoryStream(ResourceDTD.xhtml_ruby_1);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-blkstruct-1.mod":
msStream = new MemoryStream(ResourceDTD.xhtml_blkstruct_1);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-blkphras-1.mod":
msStream = new MemoryStream(ResourceDTD.xhtml_blkphras_1);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-hypertext-1.mod":
msStream = new MemoryStream(ResourceDTD.xhtml_hypertext_1);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-list-1.mod":
msStream = new MemoryStream(ResourceDTD.xhtml_list_1);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-edit-1.mod":
msStream = new MemoryStream(ResourceDTD.xhtml_edit_1);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-bdo-1.mod":
msStream = new MemoryStream(ResourceDTD.xhtml_bdo_1);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-pres-1.mod":
msStream = new MemoryStream(ResourceDTD.xhtml_pres_1);
break;
case "http://www.w3.org/tr/xhtml-modularization/dtd/xhtml-inlpres-1.mod":
//.........这里部分代码省略.........
示例4: CompileProlog
private void CompileProlog ()
{
Prolog p = module.Prolog;
// resolve external modules
// FIXME: check if external queries are allowed by default.
// FIXME: check recursion
XmlUrlResolver res = new XmlUrlResolver ();
foreach (ModuleImport modimp in p.ModuleImports) {
foreach (string uri in modimp.Locations) {
Stream s = res.GetEntity (res.ResolveUri (null, uri), null, typeof (Stream)) as Stream;
XQueryLibraryModule ext = Mono.Xml.XQuery.Parser.Parser.Parse (new StreamReader (s)) as XQueryLibraryModule;
if (ext == null)
throw new XmlQueryCompileException (String.Format ("External module {0} is resolved as a main module, while it should be a library module."));
XQueryStaticContext sctx = new XQueryASTCompiler (ext, options, compileContext, evidence, commandImpl).Compile ();
libModuleContexts.Add (sctx);
}
}
// resolve and compile in-scope schemas
foreach (SchemaImport xsimp in p.SchemaImports) {
foreach (string uri in xsimp.Locations) {
XmlSchema schema = inScopeSchemas.Add (xsimp.Namespace, uri);
compileContext.InEffectSchemas.Add (schema);
}
}
inScopeSchemas.Compile ();
CheckReferences ();
ResolveVariableReferences ();
// compile FunctionDeclaration into XQueryFunction
foreach (FunctionDeclaration func in p.Functions.Values) {
XQueryFunction cfunc = CompileFunction (func);
localFunctions.Add (cfunc);
}
}
示例5: ReadFile
public static string ReadFile(string path, bool skipdeclaration){
var res = new XmlUrlResolver();
var uri = res.ResolveUri(null, path);
var s = (Stream) res.GetEntity(uri, "standard", typeof (Stream));
try{
var sw = new StringWriter();
var w = XmlWriter.Create(sw);
var r = XmlReader.Create(s);
if (skipdeclaration){
r.Read();
if (!(r.NodeType == XmlNodeType.XmlDeclaration)) w.WriteNode(r, false);
else r.Read();
}
while (!r.EOF) w.WriteNode(r, false);
w.Flush();
return sw.ToString();
}
finally{
s.Close();
}
}
示例6: ResolveSchemaLocation
private Stream ResolveSchemaLocation(XmlSchema enclosingSchema, string location, out string fullPath) {
Stream stream;
fullPath = null;
try {
XmlResolver resolver = new XmlUrlResolver();
Uri ruri = resolver.ResolveUri((enclosingSchema.BaseUri != null && enclosingSchema.BaseUri != String.Empty) ? resolver.ResolveUri(null, enclosingSchema.BaseUri) : null, location);
stream = (Stream)resolver.GetEntity(ruri, null, null);
fullPath = ruri.ToString();
}
catch {
return null;
}
return stream;
}