Did you know ... Search Documentation:
rdf_write.pl -- Write RDF/XML from a list of triples
PublicShow source

This module writes an RDF/XML document from a list of triples of the format rdf(Subject, Predicate, Object). It is primarily intended for communicating computed RDF model fragments to external programs using RDF/XML.

When used from the HTTP library, use the following code:

reply_graph(RDF) :-
        format('Content-type: application/rdf+xml; charset=UTF-8~n~n'),
        rdf_write_xml(current_output, RDF).
author
- Jan Wielemaker
See also
- library(semweb/rdf_db) offers saving a named graph directly from the RDF database.
Source rdf_write_xml(+Out:stream, +Triples:list(rdf(S,P,O))) is det
Write an RDF/XML serialization of Triples to Out.
Source rdf_write_header(+Out, +Triples)[private]
Save XML document header, doctype and open the RDF environment. This predicate also sets up the namespace notation.
Source xml_escape_parameter_entity(+In, -Out) is det[private]
Escape % as % for entity declarations.
Source used_namespaces(+Triples:list(rdf(S,P,O)), -List:atom) is det[private]
Return the list of namespace abbreviations used in a set of triples.
Source resources(+Triples:list(rdf(S,P,O)), -Resources:list(atom)) is det[private]
Resources is the set of resources referenced in Triples.
Source decl_used_predicate_ns(+Triples:list(rdf(S,P,O)))[private]
For every URL used as a predicate we MUST define a namespace as we cannot use names holding /, :, etc. as XML identifiers.
Source node_id_map(+Triples, -IdMap) is det[private]
Create an assoc Resource -> NodeID for those anonymous resources in Triples that need a NodeID. This implies all anonymous resources that are used multiple times as object value.
Source save_attributes(+List, +DefNS, +Out, +NodeIDs, Element, +Indent, +Anon)[private]
Save the attributes. Short literal attributes are saved in the tag. Others as the content of the description element. The begin tag has already been filled.
Source save_attribute(+Where, +Triple, +DefNS, +Out, +NodeIDs, +Indent, +Anon)[private]
Source rdf_p_id(+Resource, +DefNS, -NSLocal)[private]
As rdf_id/3 for predicate names. Maps _:<N> to rdf:li.
To be done
- Ensure we are talking about an rdf:Bag
Source is_bag_li_predicate(+Pred) is semidet[private]
True if Pred is _:N, as used for members of an rdf:Bag, rdf:Seq or rdf:Alt.
Source rdf_id(+Resource, +DefNS, -NSLocal)[private]
Generate a NS:Local name for Resource given the indicated default namespace. This call is used for elements.
Source rdf_write_id(+Out, +NSLocal) is det[private]
Write an identifier. We cannot use native write on it as both NS and Local can be operators.
Source rdf_att_id(+URI, +DefNS, -ID)[private]
Source rdf_value(+Resource, -Text, +Encoding)[private]
According to "6.4 RDF URI References" of the RDF Syntax specification, a URI reference is UNICODE string not containing control sequences, represented as UTF-8 and then as escaped US-ASCII.

NOTE: the to_be_described/1 trick ensures entity rewrite in resources that start with 'http://t-d-b.org?'. This is a of a hack to save the artchive data in the MultimediaN project. We should use a more general mechanism.