ResolveUri() private method

private ResolveUri ( Uri baseUri, string relativeUri ) : Uri
baseUri System.Uri
relativeUri string
return System.Uri
Esempio n. 1
0
		[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");
		}
Esempio n. 2
0
        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;
            }
        }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
        /// <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 );
        }
Esempio n. 5
0
		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);
			}
		}
Esempio n. 6
0
 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();
     }
 }
Esempio n. 7
0
 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;
 }
      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);
      }