3 Predicates for parsing RDF/XML
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog RDF parser
        • Predicates for parsing RDF/XML
          • load_rdf/2
          • load_rdf/3
          • RDF Object representation
          • Name spaces
          • Low-level access
Availability::- use_module(library(rdf)).(can be autoloaded)
Sourceload_rdf(+File, -Triples, +Options)
Read the RDF-XML file File and return a list of Triples. Options defines additional processing options. Currently defined options are:
base_uri(BaseURI)
If provided local identifiers and identifier-references are globalised using this URI. If omited or the atom [], local identifiers are not tagged.
blank_nodes(Mode)
If Mode is share (default), blank-node properties (i.e. complex properties without identifier) are reused if they result in exactly the same triple-set. Two descriptions are shared if their intermediate description is the same. This means they should produce the same set of triples in the same order. The value noshare creates a new resource for each blank node.
expand_foreach(Boolean)
If Boolean is true, expand rdf:aboutEach into a set of triples. By default the parser generates rdf(each(Container), Predicate, Subject).
lang(Lang)
Define the initial language (i.e. pretend there is an xml:lang declaration in an enclosing element).
ignore_lang(Bool)
If true, xml:lang declarations in the document are ignored. This is mostly for compatibility with older versions of this library that did not support language identifiers.
convert_typed_literal(:ConvertPred)
If the parser finds a literal with the rdf:datatype=Type attribute, call ConvertPred(+Type, +Content, -Literal). Content is the XML element contentas returned by the XML parser (a list). The predicate must unify Literal with a Prolog representation of Content according to Type or throw an exception if the conversion cannot be made.

This option servers two purposes. First of all it can be used to ignore type declarations for backward compatibility of this library. Second it can be used to convert typed literals to a meaningful Prolog representation. E.g. convert’42' to the Prolog integer 42 if the type is xsd:int or a related type.

namespaces(-List)
Unify List with a list of NS=URL for each encountered xmlns:NS=URL declaration found in the source.
entity(+Name, +Value)
Overrule entity declaration in file. As it is common practice to declare namespaces using entities in RDF/XML, this option allows for changing the namespace without changing the file. Multiple of these options are allowed.

The Triples list is a list of rdf(Subject, Predicate, Object) triples. Subject is either a plain resource (an atom), or one of the terms each(URI) or prefix(URI) with the obvious meaning. Predicate is either a plain atom for explicitely non-qualified names or a term NameSpace:Name. If NameSpace is the defined RDF name space it is returned as the atom rdf. Finally, Object is a URI, a Predicate or a term of the format literal(Value) for literal values. Value is either a plain atom or a parsed XML term (list of atoms and elements).