RDF.ex v0.4.0 RDF.IRI View Source
A structure for IRIs.
This structure just wraps a plain IRI string and doesn’t bother with the
components of the IRI, since in the context of RDF there are usually very many
IRIs and parsing them isn’t needed in most cases. For these reasons we don’t
use Elixirs built-in URI
structure, because it would be unnecessary
expensive in terms of performance and memory.
The component parts can always be retrieved with the RDF.IRI.parse/1
function, which returns Elixirs built-in URI
structure. Note, that URI
doesn’t escape Unicode characters by default, so it’s a suitable structure for
IRIs.
Link to this section Summary
Functions
Resolves a relative IRI against a base IRI
Checks if the given value is an absolute IRI
Merges two IRIs
Parses an IRI into its components and returns them as an URI
struct
Returns the scheme of the given IRI
Returns the given value unchanged if it’s a valid IRI, otherwise raises an exception
Checks if the given IRI is valid
Link to this section Types
Link to this section Functions
Resolves a relative IRI against a base IRI.
as specified in section 5.1 Establishing a Base URI of RFC3986. Only the basic algorithm in section 5.2 of RFC3986 is used; neither Syntax-Based Normalization nor Scheme-Based Normalization are performed.
Characters additionally allowed in IRI references are treated in the same way that unreserved characters are treated in URI references, per section 6.5 of RFC3987
Checks if the given value is an absolute IRI.
An absolute IRI is defined in RFC3987 containing a scheme along with a path and optional query and fragment segments.
Merges two IRIs.
This function merges two IRIs as per RFC 3986, section 5.2.
Creates a RDF.IRI
.
Creates a RDF.IRI
, but checks if the given IRI is valid.
If the given IRI is not valid a RDF.IRI.InvalidError
is raised.
see valid?/1
Parses an IRI into its components and returns them as an URI
struct.
Returns the scheme of the given IRI
If the given string is not a valid absolute IRI, nil
is returned.
Examples
iex> RDF.IRI.scheme("http://www.example.com/foo")
"http"
iex> RDF.IRI.scheme("not an iri")
nil
Returns the given value unchanged if it’s a valid IRI, otherwise raises an exception.
Examples
iex> RDF.IRI.valid!("http://www.example.com/foo")
"http://www.example.com/foo"
iex> RDF.IRI.valid!(RDF.IRI.new("http://www.example.com/foo"))
RDF.IRI.new("http://www.example.com/foo")
iex> RDF.IRI.valid!("not an iri")
** (RDF.IRI.InvalidError) Invalid IRI: "not an iri"