コード例 #1
0
ファイル: Viewer.cs プロジェクト: raosrinivasa/doap
		public void Load (string uri)
		{
			string txt = null;

			System.Uri u = new System.Uri (uri);
			Util.Debug ("Fetching file from " + uri);
			if (u.IsFile) {
				txt = Util.LoadFile (u.LocalPath);
			} else if (u.Scheme == System.Uri.UriSchemeHttp) {
				txt = Util.FetchUrl (uri);
			} else {
				throw new Exception
					("Unsupported URI scheme. Only file: and http: " +
					 "URIs understood.");
			}

			if (txt == null)
				throw new Exception ("No content found.");

			storage = new Storage ("memory", "data", null);
			model = new Model (storage);
			if (uri == null)
				uri = "file:///tmp/stdin";
			Redland.Uri baseuri = new Redland.Uri (uri);
			
			parser.ParseStringIntoModel (txt, baseuri, model);
		}
コード例 #2
0
ファイル: Validator.cs プロジェクト: xiaoxiongnpu/doap
        private ArrayList ValidateString(string str, string uri)
        {
            this.text = str;

            ArrayList results = RunXmlChecks(str);

            // if XML checks went OK, we can continue with the
            // RDF ones
            if (results.Count == 0)
            {
                storage = new Storage("memory", "data", null);
                model   = new Model(storage);
                if (uri == null)
                {
                    uri = "file:///tmp/stdin";
                }
                Redland.Uri baseuri = new Redland.Uri(uri);

                try {
                    parser.ParseStringIntoModel(str, baseuri, model);
                } catch (RedlandError r) {
                    foreach (LogMessage m in r.Messages)
                    {
                        results.Add(new Problem(
                                        new Tests.TestResult(Tests.Severity.Error),
                                        "RDF error",
                                        m.ToString(),
                                        r.Message, "ParseRDF"));
                    }
                } catch (Exception e) {
                    // TODO: add a won't-parse-as-RDF-error
                    Util.Error("Exception caught while parsing as RDF, but continuing anyway.");
                    Util.Error(e.ToString());
                }

                results.AddRange(RunRdfChecks());
            }

            return(results);
        }
コード例 #3
0
ファイル: Viewer.cs プロジェクト: xiaoxiongnpu/doap
        public void Load(string uri)
        {
            string txt = null;

            System.Uri u = new System.Uri(uri);
            Util.Debug("Fetching file from " + uri);
            if (u.IsFile)
            {
                txt = Util.LoadFile(u.LocalPath);
            }
            else if (u.Scheme == System.Uri.UriSchemeHttp)
            {
                txt = Util.FetchUrl(uri);
            }
            else
            {
                throw new Exception
                          ("Unsupported URI scheme. Only file: and http: " +
                          "URIs understood.");
            }

            if (txt == null)
            {
                throw new Exception("No content found.");
            }

            storage = new Storage("memory", "data", null);
            model   = new Model(storage);
            if (uri == null)
            {
                uri = "file:///tmp/stdin";
            }
            Redland.Uri baseuri = new Redland.Uri(uri);

            parser.ParseStringIntoModel(txt, baseuri, model);
        }
コード例 #4
0
ファイル: Validator.cs プロジェクト: B-Rich/doap
		private ArrayList ValidateString (string str, string uri)
		{
			this.text = str;

			ArrayList results = RunXmlChecks (str); 

			// if XML checks went OK, we can continue with the
			// RDF ones
			if (results.Count == 0) {
			
				storage = new Storage ("memory", "data", null);
				model = new Model (storage);
				if (uri == null)
					uri = "file:///tmp/stdin";
				Redland.Uri baseuri = new Redland.Uri (uri);

				try {
					parser.ParseStringIntoModel (str, baseuri, model);
				} catch (RedlandError r) {
					foreach (LogMessage m in r.Messages) {
						results.Add (new Problem (
									new Tests.TestResult (Tests.Severity.Error),
									"RDF error",
									m.ToString (),
									r.Message, "ParseRDF" ));
					}
				} catch (Exception e) {
					// TODO: add a won't-parse-as-RDF-error
					Util.Error ("Exception caught while parsing as RDF, but continuing anyway.");
					Util.Error (e.ToString ());
				}

				results.AddRange (RunRdfChecks ());
			}

			return results;
		}