def rdf_from_sources(self, names, outputFormat = "pretty-xml", rdfOutput = False) :
"""
Extract and RDF graph from a list of RDFa sources and serialize them in one graph. The sources are parsed, the RDF
extracted, and serialization is done in the specified format.
@param names: list of sources, each can be a URI, a file name, or a file-like object
@keyword outputFormat: serialization format. Can be one of "turtle", "n3", "xml", "pretty-xml", "nt". "xml" and "pretty-xml", as well as "turtle" and "n3" are synonyms.
@return: a serialized RDF Graph
@rtype: string
"""
try :
from pyRdfaExtras import MyGraph
graph = MyGraph()
except :
graph = Graph()
for prefix in _bindings :
graph.bind(prefix,Namespace(_bindings[prefix]))
# the value of rdfOutput determines the reaction on exceptions...
for name in names :
self.graph_from_source(name, graph, rdfOutput)
return graph.serialize(format=outputFormat)
评论列表
文章目录