Exemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            String uri = context.Request.QueryString["uri"];
            if (uri == null)
            {
                context.Response.Write("Bad request");
            }
            else
            {
                //Load the Graph from that URI
                Graph g = new Graph();
                try
                {
                    UriLoader.Load(g, new Uri(uri));
                }
                catch (Exception)
                {
                    //Supress the exception
                    //TODO: Show an error message to the end user
                }

                //Write out as a HTML page
                HtmlWriter writer = new HtmlWriter();
                writer.Stylesheet = "../sparql.css";
                writer.UriPrefix = "?uri=";

                context.Response.ContentType = "text/html";
                writer.Save(g, context.Response.Output);
            }
        }
Exemplo n.º 2
0
        public void WritingHtmlWriter()
        {
            Graph g = new Graph();
            FileLoader.Load(g, "InferenceTest.ttl");

            HtmlWriter writer = new HtmlWriter();
            String data = StringWriter.Write(g, writer);

            Console.WriteLine("Serialized as XHTML+RDFa");
            Console.WriteLine(data);

            Console.WriteLine();

            Graph h = new Graph();
            h.BaseUri = new Uri("http://example.org");
            StringParser.Parse(h, data, new RdfAParser());

            Console.WriteLine("Extracted Triples");
            foreach (Triple t in h.Triples)
            {
                Console.WriteLine(t.ToString());
            }

            Assert.AreEqual(g, h, "Graphs should have been the same");
        }
Exemplo n.º 3
0
        private void cboGraphFormat_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (this.cboGraphFormat.SelectedIndex)
            {
                case 0:
                    this._rdfwriter = new CsvWriter();
                    this._rdfext = ".csv";
                    break;
                case 1:
                    fclsStylesheetPicker stylesheetPicker = new fclsStylesheetPicker("CSS (Optional)");
                    if (stylesheetPicker.ShowDialog() == DialogResult.OK)
                    {
                        HtmlWriter temp = new HtmlWriter();
                        temp.Stylesheet = stylesheetPicker.StylesheetUri;
                        this._rdfwriter = temp;
                    }
                    else
                    {
                        this._rdfwriter = new HtmlWriter();
                    }
                    this._rdfext = ".html";
                    break;
                case 2:
                    this._rdfwriter = new Notation3Writer();
                    this._rdfext = ".n3";
                    break;
                case 3:
                    this._rdfwriter = new NTriplesWriter();
                    this._rdfext = ".nt";
                    break;
                case 4:
                    this._rdfwriter = new RdfJsonWriter();
                    this._rdfext = ".json";
                    break;
                case 5:
                    this._rdfwriter = new RdfXmlWriter();
                    this._rdfext = ".rdf";
                    break;
                case 6:
                    this._rdfwriter = new CompressingTurtleWriter();
                    this._rdfext = ".ttl";
                    break;
                case 7:
                    this._rdfwriter = new TsvWriter();
                    this._rdfext = ".tsv";
                    break;
            }

            if (this._rdfwriter is ICompressingWriter)
            {
                ((ICompressingWriter)this._rdfwriter).CompressionLevel = WriterCompressionLevel.High;
            }

            if (this.cboResultsFormat.SelectedIndex == 1)
            {
                this._resultswriter = new SparqlRdfWriter(this._rdfwriter);
                this._resultsext = this._rdfext;
            }
        }