Expanding Topics in SPARQL Query Results |
Top Previous Next |
In some cases it is desirable to retrieve more than just the URI address of a topic - for example labels and type are useful for display purposes and in some cases other topic properties can be useful too. In most cases it is advisable to add extra columns to the query to return just the specific properties, labels or identifiers of interest. However there are some cases where what the developer really needs is the one of the three Web3 topic representation structures in place of the topic URI. This is now supported through the SPARQL query interface as an in-place expansion of all URIs that refer to a topic into a representation of the referenced topic. Procedure To specify that expansion of topics references should take place, specify an additional query parameter with the name expandTopic and one of the following values:
The resulting SPARQL results set structure will contain the specified topic serialization as the value for any binding that is recognized as a Web3 topic web address instead of the normal URI binding.
For example, a query that returns the following SPARQL results XML with no expandTopic query parameter: <sparql xmlns="http://www.w3.org/2005/sparql-results#"> <head> <variable name="t"/> </head> <results> <result> <binding name="t"> <uri>http://localhost/web3/topicmaps/eab7e7e8-6fe9-402d-97c8-3a571b476189/topics/4d213ce8-7ef6-4dec-a286-d6b1f4cc306d</uri> </binding> </result> </results> </sparql>
Would return something like the following when expandTopic is set to ref:
<sparql xmlns="http://www.w3.org/2005/sparql-results#"> <head> <variable name="t"/> </head> <results> <result> <binding name="t"> <TopicRef Address="http://localhost/web3/topicmaps/eab7e7e8-6fe9-402d-97c8-3a571b476189/topics/4d213ce8-7ef6-4dec-a286-d6b1f4cc306d" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Labels> <Label Lang="en">Sample Topic</Label> </Labels> <Identifiers/> <Types> <Type Address="http://localhost/web3/topicmaps/eab7e7e8-6fe9-402d-97c8-3a571b476189/topics/e81a795e-6e49-4bea-be7f-4f282aba5da4"/> </Types> </TopicRef> </binding> </result> </results> </sparql>
Limitation and Cautions
|