swish-0.10.0.9: A semantic web toolkit.
Copyright(c) 2003 Graham Klyne 2009 Vasili I Galchin 2011 2012 2013 2020 Douglas Burke
LicenseGPL V2
MaintainerDouglas Burke
Stabilityexperimental
PortabilityOverloadedStrings
Safe HaskellNone
LanguageHaskell2010

Swish.QName

Description

This module defines an algebraic datatype for qualified names (QNames), which represents a URI as the combination of a namespace URI and a local component (LName), which can be empty.

Although RDF supports using IRIs, the use of URI here precludes this, which means that, for instance, LName only accepts a subset of valid characters. There is currently no attempt to convert from an IRI into a URI.

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> let qn5 = "http://example.com/bob/fred:joe" :: QName
swish> map getLocalName [qn1, qn2, qn3, qn4, qn5]
["","bob","fred","x","fred:joe"]
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

Instances details
Eq QName Source #

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

Instance details

Defined in Swish.QName

Methods

(==) :: QName -> QName -> Bool #

(/=) :: QName -> QName -> Bool #

Ord QName Source #

In 0.8.0.0 the ordering now uses the ordering defined in Network.URI.Ord rather than the Show instance. This should make no difference unless a password was included in the URI when using basic access authorization.

Instance details

Defined in Swish.QName

Methods

compare :: QName -> QName -> Ordering #

(<) :: QName -> QName -> Bool #

(<=) :: QName -> QName -> Bool #

(>) :: QName -> QName -> Bool #

(>=) :: QName -> QName -> Bool #

max :: QName -> QName -> QName #

min :: QName -> QName -> QName #

Show QName Source #

The format used to display the URI is <uri>, and does not include the password if using basic access authorization.

Instance details

Defined in Swish.QName

Methods

showsPrec :: Int -> QName -> ShowS #

show :: QName -> String #

showList :: [QName] -> ShowS #

IsString QName Source #

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

Instance details

Defined in Swish.QName

Methods

fromString :: String -> QName #

FromRDFLabel QName Source #

Converts from a Resource.

Instance details

Defined in Swish.RDF.Graph

ToRDFLabel QName Source #

Converts to a Resource.

Instance details

Defined in Swish.RDF.Graph

data LName Source #

A local name, which can be empty.

At present, the local name can not contain a space character and can only contain ascii characters (those that match isAscii).

In version 0.9.0.3 and earlier, the following characters were not allowed in local names: '#', ':', or '/' characters.

This is all rather experimental.

Instances

Instances details
Eq LName Source # 
Instance details

Defined in Swish.QName

Methods

(==) :: LName -> LName -> Bool #

(/=) :: LName -> LName -> Bool #

Ord LName Source # 
Instance details

Defined in Swish.QName

Methods

compare :: LName -> LName -> Ordering #

(<) :: LName -> LName -> Bool #

(<=) :: LName -> LName -> Bool #

(>) :: LName -> LName -> Bool #

(>=) :: LName -> LName -> Bool #

max :: LName -> LName -> LName #

min :: LName -> LName -> LName #

Show LName Source # 
Instance details

Defined in Swish.QName

Methods

showsPrec :: Int -> LName -> ShowS #

show :: LName -> String #

showList :: [LName] -> ShowS #

IsString LName Source #

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

Instance details

Defined in Swish.QName

Methods

fromString :: String -> LName #

emptyLName :: LName Source #

The empty local name.

newLName :: Text -> Maybe LName Source #

Create a local name.

getLName :: LName -> Text Source #

Extract the local name.

newQName Source #

Arguments

:: URI

Namespace

-> LName

Local component

-> QName 

Create a new qualified name with an explicit local component.

qnameFromURI Source #

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 -> URI Source #

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

getLocalName :: QName -> LName Source #

Return the local component of the QName.

getQNameURI :: QName -> URI Source #

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

qnameFromFilePath :: FilePath -> IO QName Source #

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.