swish-0.7.0.0: A semantic web toolkit.

PortabilityOverloadedStrings
Stabilityexperimental
MaintainerDouglas Burke
Safe HaskellSafe-Infered

Swish.QName

Description

This module defines an algebraic datatype for qualified names (QNames).

Synopsis

Documentation

data QName Source

A qualified name, consisting of a namespace URI and the local part of the identifier, which can be empty. The serialisation of a QName is formed by concatanating the two components.

 Prelude> :set prompt "swish> "
 swish> :set -XOverloadedStrings
 swish> :m + Swish.QName
 swish> let qn1 = "http://example.com/" :: QName
 swish> let qn2 = "http://example.com/bob" :: QName
 swish> let qn3 = "http://example.com/bob/fred" :: QName
 swish> let qn4 = "http://example.com/bob/fred#x" :: QName
 swish> map getLocalName [qn1, qn2, qn3, qn4]
 ["","bob","fred","x"]
 swish> getNamespace qn1
 http://example.com
 swish> getNamespace qn2
 http://example.com
 swish> getNamespace qn3
 http://example.com/bob/
 swish> getNamespace qn4
 http://example.com/bob/fred#

Instances

Eq QName

Equality is determined by a case sensitive comparison of the URI.

Ord QName

At present the ordering is based on a comparison of the Show instance of the URI.

Show QName

The format used to display the URI is <uri>.

IsString QName

This is not total since it will fail if the input string is not a valid URI.

FromRDFLabel QName

Converts from a Resource.

ToRDFLabel QName

Converts to a Resource.

data LName Source

A local name, which can be empty.

At present, the local name can not contain spaces or the '#', ':', or '/' characters. This restriction is experimental.

Instances

Eq LName 
Ord LName 
Show LName 
IsString LName

This is not total since attempting to convert a string containing invalid characters will cause an error.

emptyLName :: LNameSource

The empty local name.

newLName :: Text -> Maybe LNameSource

Create a local name.

getLName :: LName -> TextSource

Extract the local name.

newQNameSource

Arguments

:: URI

Namespace

-> LName

Local component

-> QName 

Create a new qualified name with an explicit local component.

qnameFromURISource

Arguments

:: URI

The URI will be deconstructed to find if it contains a local component.

-> Maybe QName

The failure case may be removed.

Create a new qualified name.

getNamespace :: QName -> URISource

Return the URI of the namespace stored in the QName. This does not contain the local component.

getLocalName :: QName -> LNameSource

Return the local component of the QName.

getQNameURI :: QName -> URISource

Returns the full URI of the QName (ie the combination of the namespace and local components).

qnameFromFilePath :: FilePath -> IO QNameSource

Convert a filepath to a file: URI stored in a QName. If the input file path is relative then the current working directory is used to convert it into an absolute path.

If the input represents a directory then it *must* end in the directory separator - so for Posix systems use "/foo/bar/" rather than "/foo/bar".

This has not been tested on Windows.