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 |
Common.IRI
Description
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 CURIE [3].
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]: parseIRICurie
Additionally, classification of full, abbreviated and simple IRI is provided.
The abbreviated syntaxes [3] provide three different kinds of IRI.
References
- data IRI = IRI {
- iriScheme :: String
- iriAuthority :: Maybe IRIAuth
- iriPath :: Id
- iriQuery :: String
- iriFragment :: String
- prefixName :: String
- isAbbrev :: Bool
- isBlankNode :: Bool
- hasAngles :: Bool
- iriPos :: Range
- data IRIAuth = IRIAuth String String String
- nullIRI :: IRI
- iriToStringUnsecure :: IRI -> String
- iriToStringShortUnsecure :: IRI -> String
- hasFullIRI :: IRI -> Bool
- isSimple :: IRI -> Bool
- addSuffixToIRI :: String -> IRI -> IRI
- showTrace :: IRI -> String
- iriParser :: IRIParser st IRI
- angles :: IRIParser st IRI -> IRIParser st IRI
- iriCurie :: IRIParser st IRI
- compoundIriCurie :: 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
- isNullIRI :: IRI -> Bool
- iRIRange :: IRI -> [Pos]
- showIRI :: IRI -> String
- showIRICompact :: IRI -> String
- showIRIFull :: IRI -> String
- dummyIRI :: IRI
- mkIRI :: String -> IRI
- idToIRI :: Id -> IRI
- setPrefix :: String -> IRI -> IRI
- uriToCaslId :: IRI -> Id
Documentation
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:iriPath?iriQuery#iriFragment
or the simple IRI
iriPath
Constructors
IRI | |
Fields
|
Type for authority value within a IRI
Constructors
IRIAuth String String String |
iriToStringUnsecure :: IRI -> String Source #
converts IRI to String of expanded form. if available. Also showing Auth
iriToStringShortUnsecure :: IRI -> String Source #
converts IRI to String of abbreviated form. if available. Also showing Auth info.
hasFullIRI :: IRI -> Bool Source #
check that we have a full (possibly expanded) IRI (i.e. for comparisons)
isSimple :: IRI -> Bool Source #
check that we have a simple IRI that is a (possibly expanded) abbreviated IRI without prefix
addSuffixToIRI :: String -> IRI -> IRI Source #
Parsing
compoundIriCurie :: IRIParser st IRI Source #
parseCurie :: String -> Maybe IRI Source #
Turn a string containing a CURIE into an IRI
parseIRICurie :: String -> Maybe IRI Source #
Turn a string containing an IRI or a CURIE into an IRI
.
Returns Nothing
if the string is not a valid IRI;
(an absolute IRI enclosed in <
and >
with optional fragment identifier
or a CURIE).
parseIRIReference :: String -> Maybe IRI Source #
Parse a IRI reference to an IRI
value.
Returns Nothing
if the string is not a valid IRI reference.
(an absolute or relative IRI with optional fragment identifier).
parseIRI :: String -> Maybe IRI Source #
Turn a string containing an RFC3987 IRI into an IRI
.
Returns Nothing
if the string is not a valid IRI;
(an absolute IRI with optional fragment identifier).
ncname :: GenParser Char st String Source #
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 Source #
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 iriPath c
is not a valid IRI.
relativeFrom :: IRI -> IRI -> IRI Source #
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 Source #
Converts a Simple_ID to an IRI
deleteQuery :: IRI -> IRI Source #
methods from OWL2.AS
showIRICompact :: IRI -> String Source #
show IRI as abbreviated, when possible
showIRIFull :: IRI -> String Source #
show IRI in angle brackets as full IRI
uriToCaslId :: IRI -> Id Source #
Extracts Id from URI