In order to apply a ShEx schema to your RDF data, you'll have to provide a so called ShapeMap, which is a set of associations of nodes to shapes of the schema to which they must conform to be valid.

You can create a ShapeMap with the ShEx.shape_map/1 function and provide the respective associations.

ShEx.shape_map(%{~I<> => ~I<>})

The start shape of a schema can referenced with the atom :start.

ShEx.shape_map(%{~I<> => :start})

When nodes and shape identifiers are given as native Elixir values they will be coerced to respective RDF terms. This also includes terms of an RDF vocabulary namespace.

ShEx.shape_map(%{"" => EX.Shape})

You can also feed in a ShapeMap in the ShapeMap language.

ShEx.ShapeMap.decode """
    <> @ <>,
    <> @ START

The ShapeMaps above were all fixed ShapeMaps, which specify the nodes directly. Query ShapeMaps allow to provide triple patterns to query the nodes which should conform a certain shape. A triple pattern in a ShEx ShapeMap is a triple with the atom :focus on subject or object position.

  {:focus, ~I<>, ~I<>} 
    => ~I<>,
  {~I<>, ~I<>, :focus} 
    => ~I<>

Additionally, the atom :_ can also be used on subject or object position as a wildcard.

  {:focus, ~I<>, :_}  => ~I<>,
  {:_, ~I<>, :focus}  => ~I<>

A query ShapeMap is implicitly converted to a fixed ShapeMap before a validation. You can also do this on your own with the ShEx.Shape.to_fixed/2 function.

ShapeMaps are also used for storing the results of a validation, which will be described in the next section.

You can always determine the type of a ShapeMap with the type field.

shape_map = ShEx.shape_map(%{{:focus, ~I<>, :_} => :start})
shape_map.type  # => :query

ShEx.ShapeMap implements the Enumerable protocol over the set of association, so you can use it with all of the Enum functions.