ralphtq/elm-rdf/1.0.0

Rdf.Core.CURIEs

Compact URI (CURIE) handling. A CURIE is the shortened prefix:localName form of an IRI when the prefix is bound to a namespace in the surrounding context.

Shortening

convertToCURIE : PrefixDictionary -> String -> String

Shorten an IRI to its CURIE form using the given prefix dictionary. Returns the original IRI unchanged if no matching prefix is bound.

convertToCURIE
    (Dict.fromList [ ( "rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#" ) ])
    "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
    == "rdf:type"

Parsing components out of an IRI

extractBaseUri : String -> Maybe String

Extract the base IRI (everything up to and including the final / or #) from an IRI.

extractBaseUri "http://example.org/foo/bar"
    == Just "http://example.org/foo/"
extractLocalName : String -> Maybe String

Extract the local name (the part after the final / or #) from an IRI.

extractLocalName "http://example.org/foo/bar"
    == Just "bar"