本文整理汇总了C#中System.Xml.XmlUrlResolver.ResolveUri方法的典型用法代码示例。如果您正苦于以下问题:C# XmlUrlResolver.ResolveUri方法的具体用法?C# XmlUrlResolver.ResolveUri怎么用?C# XmlUrlResolver.ResolveUri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlUrlResolver
的用法示例。
在下文中一共展示了XmlUrlResolver.ResolveUri方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NullAbsoluteUriWithCustomSchemedRelativeUri
[Test] // bug #998
public void NullAbsoluteUriWithCustomSchemedRelativeUri ()
{
XmlResolver res = new XmlUrlResolver ();
var uri = res.ResolveUri (null, "view:Standard.xslt");
Assert.AreEqual ("view", uri.Scheme, "#1");
Assert.AreEqual ("Standard.xslt", uri.AbsolutePath, "#2");
Assert.AreEqual ("view:Standard.xslt", uri.AbsoluteUri, "#2");
}
示例2: NodeIter1
public void NodeIter1()
{
if (_isInProc)
return; //TEST_SKIPPED;
XslCompiledTransform xslt = new XslCompiledTransform();
XsltArgumentList xslArg = new XsltArgumentList();
XmlUrlResolver ur = new XmlUrlResolver();
Uri uriSource = ur.ResolveUri(null, FullFilePath("sample.xsd"));
xslArg.AddParam("sourceUri", String.Empty, uriSource.ToString());
xslt.Load(FullFilePath("xsd2cs1.xsl"), new XsltSettings(true, true), new XmlUrlResolver());
XPathDocument doc = new XPathDocument(FullFilePath("sample.xsd"));
StringWriter sw = new StringWriter();
try
{
xslt.Transform(doc, xslArg, sw);
sw.Dispose();
_output.WriteLine("No exception is thrown when .Current is called before .MoveNext on XPathNodeIterator");
Assert.True(false);
}
catch (System.InvalidOperationException ex)
{
_output.WriteLine(ex.ToString());
return;
}
}
示例3: NodeIter2
public void NodeIter2()
{
if (_isInProc)
return; //TEST_SKIPPED;
XslCompiledTransform xslt = new XslCompiledTransform();
XsltArgumentList xslArg = new XsltArgumentList();
XmlUrlResolver ur = new XmlUrlResolver();
Uri uriSource = ur.ResolveUri(null, FullFilePath("sample.xsd"));
xslArg.AddParam("sourceUri", String.Empty, uriSource.ToString());
xslt.Load(FullFilePath("xsd2cs2.xsl"), new XsltSettings(true, true), new XmlUrlResolver());
XPathDocument doc = new XPathDocument(FullFilePath("sample.xsd"));
StringWriter sw = new StringWriter();
xslt.Transform(doc, xslArg, sw);
sw.Dispose();
return;
}
示例4: resolveUri
/// <summary>
///
/// </summary>
/// <param name="baseURI"></param>
/// <param name="path"></param>
/// <returns></returns>
protected internal static Uri resolveUri(string baseURI, string path) {
if ( baseURI.Length > 0 ) {
XmlUrlResolver resolver = new XmlUrlResolver();
return resolver.ResolveUri( new Uri( baseURI ), path );
}
return new Uri( path );
}
示例5: 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);
}
}
示例6: 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();
}
}
示例7: 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;
}
示例8: LoadPart
private static void LoadPart(IBaseMessage msg, XPathNavigator node, string contextFile)
{
// don't care about the id because we can't set it anyway
string name = node.GetAttribute("Name", "");
string filename = node.GetAttribute("FileName", "");
string charset = node.GetAttribute("Charset", "");
string contentType = node.GetAttribute("ContentType", "");
bool isBody = XmlConvert.ToBoolean(node.GetAttribute("IsBodyPart", ""));
XmlResolver resolver = new XmlUrlResolver();
Uri realfile = resolver.ResolveUri(new Uri(contextFile), filename);
IBaseMessagePart part = CreatePartFromStream(File.OpenRead(realfile.LocalPath));
part.Charset = charset;
part.ContentType = contentType;
msg.AddPart(name, part, isBody);
}