• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • CPACK
    • Home
    • List packs
    • Submit pack
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

SWI-Prolog RDF parser
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog RDF parser
        • Introduction
        • Parsing RDF in Prolog
        • Predicates for parsing RDF/XML
        • Writing RDF graphs
          • rdf_write_xml/2
        • Testing the RDF translator
        • Metrics

4 Writing RDF graphs

The library library(rdf_write) provides the inverse of load_rdf/2 using the predicate rdf_write_xml/2. In most cases the RDF parser is used in combination with the Semweb package providing library(semweb/rdf_db). This library defines rdf_save/2 to save a named RDF graph from the database to a file. This library writes a list of rdf terms to a stream. It has been developed for the SeRQL server which computes an RDF graph that needs to be transmitted in an HTTP request. As we see this as a typical use-case scenario the library only provides writing to a stream.

rdf_write_xml(+Stream, +Triples)
Write an RDF/XML document to Stream from the list of Triples. Stream must use one of the following Prolog stream encodings: ascii, iso_latin_1 or utf8. Characters that cannot be represented in the encoding are represented as XML entities. Using ASCII is a good idea for documents that can be represented almost completely in ASCII. For more international documents using UTF-8 creates a more compact document that is easier to read.
rdf_write(File, Triples) :-
        open(File, write, Out, [encoding(utf8)]),
        call_cleanup(rdf_write_xml(Out, Triples),
                     close(Out)).

ClioPatria (version V3.1.1-51-ga0b30a5)