swish-0.10.10.0: A semantic web toolkit.

Copyright | (c) 2003 Graham Klyne 2009 Vasili I Galchin 2011 2012 2014 Douglas Burke
License | GPL V2
Maintainer | Douglas Burke
Stability | experimental
Portability | CPP, OverloadedStrings
Safe Haskell | Safe-Inferred
Language | Haskell2010

Swish.Namespace

Description

This module defines algebraic datatypes for namespaces and scoped names.

For these purposes, a namespace is a prefix and URI used to identify a namespace (cf. XML namespaces), and a scoped name is a name that is scoped by a specified namespace.

Synopsis

- data Namespace
- makeNamespace :: Maybe Text -> URI -> Namespace
- makeNamespaceQName :: Namespace -> LName -> QName
- getNamespacePrefix :: Namespace -> Maybe Text
- getNamespaceURI :: Namespace -> URI
- getNamespaceTuple :: Namespace -> (Maybe Text, URI)
- data ScopedName
- getScopeNamespace :: ScopedName -> Namespace
- getScopeLocal :: ScopedName -> LName
- getScopePrefix :: ScopedName -> Maybe Text
- getScopeURI :: ScopedName -> URI
- getQName :: ScopedName -> QName
- getScopedNameURI :: ScopedName -> URI
- matchName :: String -> ScopedName -> Bool
- makeScopedName :: Maybe Text -> URI -> LName -> ScopedName
- makeQNameScopedName :: Maybe Text -> QName -> ScopedName
- makeURIScopedName :: URI -> ScopedName
- makeNSScopedName :: Namespace -> LName -> ScopedName
- nullScopedName :: ScopedName
- namespaceToBuilder :: Namespace -> Builder

# Documentation

data Namespace Source #

A NameSpace value consists of an optional prefix and a corresponding URI.

#### Instances

Instances details

Show Namespace Source # |
Instance details Defined in Swish.Namespace Methods showsPrec :: Int -> Namespace -> ShowS Source # show :: Namespace -> String Source # showList :: [Namespace] -> ShowS Source #
Eq Namespace Source # | Equality is defined by the URI, not by the prefix (so the same URI with different prefixes will be considered to be equal).
Instance details Defined in Swish.Namespace Methods (==) :: Namespace -> Namespace -> Bool Source # (/=) :: Namespace -> Namespace -> Bool Source #
Ord Namespace Source # |
Instance details Defined in Swish.Namespace Methods compare :: Namespace -> Namespace -> Ordering Source # (<) :: Namespace -> Namespace -> Bool Source # (<=) :: Namespace -> Namespace -> Bool Source # (>) :: Namespace -> Namespace -> Bool Source # (>=) :: Namespace -> Namespace -> Bool Source # max :: Namespace -> Namespace -> Namespace Source # min :: Namespace -> Namespace -> Namespace Source #

makeNamespace Source #

Arguments

:: Maybe Text | optional prefix.
-> URI | URI.
-> Namespace |

Create a name space from a URI and an optional prefix label.

makeNamespaceQName Source #

Arguments

:: Namespace | The name space URI is used in the qualified name
-> LName | local component of the qualified name (can be `emptyLName`)
-> QName |

Create a qualified name by combining the URI from the name space with a local component.

getNamespacePrefix :: Namespace -> Maybe Text Source #

Returns the prefix stored in the name space.

getNamespaceURI :: Namespace -> URI Source #

Returns the URI stored in the name space.

getNamespaceTuple :: Namespace -> (Maybe Text, URI) Source #

Convert the name space to a (prefix, URI) tuple.

data ScopedName Source #

A full ScopedName value has a QName prefix, namespace URI and a local part. ScopedName values may omit the prefix (see `Namespace`) or the local part.

Some applications may handle null namespace URIs as meaning the local part is relative to some base URI.

#### Instances

Instances details

IsString ScopedName Source # | This is not total since it will fail if the input string is not a valid `URI`.
Instance details Defined in Swish.Namespace Methods fromString :: String -> ScopedName Source #
Show ScopedName Source # | If there is a namespace associated then the Show instance uses `prefix:local`, otherwise `url`.
Instance details Defined in Swish.Namespace Methods showsPrec :: Int -> ScopedName -> ShowS Source # show :: ScopedName -> String Source # showList :: [ScopedName] -> ShowS Source #
Eq ScopedName Source # | Scoped names are equal if their corresponding `QName` values are equal.
Instance details Defined in Swish.Namespace Methods (==) :: ScopedName -> ScopedName -> Bool Source # (/=) :: ScopedName -> ScopedName -> Bool Source #
Ord ScopedName Source # | Scoped names are ordered by their `QName` components.

Instance details

Defined in Swish.Namespace

Methods

compare :: ScopedName -> ScopedName -> Ordering Source #

(<) :: ScopedName -> ScopedName -> Bool Source #

(<=) :: ScopedName -> ScopedName -> Bool Source #

(>) :: ScopedName -> ScopedName -> Bool Source #

(>=) :: ScopedName -> ScopedName -> Bool Source #

max :: ScopedName -> ScopedName -> ScopedName Source #

min :: ScopedName -> ScopedName -> ScopedName Source #

FromRDFLabel ScopedName Source # | Converts from a Resource.
Instance details Defined in Swish.RDF.Graph Methods fromRDFLabel :: RDFLabel -> Maybe ScopedName Source #
ToRDFLabel ScopedName Source # | Converts to a Resource.
Instance details Defined in Swish.RDF.Graph Methods toRDFLabel :: ScopedName -> RDFLabel Source #

getScopeNamespace :: ScopedName -> Namespace Source #

Returns the namespace.

getScopeLocal :: ScopedName -> LName Source #

Returns the local part.

getScopePrefix :: ScopedName -> Maybe Text Source #

Returns the prefix of the namespace, if set.

getScopeURI :: ScopedName -> URI Source #

Returns the URI of the namespace.

getQName :: ScopedName -> QName Source #

Get the QName corresponding to a scoped name.

getScopedNameURI :: ScopedName -> URI Source #

Get URI corresponding to a scoped name (using RDF conventions).

matchName :: String -> ScopedName -> Bool Source #

Test if supplied string matches the display form of a scoped name.

makeScopedName Source #

Arguments

:: Maybe Text | prefix for the namespace
-> URI | namespace
-> LName | local name
-> ScopedName |

Construct a ScopedName.

makeQNameScopedName Source #

Arguments

:: Maybe Text | prefix
-> QName |
-> ScopedName |

Construct a ScopedName from a QName.

makeURIScopedName :: URI -> ScopedName Source #

Construct a ScopedName for a bare URI (the label is set to "").

makeNSScopedName Source #

Arguments

:: Namespace | namespace
-> LName | local component
-> ScopedName |

Construct a ScopedName.

nullScopedName :: ScopedName Source #

This should never appear as a valid name

namespaceToBuilder :: Namespace -> Builder Source #

Utility routine to create a @prefix line (matching N3/Turtle) grammar for this namespace.