def generate_RDF_collection( graph, vals ) :
"""
Generate an RDF List from vals, returns the head of the list
@param graph: RDF graph
@type graph: RDFLib Graph
@param vals: array of RDF Resources
@return: head of the List (an RDF Resource)
"""
# generate an RDF List, returns the head
# list has all the elements in RDF format already
heads = [ BNode() for r in vals ] + [ ns_rdf["nil"] ]
for i in range(0, len(vals)) :
graph.add( (heads[i], ns_rdf["first"], vals[i]) )
graph.add( (heads[i], ns_rdf["rest"], heads[i+1]) )
return heads[0]
#################################################################################
评论列表
文章目录