Skip to content

Webpage and service call

architolk edited this page Nov 28, 2016 · 1 revision

You specify how the Linked Data Theatre retrieves the data. One way is to include data from a webpage or service call.

stage:service a elmo:Representation;
	elmo:url-pattern "/query/service$";
	elmo:service "http://localhost:8080/query/ContentAppearance?format=json";
.

This example calls the JSON-LD webservice at the location specified. As you might notice, this is actually a page of the theatre itself. A more common situation is to call some external webservice. This webservice should return some JSON-LD. A regular JSON response won't work.

Another option is to retrieve data from a webpage. The difference with a service call is that any valid serialization is possible (json-ld, turtle, rdfa, whatever. So you could actually call a html webpagina, as long as it contains some linked data.

stage:webpage a elmo:Representation;
	elmo:url-pattern "/query/webpage$";
	elmo:appearance elmo:VocabularyAppearance;
	elmo:webpage "http://www.w3.org/2000/01/rdf-schema";
.

The example above will retrieve the rdfs vocabulary, and displays the result using the vocabulary appearance. The example above is actually a very nice way to display any vocabulary that is made available as linked data on the web.

The final option is to use a service call to retrieve some information, and use the information again within a regular sparql query.

stage:service2 a elmo:Representation;
	elmo:service "http://somesite/api/geo?long=@LONG@&lat=@LAT@";
	elmo:fragment [
		elmo:name "item";
		elmo:path "/results/result[1]/uri"
	];
	elmo:query '''
		CONSTRUCT {<@ITEM@> ?p ?o}
		WHERE {<@ITEM@> ?p ?o}
	''';
.

This example calls a geo-function at somesite. You notice that it is possible to include parameters in the servicecall as well (@LONG@ and @LAT@). The elmo:fragment is used to define what should be done with the result. The elmo:path contains the xpath expression to a particular value, and the elmo:name defines the name of the parameter. This parameter (@ITEM@) is used in the "regular" sparql query.

All examples above used a http-GET call to the particular service. In some cases, an http-POST is needed, with the parameters contained in the body of the request. This can be done by using a elmo:body statement:

Clone this wiki locally