WOLFRAM

Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how
Wolfram Language & System Documentation Center

SPARQLVariable["var"]

represents a variable with label "var" in a SPARQL query.

Details and Options
Details and Options Details and Options
Examples  
Basic Examples  
Possible Issues  
See Also
Related Guides
Cite this Page

SPARQLVariable["var"]

represents a variable with label "var" in a SPARQL query.

Details and Options

  • SPARQLVariable["x"] is used in SPARQL graph patterns and expressions to distinguish a variable with label "x" from a string literal "x".
  • The SPARQLVariable wrapper is optional in places where only variables can appear.
  • A SPARQLVariable can appear in any position of an RDFTriple .
  • An RDFTriple that contains a SPARQLVariable is also known as a triple pattern.

Examples

open all close all

Basic Examples  (1)

Wolfram Language code: Needs["GraphStore`"]

Given an RDFStore about people:

Wolfram Language code: store = GraphStore`RDFStore[{GraphStore`RDFTriple[URL["http://example.org/sophia"], URL["http://xmlns.com/foaf/0.1/firstName"], "Sophia"], GraphStore`RDFTriple[URL["http://example.org/sophia"], URL["http://xmlns.com/foaf/0.1/lastName"], "Rodríguez"]}, Association[]];

Query all persons together with their first name:

Wolfram Language code: foaf[s_] := URL["http://xmlns.com/foaf/0.1/" <> s];
Wolfram Language code: store//SPARQLSelect[{ RDFTriple[SPARQLVariable["person"], foaf["firstName"], SPARQLVariable["first"]] }]

Get the first and last name:

Wolfram Language code: store//SPARQLSelect[{ RDFTriple[SPARQLVariable["person"], foaf["firstName"], SPARQLVariable["first"]], RDFTriple[SPARQLVariable["person"], foaf["firstName"], SPARQLVariable["last"]] }]

Possible Issues  (1)

Wolfram Language code: Needs["GraphStore`"]

Given an RDFStore about people:

Wolfram Language code: store = GraphStore`RDFStore[{GraphStore`RDFTriple[URL["http://example.org/sophia"], URL["http://xmlns.com/foaf/0.1/firstName"], "Sophia"], GraphStore`RDFTriple[URL["http://example.org/sophia"], URL["http://xmlns.com/foaf/0.1/lastName"], "Rodríguez"]}, Association[]];

Define a pattern that matches the first and last name:

Wolfram Language code: foaf[s_] := URL["http://xmlns.com/foaf/0.1/" <> s];
Wolfram Language code: firstLastPatt = { RDFTriple[SPARQLVariable["person"], foaf["firstName"], SPARQLVariable["first"]], RDFTriple[SPARQLVariable["person"], foaf["lastName"], SPARQLVariable["last"]] };

The strings "first" and "last" in the "concat" function are interpreted as literals:

Wolfram Language code: store//SPARQLSelect[firstLastPatt -> { "name" -> SPARQLEvaluation["concat"]["first", " ", "last"] }]

To refer to the variables use the SPARQLVariable wrapper:

Wolfram Language code: store//SPARQLSelect[firstLastPatt -> { "name" -> SPARQLEvaluation["concat"][SPARQLVariable["first"], " ", SPARQLVariable["last"]] }]
Wolfram Research (2019), SPARQLVariable, Wolfram Language function, https://reference.wolfram.com/language/GraphStore/ref/SPARQLVariable.html.

Text

Wolfram Research (2019), SPARQLVariable, Wolfram Language function, https://reference.wolfram.com/language/GraphStore/ref/SPARQLVariable.html.

CMS

Wolfram Language. 2019. "SPARQLVariable." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/GraphStore/ref/SPARQLVariable.html.

APA

Wolfram Language. (2019). SPARQLVariable. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/GraphStore/ref/SPARQLVariable.html

BibTeX

@misc{reference.wolfram_2026_sparqlvariable, author="Wolfram Research", title="{SPARQLVariable}", year="2019", howpublished="\url{https://reference.wolfram.com/language/GraphStore/ref/SPARQLVariable.html}", note=[Accessed: 19-August-2026]}

BibLaTeX

@online{reference.wolfram_2026_sparqlvariable, organization={Wolfram Research}, title={SPARQLVariable}, year={2019}, url={https://reference.wolfram.com/language/GraphStore/ref/SPARQLVariable.html}, note=[Accessed: 19-August-2026]}

Top [フレーム]

AltStyle によって変換されたページ (->オリジナル) /