WOLFRAM

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

RDFCollection[{e1,e2,}]

represents a list-like collection of the ei in functions like RDFStore and SPARQLSelect .

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

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 all

Basic Examples  (1)

Wolfram Language code: Needs["GraphStore`"]

Specify a graph which lists the favorite fruits of Bob:

Wolfram Language code: ex[s_] := URL["http://example.org/" <> s];
Wolfram Language code: RDFStore[{ RDFTriple[ex["bob"], ex["favoriteFruits"], RDFCollection[{ex["mango"], ex["strawberry"]}]] }]

Scope  (2)

Wolfram Language code: Needs["GraphStore`"]

Specify an RDF graph containing a collection of letters:

Wolfram Language code: rdf[s_] := URL["http://www.w3.org/1999/02/22-rdf-syntax-ns#" <> s]; ex[s_] := URL["http://example.org/" <> s];
Wolfram Language code: g = RDFStore[{ RDFTriple[ex["a"], ex["list"], RDFCollection[{"a", "b", "c"}]] }];

Check whether there is any collection that contains three elements:

Wolfram Language code: g//SPARQLAsk[RDFTriple[SPARQLVariable["x"], SPARQLVariable["y"], RDFCollection[{SPARQLVariable["e1"], SPARQLVariable["e2"], SPARQLVariable["e3"]}]]]

Retrieve the middle element:

Wolfram Language code: g//SPARQLSelect[RDFTriple[SPARQLVariable["x"], SPARQLVariable["y"], RDFCollection[{SPARQLVariable["e1"], SPARQLVariable["e2"], SPARQLVariable["e3"]}]] -> "e2"]

Retrieve all elements:

Wolfram Language code: g//SPARQLSelect[{ RDFTriple[ex["a"], ex["list"], SPARQLVariable["l"]], SPARQLPropertyPath[SPARQLVariable["l"], {rdf["rest"]..., rdf["first"]}, SPARQLVariable["x"]] } -> "x"]
Wolfram Language code: Needs["GraphStore`"]

Specify an RDF graph in two different ways:

Wolfram Language code: rdf[s_] := URL["http://www.w3.org/1999/02/22-rdf-syntax-ns#" <> s]; ex[s_] := URL["http://example.org/" <> s];
Wolfram Language code: g1 = RDFStore[{ RDFTriple[ex["a"], ex["list"], RDFCollection[{1, 2}]] }];
Wolfram Language code: 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:

Wolfram Language code: iso = SelectFirst[ AssociationThread[ Cases[First[g2], _RDFBlankNode, {2}], # ]& /@ Permutations[Cases[First[g1], _RDFBlankNode, {2}]], ContainsExactly[First[g1], First[g2] /. #]& ]
Wolfram Language code: ContainsExactly[First[g1], First[g2] /. iso]

Possible Issues  (1)

Wolfram Language code: Needs["GraphStore`"]

RDF has no built-in list datatype:

Wolfram Language code: ex[s_] := URL["http://example.org/" <> s];
Wolfram Language code: ExportString[ RDFStore[{ RDFTriple[ex["a"], ex["numberList"], {1, 2}] }], "Turtle" ]

Use an RDF collection instead:

Wolfram Language code: 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:

Wolfram Language code: ExportString[ RDFStore[{ RDFTriple[ex["a"], ex["number"], 1], RDFTriple[ex["a"], ex["number"], 2] }], "Turtle", "Prefixes" -> <|"ex" -> "http://example.org/"|> ]

See Also

RDFStore   SPARQLSelect

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

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: 16-August-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: 16-August-2026]}

Top [フレーム]

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