How would you handle sparql xml directly when QueryWithResultSet is not working

Over the past year or so, I have used a bunch of custom code to interact with multiple endpoints SPARQL. I would rather not support it, so I learned how to use it dotnetrdf. The problem I have is that I encounter endpoints that I cannot work with. Here is an example: Endpoint http://id.ndl.go.jp/auth/ndla SPARQL Query::

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX xl: <http://www.w3.org/2008/05/skos-xl#>
SELECT ?subj WHERE { 
{?subj rdfs:label ?heading} UNION
{?subj xl:altLabel [ xl:literalForm ?heading]}
filter (?heading = "軍事基地.")
}

If you run this query as a query GET, it works:SPARQL QUERY

The problem with this dotnetrefis that I am trying to do the following:

SparqlRemoteEndpoint endpoint = new SparqlRemoteEndpoint(new Uri(@"http://id.ndl.go.jp/auth/ndla"));
endpoint.HttpMode = "GET";               
SparqlResultSet results = endpoint.QueryWithResultSet(textBox1.Text);                

POST - , HTML. , :

System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(@"http://id.ndl.go.jp/auth/ndla?query=PREFIX%20rdfs%3A%20%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%20%0APREFIX%20xl%3A%20%3Chttp%3A%2F%2Fwww.w3.org%2F2008%2F05%2Fskos-xl%23%3E%0ASELECT%20%3Fsubj%20WHERE%20%7B%20%0A%20%7B%3Fsubj%20rdfs%3Alabel%20%3Fheading%7D%20UNION%0A%20%7B%3Fsubj%20xl%3AaltLabel%20%5B%20xl%3AliteralForm%20%3Fheading%5D%7D%0A%20filter%20(%3Fheading%20%3D%20%22%E8%BB%8D%E4%BA%8B%E5%9F%BA%E5%9C%B0%22)%0A%20%7D");

System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();           
System.IO.Stream s = response.GetResponseStream();
System.IO.StreamReader reader = new System.IO.StreamReader(s);
string _s = reader.ReadToEnd();
reader.Close();
s.Close();

raw sparql xml, , dotnetrdf. , .

  • , . FullHTTPDebugging is how I can see that the HTTPMode` - . ( 2.0 preerelease 8 )
  • , , sparql xml , HttpWebResponse , SparqlResultSet.

, , , , , sparql xml , resultset.

+4

Source: https://habr.com/ru/post/1687928/


All Articles