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); }
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); }
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); }
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; }