The above defined load_rdf/[2,3] is not always suitable. For example, it cannot deal with documents where the RDF statement is embedded in an XML document. It also cannot deal with really large documents (e.g. the Netscape OpenDirectory project, currently about 90 MBytes), without huge amounts of memory.
For really large documents, the sgml2pl parser can be
programmed to handle the content of a specific element (i.e.
element-by-element. The parsing primitives defined in this section can
be used to process these one-by-one.
- xml_to_rdf(+XML, +BaseURI, -Triples)
- Process an XML term produced by load_structure/3
dialect(xmlns)output option. XML is either a complete
<rdf:RDF>element, a list of RDF-objects (container or description) or a single description of container.
- process_rdf(+Input, :OnTriples, +Options)
Exploits the call-back interface of sgml2pl, calling
OnTriples(Triples, File:Line)with the list of triples resulting from a single top level RDF object for each RDF element in the input as well as the source-location where the description started. Input is either a file name or term
stream(Stream). When using a stream all triples are associated to the value of the
base_urioption. This predicate can be used to process arbitrary large RDF files as the file is processed object-by-object. The example below simply asserts all triples into the database:
assert_list(, _). assert_list([H|T], Source) :- assert(H), assert_list(T, Source). ?- process_rdf('structure,rdf', assert_list, ).
Options are described with load_rdf/3. The option
expand_foreachis not supported as the container may be in a different description. Additional it provides
- The predicate process_rdf/3
processes arbitrary XML documents, only interpreting the content of
rdf:RDFelements. If this option is
false(default), it gives a warning on elements that are not processed. The option
embedded(true)can be used to process RDF embedded in xhtml without warnings.