RDFCollection[{e1,e2,…}]
represents a list-like collection of the ei in functions like RDFStore and SPARQLSelect.
RDFCollection
RDFCollection[{e1,e2,…}]
represents a list-like collection of the ei in functions like RDFStore and SPARQLSelect.
Details and Options
- The RDF collection vocabulary includes the following terms:
-
URL["http://www.w3.org/1999/02/22-rdf-syntax-ns#first"] links a collection to its first element URL["http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"] links a collection to its rest URL["http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"] the empty collection
Examples
open all close allBasic Examples (1)
Scope (2)
Needs["GraphStore`"]Specify an RDF graph containing a collection of letters:
rdf[s_] := URL["http://www.w3.org/1999/02/22-rdf-syntax-ns#" <> s];
ex[s_] := URL["http://example.org/" <> s];g = RDFStore[{
RDFTriple[ex["a"], ex["list"], RDFCollection[{"a", "b", "c"}]]
}];Check whether there is any collection that contains three elements:
g//SPARQLAsk[RDFTriple[SPARQLVariable["x"], SPARQLVariable["y"], RDFCollection[{SPARQLVariable["e1"], SPARQLVariable["e2"], SPARQLVariable["e3"]}]]]g//SPARQLSelect[RDFTriple[SPARQLVariable["x"], SPARQLVariable["y"], RDFCollection[{SPARQLVariable["e1"], SPARQLVariable["e2"], SPARQLVariable["e3"]}]] -> "e2"]g//SPARQLSelect[{
RDFTriple[ex["a"], ex["list"], SPARQLVariable["l"]],
SPARQLPropertyPath[SPARQLVariable["l"], {rdf["rest"]..., rdf["first"]}, SPARQLVariable["x"]]
} -> "x"]Needs["GraphStore`"]Specify an RDF graph in two different ways:
rdf[s_] := URL["http://www.w3.org/1999/02/22-rdf-syntax-ns#" <> s];
ex[s_] := URL["http://example.org/" <> s];g1 = RDFStore[{
RDFTriple[ex["a"], ex["list"], RDFCollection[{1, 2}]]
}];g2 = RDFStore[{
RDFTriple[ex["a"], ex["list"], RDFBlankNode["a"]],
RDFTriple[RDFBlankNode["a"], rdf["first"], 1],
RDFTriple[RDFBlankNode["a"], rdf["rest"], RDFBlankNode["b"]],
RDFTriple[RDFBlankNode["b"], rdf["first"], 2],
RDFTriple[RDFBlankNode["b"], rdf["rest"], rdf["nil"]]
}];The RDF graphs are isomorphic:
iso = SelectFirst[
AssociationThread[
Cases[First[g2], _RDFBlankNode, {2}],
#
]& /@ Permutations[Cases[First[g1], _RDFBlankNode, {2}]],
ContainsExactly[First[g1], First[g2] /. #]&
]ContainsExactly[First[g1], First[g2] /. iso]Possible Issues (1)
Needs["GraphStore`"]RDF has no built-in list datatype:
ex[s_] := URL["http://example.org/" <> s];ExportString[
RDFStore[{
RDFTriple[ex["a"], ex["numberList"], {1, 2}]
}],
"Turtle"
]Use an RDF collection instead:
ExportString[
RDFStore[{
RDFTriple[ex["a"], ex["numberList"], RDFCollection[{1, 2}]]
}],
"Turtle",
"Prefixes" -> <|"ex" -> "http://example.org/"|>
]Alternatively, choose a non-list-valued property and assign multiple values to it:
ExportString[
RDFStore[{
RDFTriple[ex["a"], ex["number"], 1],
RDFTriple[ex["a"], ex["number"], 2]
}],
"Turtle",
"Prefixes" -> <|"ex" -> "http://example.org/"|>
]See Also
Related Guides
Text
Wolfram Research (2019), RDFCollection, Wolfram Language function, https://reference.wolfram.com/language/GraphStore/ref/RDFCollection.html.
CMS
Wolfram Language. 2019. "RDFCollection." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/GraphStore/ref/RDFCollection.html.
APA
Wolfram Language. (2019). RDFCollection. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/GraphStore/ref/RDFCollection.html
BibTeX
@misc{reference.wolfram_2026_rdfcollection, author="Wolfram Research", title="{RDFCollection}", year="2019", howpublished="\url{https://reference.wolfram.com/language/GraphStore/ref/RDFCollection.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_rdfcollection, organization={Wolfram Research}, title={RDFCollection}, year={2019}, url={https://reference.wolfram.com/language/GraphStore/ref/RDFCollection.html}, note=[Accessed: 15-June-2026]}