View Source SPARQL.Query.Result.Format behaviour (SPARQL.ex v0.3.8)

A behaviour for SPARQL query result formats.

A SPARQL.Query.Result.Format for a format can be implemented like this

defmodule SomeFormat do
  use SPARQL.Query.Result.Format
  import RDF.Sigils

  @id         ~I<http://example.com/some_format>
  @name       :some_format
  @extension  "ext"
  @media_type "application/some-format"
end

When @id, @name, @extension and @media_type module attributes are defined the resp. behaviour functions are generated automatically and return these values.

Then you'll have to do the main work by implementing a RDF.Serialization.Encoder and a RDF.Serialization.Decoder for the format.

By default, it is assumed that these are defined in Encoder and Decoder modules under the module of the format, i.e. in the example above in SomeFormat.Encoder and SomeFormat.Decoder. If you want them in another module, you'll have to override the encoder/0 and/or decoder/0 functions in your SPARQL.Query.Result.Format module.

Link to this section Summary

Callbacks

The SPARQL.Query.Result.Format.Decoder module for the result format.

The SPARQL.Query.Result.Format.Encoder module for the result format.

The usual file extension for the SPARQL query result format.

An IRI of the SPARQL query result format.

The MIME type of the SPARQL query result format.

An name atom of the SPARQL query result format under which it can referenced.

A list of the supported query forms of the SPARQL query result format.

Link to this section Callbacks

@callback decoder() :: module()

The SPARQL.Query.Result.Format.Decoder module for the result format.

@callback encoder() :: module()

The SPARQL.Query.Result.Format.Encoder module for the result format.

@callback extension() :: binary()

The usual file extension for the SPARQL query result format.

@callback id() :: RDF.IRI.t()

An IRI of the SPARQL query result format.

@callback media_type() :: binary()

The MIME type of the SPARQL query result format.

@callback name() :: atom()

An name atom of the SPARQL query result format under which it can referenced.

@callback supported_query_forms() :: [SPARQL.Query.forms()]

A list of the supported query forms of the SPARQL query result format.