Copyright | (c) DFKI GmbH 2012 |
---|---|
License | GPLv2 or higher, see LICENSE.txt |
Maintainer | Eugen Kuksa <eugenk@informatik.uni-bremen.de> |
Stability | provisional |
Portability | portable |
Safe Haskell | Safe-Inferred |
This module defines functions for handling IRIs. It was adopted from the Network.URI module by Graham Klyne, but is extended to IRI support [2] and even Manchester-Syntax-IRI [3], [4] and CURIE [5].
Four methods are provided for parsing different
kinds of IRI string (as noted in [1], [2]):
parseIRI
parseIRIReference
An additional method is provided for parsing an abbreviated IRI according to
[3], [4]: parseIRIManchester
and according to [5]: parseIRICurie
Additionally, classification of full, abbreviated and simple IRI is provided.
The abbreviated syntaxes [3], [4], [5] provide three different kinds of IRI.
References
- data IRI = IRI {
- iriScheme :: String
- iriAuthority :: Maybe IRIAuth
- iriPath :: String
- iriQuery :: String
- iriFragment :: String
- prefixName :: String
- abbrevPath :: String
- abbrevQuery :: String
- abbrevFragment :: String
- hasAngles :: Bool
- iriPos :: Range
- data IRIAuth = IRIAuth String String String
- data PNameLn = PNameLn PNameNs PnLocal
- nullIRI :: IRI
- iriToStringUnsecure :: IRI -> String
- iriToStringShortUnsecure :: IRI -> String
- hasFullIRI :: IRI -> Bool
- isAbbrev :: IRI -> Bool
- isSimple :: IRI -> Bool
- iriManchester :: IRIParser st IRI
- parseIRIManchester :: String -> Maybe IRI
- iriCurie :: IRIParser st IRI
- parseCurie :: String -> Maybe IRI
- parseIRICurie :: String -> Maybe IRI
- parseIRIReference :: String -> Maybe IRI
- parseIRI :: String -> Maybe IRI
- ncname :: GenParser Char st String
- expandCurie :: Map String IRI -> IRI -> Maybe IRI
- relativeTo :: IRI -> IRI -> Maybe IRI
- relativeFrom :: IRI -> IRI -> IRI
- simpleIdToIRI :: SIMPLE_ID -> IRI
- deleteQuery :: IRI -> IRI
- setAngles :: Bool -> IRI -> IRI
Documentation
data IRI
Represents a general universal resource identifier using its component parts.
For example, for the (full) IRI
foo://anonymous@www.haskell.org:42/ghc?query#frag
or the abbreviated IRI
prefix:abbrevPath?abbrevQuery#abbrevFragment
or the simple IRI
abbrevPath
IRI | |
|
data IRIAuth
Type for authority value within a IRI
iriToStringUnsecure :: IRI -> String
converts IRI to String of expanded form. if available. Also showing Auth
iriToStringShortUnsecure :: IRI -> String
converts IRI to String of abbreviated form. if available. Also showing Auth info.
hasFullIRI :: IRI -> Bool
do we have a full (possibly expanded) IRI (i.e. for comparisons)
do we have a simple IRI that is a (possibly expanded) abbreviated IRI without prefix
Parsing
iriManchester :: IRIParser st IRI
parseIRIManchester :: String -> Maybe IRI
parseCurie :: String -> Maybe IRI
Turn a string containing a CURIE into an IRI
parseIRICurie :: String -> Maybe IRI
parseIRIReference :: String -> Maybe IRI
ncname :: GenParser Char st String
Prefix part of CURIE in prefix_part:reference
http://www.w3.org/TR/2009/REC-xml-names-20091208/#NT-NCName
expandCurie :: Map String IRI -> IRI -> Maybe IRI
Expands a CURIE to an IRI. Nothing
iff there is no IRI i
assigned
to the prefix of c
or the concatenation of i
and abbrevPath c
is not a valid IRI.
relativeTo :: IRI -> IRI -> Maybe IRI
relativeFrom :: IRI -> IRI -> IRI
Returns a new IRI
which represents the relative location of
the first IRI
with respect to the second IRI
. Thus, the
values supplied are expected to be absolute IRIs, and the result
returned may be a relative IRI.
Example:
"http://example.com/Root/sub1/name2#frag" `relativeFrom` "http://example.com/Root/sub2/name2#frag" == "../sub1/name2#frag"
There is no single correct implementation of this function, but any acceptable implementation must satisfy the following:
(uabs `relativeFrom` ubase) `relativeTo` ubase == uabs
For any valid absolute IRI. (cf. http://lists.w3.org/Archives/Public/iri/2003Jan/0008.html http://lists.w3.org/Archives/Public/iri/2003Jan/0005.html)
Conversion
simpleIdToIRI :: SIMPLE_ID -> IRI
Converts a Simple_ID to an IRI
deleteQuery :: IRI -> IRI