3.1 library(semweb/rdf11): The RDF database
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog Semantic Web Library 3.0
        • Two RDF APIs
          • library(semweb/rdf11): The RDF database
            • Query the RDF database
            • Enumerating and testing objects
            • RDF literals
            • Accessing RDF graphs
            • Modifying the RDF store
            • Accessing RDF collections
              • rdf_last/2
              • rdf_list/1
              • rdf_list/2
              • rdf_length/2
              • rdf_member/2
              • rdf_nth0/3
              • rdf_nth1/3
              • rdf_assert_list/2
              • rdf_assert_list/3
              • rdf_retract_list/1

3.1.6 Accessing RDF collections

The following predicates are utilities to access RDF 1.1 collections. A collection is a linked list created from rdf:first and rdf:next triples, ending in rdf:nil.

[det]rdf_last(+RDFList, -Last)
True when Last is the last element of RDFList. Note that if the last cell has multiple rdf:first triples, this predicate becomes nondet.
[semidet]rdf_list(?RDFTerm)
True if RDFTerm is a proper RDF list. This implies that every node in the list has an rdf:first and rdf:rest property and the list ends in rdf:nil.

If RDFTerm is unbound, RDFTerm is bound to each maximal RDF list. An RDF list is maximal if there is no triple rdf(_, rdf:rest, RDFList).

[det]rdf_list(+RDFList, -PrologList)
True when PrologList represents the rdf:first objects for all cells in RDFList. Note that this can be non-deterministic if cells have multiple rdf:first or rdf:rest triples.
[nondet]rdf_length(+RDFList, -Length:nonneg)
True when Length is the number of cells in RDFList. Note that a list cell may have multiple rdf:rest triples, which makes this predicate non-deterministic. This predicate does not check whether the list cells have associated values (rdf:first). The list must end in rdf:nil.
[nondet]rdf_member(?Member, +RDFList)
True when Member is a member of RDFList
[nondet]rdf_nth0(?Index, +RDFList, ?X)
[nondet]rdf_nth1(?Index, +RDFList, ?X)
True when X is the Index-th element (0-based or 1-based) of RDFList. This predicate is deterministic if Index is given and the list has no multiple rdf:first or rdf:rest values.
[det]rdf_assert_list(+PrologList, ?RDFList)
[det]rdf_assert_list(+PrologList, ?RDFList, +Graph)
Create an RDF list from the given Prolog List. PrologList must be a proper Prolog list and all members of the list must be acceptable as object for rdf_assert/3. If RDFList is unbound and PrologList is not empty, rdf_create_bnode/1 is used to create RDFList.
[det]rdf_retract_list(+RDFList)
Retract the rdf:first, rdf:rest and rdf:type=rdf:'List' triples from all nodes reachable through rdf:rest. Note that other triples that exist on the nodes are left untouched.