hereon-mb/elm-rdf/2.0.0

Rdf.Dataset

This module defines the Dataset type which models an RDF dataset, and helper functions for building, updating, parsing, and serializing these. Take a look at the Rdf.Decode module if you want to extract Elm values from a Dataset.

type alias Dataset =
Dataset

This type represents an RDF dataset.

Build

empty : Dataset

Create an empty RDF dataset.

fromGraph : Graph -> Dataset

Create a dataset with default graph set to the provided graph and no other named graph.

insertNamedGraph : IsBlankNodeOrIri compatible -> Graph -> Dataset -> Dataset

Insert a named graph into a dataset. Replaces an already existing graph with that name.

fromQuads : List Quad -> Dataset

Convert a list of Quad's into a Dataset.

fromNQuads : String -> Result Error Dataset

Parse an N-Quads file and put all RDF quads into a Dataset. This function will keep blank node identifiers.

fromTrig : Seed -> String -> Result Error ( Dataset, Seed )

Parse a TriG file and put all RDF quads into a Dataset. This function will keep blank node identifiers and only mint new ones if they are not given in the original. For minting it uses the provided Seed. Make sure to reuse the returned Seed in subsequent calls to avoid blank node identifier collisions. You can use Rdf.initialSeed and Rdf.seedGenerator to get a seed.

fromTrigWith : Seed -> Iri -> String -> Result Error ( Dataset, Seed )

This is like fromTrig but you can also specify the initial base IRI.

type Error
= ErrorParser (List DeadEnd)
| MissingSubject
| MissingPredicate
| MissingBase
| CouldNotResolvePrefixedName String String

You get one of these if parsing fails.

errorToString : String -> Error -> String

Turn an Error into a more human friendly error message.

Query

defaultGraph : Dataset -> Graph

The dataset's default graph.

Dataset
-> List
{ name : BlankNodeOrIri
, graph : Graph
}

All dataset's named graphs.

decode : Decoder a -> Dataset -> Result Error a

Run a Decoder on a Dataset starting at the provided Node's. Make sure to anchor your decoder using from, fromSubject, or at. By default, decoding will be done on the default graph. Use helpers like inGraphs to change this behaviour

Export

toQuads : Dataset -> List Quad

Get a list of all Quad's in the Dataset.

toNQuads : Dataset -> String

Serialize a Dataset into the N-Quads format.

toTrig : Dataset -> String

Serialize a Dataset into the TriG format.