Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a standardized extension of SPARQL Query Results XML format #12

Closed
abrokenjester opened this issue Oct 13, 2020 · 1 comment
Closed
Labels
sparql-star About SPARQL-star

Comments

@abrokenjester
Copy link
Contributor

abrokenjester commented Oct 13, 2020

The result of a SPARQL SELECT query is serialized in XML using the SPARQL Query Results XML format. This format will need to be extended to deal with the RDF* triple being a new possible value type for a binding. For example, the result of a query where variable ?a is bound to an RDF* triple:

?a ?b ?c
<<<http://example.org/bob> <http://xmlns.com/foaf/0.1/age> 23>> <http://example.org/certainty> 0.9

Currently, different implementations all have their own, slightly diverging, extensions. For example, in Eclipse RDF4J, the extension looks as follows:

<?xml version='1.0' encoding='UTF-8'?>
<sparql xmlns='http://www.w3.org/2005/sparql-results#'>
	<head>
		<variable name='a'/>
		<variable name='b'/>
		<variable name='c'/>
	</head>
	<results>
		<result>
			<binding name='a'>
				<triple>
					<subject>
						<uri>http://example.org/bob</uri>
					</subject>
					<predicate>
						<uri>http://xmlns.com/foaf/0.1/age</uri>
					</predicate>
					<object>
						<literal datatype='http://www.w3.org/2001/XMLSchema#integer'>23</literal>
					</object>
				</triple>
			</binding>
			<binding name='b'>
				<uri>http://example.org/certainty</uri>
			</binding>
			<binding name='c'>
				<literal datatype='http://www.w3.org/2001/XMLSchema#decimal'>0.9</literal>
			</binding>
		</result>
	</results>
</sparql>

In Apache Jena, the extension is almost identical, except for the choice to name the middle element property (where RDF4J uses predicate):

<?xml version='1.0' encoding='UTF-8'?>
<sparql xmlns='http://www.w3.org/2005/sparql-results#'>
	<head>
		<variable name='a'/>
		<variable name='b'/>
		<variable name='c'/>
	</head>
	<results>
		<result>
			<binding name='a'>
				<triple>
					<subject>
						<uri>http://example.org/bob</uri>
					</subject>
					<property>
						<uri>http://xmlns.com/foaf/0.1/age</uri>
					</property>
					<object>
						<literal datatype='http://www.w3.org/2001/XMLSchema#integer'>23</literal>
					</object>
				</triple>
			</binding>
			<binding name='b'>
				<uri>http://example.org/certainty</uri>
			</binding>
			<binding name='c'>
				<literal datatype='http://www.w3.org/2001/XMLSchema#decimal'>0.9</literal>
			</binding>
		</result>
	</results>
</sparql>

In Stardog, the implemented extension currently looks as follows:

<?xml version='1.0' encoding='UTF-8'?>
<sparql xmlns='http://www.w3.org/2005/sparql-results#'>
	<head>
		<variable name='a'/>
		<variable name='b'/>
		<variable name='c'/>
	</head>
	<results>
		<result>
			<binding name='a'>
				<statement>
					<s>
						<uri>http://example.org/bob</uri>
					</s>
					<p>
						<uri>http://xmlns.com/foaf/0.1/age</uri>
					</p>
					<o>
						<literal datatype='http://www.w3.org/2001/XMLSchema#integer'>23</literal>
					</o>
				</statement>
			</binding>
			<binding name='b'>
				<uri>http://example.org/certainty</uri>
			</binding>
			<binding name='c'>
				<literal datatype='http://www.w3.org/2001/XMLSchema#decimal'>0.9</literal>
			</binding>
		</result>
	</results>
</sparql>

In summary, RDF4J, Jena and Stardog all differ in the element names used (triple vs statement, property vs predicate, subject vs s, etc).

Other implementations may have yet other, slightly deviant variants. This makes it difficult to process query results from different endpoint implementations. A single recommended extension would be a benefit for parser implementors and users alike.

@pchampin
Copy link
Collaborator

This was solved a while ago by #39

@pchampin pchampin removed the help wanted Extra attention is needed label Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sparql-star About SPARQL-star
Projects
None yet
Development

No branches or pull requests

2 participants