AS.hs revision 437db42248d4e92184bf34417043a8fe891c751b
ca010363454de207082dfaa4b753531ce2a34551Christian Maeder{-# LANGUAGE DeriveDataTypeable #-}
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian MaederModule : $Header$
49fc18b4bb1d4a8d3ec05e0cffd5f0475b289592Christian MaederCopyright : (c) C. Maeder, Felix Gabriel Mance
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu ProdescuLicense : GPLv2 or higher, see LICENSE.txt
3f69b6948966979163bdfe8331c38833d5d90ecdChristian MaederMaintainer : Christian.Maeder@dfki.de
ca010363454de207082dfaa4b753531ce2a34551Christian MaederStability : provisional
49fc18b4bb1d4a8d3ec05e0cffd5f0475b289592Christian MaederPortability : portable
79d11c2e3ad242ebb241f5d4a5e98a674c0b986fChristian MaederOWL 2 Functional Syntax constructs
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder <http://www.w3.org/TR/2009/REC-owl2-syntax-20091027/#Functional-Style_Syntax>
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder <http://www.w3.org/TR/owl2-manchester-syntax/>
53301de22afd7190981b363b57c48df86fcb50f7Christian Maederimport Data.Char (intToDigit)
10b02b2343246df6773585636fe3ddbefa3b6a1bChristian Maederimport qualified Data.Map as Map
10b02b2343246df6773585636fe3ddbefa3b6a1bChristian Maederimport qualified Data.Set as Set
10b02b2343246df6773585636fe3ddbefa3b6a1bChristian Maederdata IRIType = Full | Abbreviated | NodeID
e68f45f355ed9d4026ee9baff5aa75aa7c911cc2Christian Maeder deriving (Show, Eq, Ord, Typeable, Data)
fc8c6570c7b4ee13f375eb607bed2290438573bfChristian Maeder{- | full or abbreviated IRIs with a possible uri for the prefix
83cc27e4ca7cf1a4bb5f4a8df17d3e6d44e6f1eaChristian Maeder or a local part following a hash sign -}
53301de22afd7190981b363b57c48df86fcb50f7Christian Maederdata QName = QN
028f19cdb09d52bb2fd207399b6fa874540d1670Christian Maeder { namePrefix :: String
53301de22afd7190981b363b57c48df86fcb50f7Christian Maeder -- ^ the name prefix part of a qualified name \"namePrefix:localPart\"
83cc27e4ca7cf1a4bb5f4a8df17d3e6d44e6f1eaChristian Maeder , localPart :: String
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maeder -- ^ the local part of a qualified name \"namePrefix:localPart\"
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maeder , iriType :: IRIType
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maeder , expandedIRI :: String
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maeder -- ^ the associated namespace uri (not printed)
fc8c6570c7b4ee13f375eb607bed2290438573bfChristian Maeder , iriPos :: Range
83cc27e4ca7cf1a4bb5f4a8df17d3e6d44e6f1eaChristian Maeder } deriving (Show, Typeable, Data)
72b9099aeec0762bae4546db3bc4b48721027bf4Christian Maederinstance Eq QName where
53301de22afd7190981b363b57c48df86fcb50f7Christian Maeder p == q = compare p q == EQ
49fc18b4bb1d4a8d3ec05e0cffd5f0475b289592Christian Maederinstance Ord QName where
53301de22afd7190981b363b57c48df86fcb50f7Christian Maeder compare (QN p1 l1 b1 n1 _) (QN p2 l2 b2 n2 _) =
53301de22afd7190981b363b57c48df86fcb50f7Christian Maeder if null n1 || null n2 then compare (b1, p1, l1) (b2, p2, l2) else
0a39036fa485579a7b7c81cdd44a412392571927Christian Maeder compare n1 n2 -- compare fully expanded names only
0a39036fa485579a7b7c81cdd44a412392571927Christian MaederqNameRange :: QName -> [Pos]
9c07aad044613547d61ab235665c08adcef03a1cChristian MaederqNameRange q = let Range rs = iriPos q in case rs of
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maeder p0 = if iriType q == Full then incSourceColumn p (-1) else p
962036a37b92afb04ac0725cde9f20e599c04c5fChristian Maeder in tokenRange $ Token (showQN q) $ Range [p0]
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maederinstance GetRange QName where
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder getRange = iriPos
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maeder rangeSpan = qNameRange
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaedershowQN :: QName -> String
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaedershowQN q = (if iriType q == Full then showQI else showQU) q
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder-- | show QName as abbreviated iri
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaedershowQU :: QName -> String
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaedershowQU (QN pre local _ _ _) =
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maeder if null pre then local else pre ++ ":" ++ local
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian Maeder-- | show QName in angle brackets as full iris
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian MaedershowQI :: QName -> String
1eb10c0c30323eed3cc21082fd242cd09a612dc5Christian MaedershowQI n = '<' : showQU n ++ ">"
1eb10c0c30323eed3cc21082fd242cd09a612dc5Christian MaedernullQName :: QName
1eb10c0c30323eed3cc21082fd242cd09a612dc5Christian MaedernullQName = QN "" "" Abbreviated "" nullRange
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian MaederisNullQName :: QName -> Bool
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian MaederisNullQName qn = case qn of
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian Maeder QN "" "" _ "" _ -> True
72b9099aeec0762bae4546db3bc4b48721027bf4Christian MaederunamedS :: String
72b9099aeec0762bae4546db3bc4b48721027bf4Christian MaederunamedS = "//www." ++ dnamedS
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian MaederdnamedS :: String
1eb10c0c30323eed3cc21082fd242cd09a612dc5Christian MaederdnamedS = "dfki.de/sks/hets/ontology/unamed"
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian MaederdummyQName :: QName
d591a82b32594f0992b27477cacb00b97226c9c8Christian MaederdummyQName = QN "http" unamedS Full ("http:" ++ unamedS) nullRange
d591a82b32594f0992b27477cacb00b97226c9c8Christian MaedermkQName :: String -> QName
c4d4df505f3ca488978629c65f4fd15a3ba2833aChristian MaedermkQName s = nullQName { localPart = s }
72b9099aeec0762bae4546db3bc4b48721027bf4Christian MaedersetQRange :: Range -> QName -> QName
72b9099aeec0762bae4546db3bc4b48721027bf4Christian MaedersetQRange r q = q { iriPos = r }
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian MaedersetPrefix :: String -> QName -> QName
d591a82b32594f0992b27477cacb00b97226c9c8Christian MaedersetPrefix s q = q { namePrefix = s }
6fc65e097da8013f5f4f96c8b343b9b48cd3d9e1Christian MaedersetFull :: QName -> QName
6fc65e097da8013f5f4f96c8b343b9b48cd3d9e1Christian MaedersetFull q = q {iriType = Full}
6fc65e097da8013f5f4f96c8b343b9b48cd3d9e1Christian Maedertype IRI = QName
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder-- | checks if an IRI is an anonymous individual
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaederisAnonymous :: IRI -> Bool
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaederisAnonymous iri = iriType iri == NodeID || namePrefix iri == "_"
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder-- | checks if a string (bound to be localPart of an IRI) contains \":\/\/\"
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaedercssIRI :: String -> IRIType
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaedercssIRI iri = if isInfixOf "://" iri then Full else Abbreviated
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder-- | prefix -> localname
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maedertype PrefixMap = Map.Map String String
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaederpredefPrefixes :: PrefixMap
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaederpredefPrefixes = Map.fromList
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder [ ("owl", "http://www.w3.org/2002/07/owl#")
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder , ("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
9c07aad044613547d61ab235665c08adcef03a1cChristian Maeder , ("rdfs", "http://www.w3.org/2000/01/rdf-schema#")
9c07aad044613547d61ab235665c08adcef03a1cChristian Maeder , ("xsd", "http://www.w3.org/2001/XMLSchema#")
9c07aad044613547d61ab235665c08adcef03a1cChristian Maeder , ("", showQU dummyQName ++ "#") ]
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maedertype LexicalForm = String
9c07aad044613547d61ab235665c08adcef03a1cChristian Maedertype LanguageTag = String
639732746d7c3a586790043b452a4cbdd29a3fc3Christian Maedertype ImportIRI = IRI
639732746d7c3a586790043b452a4cbdd29a3fc3Christian Maedertype OntologyIRI = IRI
639732746d7c3a586790043b452a4cbdd29a3fc3Christian Maedertype Class = IRI
639732746d7c3a586790043b452a4cbdd29a3fc3Christian Maedertype Datatype = IRI
639732746d7c3a586790043b452a4cbdd29a3fc3Christian Maedertype ObjectProperty = IRI
9c07aad044613547d61ab235665c08adcef03a1cChristian Maedertype DataProperty = IRI
9c07aad044613547d61ab235665c08adcef03a1cChristian Maedertype AnnotationProperty = IRI
9c07aad044613547d61ab235665c08adcef03a1cChristian Maedertype Individual = IRI
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian Maederdata EquivOrDisjoint = Equivalent | Disjoint
d591a82b32594f0992b27477cacb00b97226c9c8Christian Maeder deriving (Show, Eq, Ord, Typeable, Data)
d591a82b32594f0992b27477cacb00b97226c9c8Christian MaedershowEquivOrDisjoint :: EquivOrDisjoint -> String
9c07aad044613547d61ab235665c08adcef03a1cChristian MaedershowEquivOrDisjoint ed = case ed of
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder Equivalent -> equivalentToC
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder Disjoint -> disjointWithC
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maederdata DomainOrRange = ADomain | ARange
adfdcfa67b7f12df6df7292e238c3f9a4b637980Christian Maeder deriving (Show, Eq, Ord, Typeable, Data)
6e2c88c65d50b2e44f7afa165e6a5fac0724f08cChristian MaedershowDomainOrRange :: DomainOrRange -> String
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaedershowDomainOrRange dr = case dr of
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder ADomain -> domainC
7946f81bdc77b0790ac47ccaf2912a1d55c8336dChristian Maeder ARange -> rangeC
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maederdata SameOrDifferent = Same | Different
72b9099aeec0762bae4546db3bc4b48721027bf4Christian Maeder deriving (Show, Eq, Ord, Typeable, Data)
d27877901128f04518461d25b96d2d93a13f01e4Christian MaedershowSameOrDifferent :: SameOrDifferent -> String
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaedershowSameOrDifferent sd = case sd of
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder Same -> sameAsC
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder Different -> differentFromC
7946f81bdc77b0790ac47ccaf2912a1d55c8336dChristian Maederdata Relation =
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder EDRelation EquivOrDisjoint
72b9099aeec0762bae4546db3bc4b48721027bf4Christian Maeder | SubPropertyOf
72b9099aeec0762bae4546db3bc4b48721027bf4Christian Maeder | DRRelation DomainOrRange
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder | SDRelation SameOrDifferent
7946f81bdc77b0790ac47ccaf2912a1d55c8336dChristian Maeder deriving (Show, Eq, Ord, Typeable, Data)
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaedershowRelation :: Relation -> String
72b9099aeec0762bae4546db3bc4b48721027bf4Christian MaedershowRelation r = case r of
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder EDRelation ed -> showEquivOrDisjoint ed
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder SubPropertyOf -> subPropertyOfC
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder InverseOf -> inverseOfC
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder SubClass -> subClassOfC
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder Types -> typesC
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder DRRelation dr -> showDomainOrRange dr
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder SDRelation sd -> showSameOrDifferent sd
d27877901128f04518461d25b96d2d93a13f01e4Christian MaedergetED :: Relation -> EquivOrDisjoint
72b9099aeec0762bae4546db3bc4b48721027bf4Christian MaedergetED r = case r of
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder EDRelation ed -> ed
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder _ -> error "not domain or range"
72b9099aeec0762bae4546db3bc4b48721027bf4Christian MaedergetDR :: Relation -> DomainOrRange
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaedergetDR r = case r of
53301de22afd7190981b363b57c48df86fcb50f7Christian Maeder DRRelation dr -> dr
49fc18b4bb1d4a8d3ec05e0cffd5f0475b289592Christian Maeder _ -> error "not domain or range"
7946f81bdc77b0790ac47ccaf2912a1d55c8336dChristian MaedergetSD :: Relation -> SameOrDifferent
d27877901128f04518461d25b96d2d93a13f01e4Christian MaedergetSD s = case s of
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder SDRelation sd -> sd
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder _ -> error "not same or different"
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maederdata Character =
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder | InverseFunctional
7946f81bdc77b0790ac47ccaf2912a1d55c8336dChristian Maeder | Irreflexive
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder | Antisymmetric
53301de22afd7190981b363b57c48df86fcb50f7Christian Maeder deriving (Enum, Bounded, Show, Eq, Ord, Typeable, Data)
7946f81bdc77b0790ac47ccaf2912a1d55c8336dChristian Maederdata PositiveOrNegative = Positive | Negative
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder deriving (Show, Eq, Ord, Typeable, Data)
7946f81bdc77b0790ac47ccaf2912a1d55c8336dChristian Maederdata QuantifierType = AllValuesFrom | SomeValuesFrom
7946f81bdc77b0790ac47ccaf2912a1d55c8336dChristian Maeder deriving (Show, Eq, Ord, Typeable, Data)
d591a82b32594f0992b27477cacb00b97226c9c8Christian MaedershowQuantifierType :: QuantifierType -> String
d591a82b32594f0992b27477cacb00b97226c9c8Christian MaedershowQuantifierType ty = case ty of
669e21946b6f90785fc3cb44e7cf4f38c3f6493dChristian Maeder AllValuesFrom -> onlyS
7946f81bdc77b0790ac47ccaf2912a1d55c8336dChristian Maeder SomeValuesFrom -> someS
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder-- * Predefined IRI checkings
d27877901128f04518461d25b96d2d93a13f01e4Christian MaederthingMap :: PreDefMaps
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaederthingMap = makeOWLPredefMaps predefClass
7946f81bdc77b0790ac47ccaf2912a1d55c8336dChristian MaederisThing :: IRI -> Bool
7946f81bdc77b0790ac47ccaf2912a1d55c8336dChristian MaederisThing = checkPredef thingMap
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaedermakePredefObjProp :: PreDefMaps
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaedermakePredefObjProp = makeOWLPredefMaps predefObjProp
7946f81bdc77b0790ac47ccaf2912a1d55c8336dChristian MaederisPredefObjProp :: IRI -> Bool
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaederisPredefObjProp = checkPredef makePredefObjProp
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaedermakePredefDataProp :: PreDefMaps
7946f81bdc77b0790ac47ccaf2912a1d55c8336dChristian MaedermakePredefDataProp = makeOWLPredefMaps predefDataProp
669e21946b6f90785fc3cb44e7cf4f38c3f6493dChristian MaederisPredefDataProp :: IRI -> Bool
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill MossakowskiisPredefDataProp = checkPredef makePredefDataProp
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaedermakePredefRDFSAnnoProp :: PreDefMaps
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaedermakePredefRDFSAnnoProp = preDefMaps predefRDFSAnnoProps "rdfs"
962036a37b92afb04ac0725cde9f20e599c04c5fChristian MaederisPredefRDFSAnnoProp :: IRI -> Bool
962036a37b92afb04ac0725cde9f20e599c04c5fChristian MaederisPredefRDFSAnnoProp = checkPredef makePredefRDFSAnnoProp
72b9099aeec0762bae4546db3bc4b48721027bf4Christian MaedermakePredefOWLAnnoProp :: PreDefMaps
72b9099aeec0762bae4546db3bc4b48721027bf4Christian MaedermakePredefOWLAnnoProp = makeOWLPredefMaps predefOWLAnnoProps
09249711700a6acbc40a2e337688b434d7aafa28Christian MaederisPredefOWLAnnoProp :: IRI -> Bool
09249711700a6acbc40a2e337688b434d7aafa28Christian MaederisPredefOWLAnnoProp = checkPredef makePredefOWLAnnoProp
72b9099aeec0762bae4546db3bc4b48721027bf4Christian MaederisPredefAnnoProp :: IRI -> Bool
72b9099aeec0762bae4546db3bc4b48721027bf4Christian MaederisPredefAnnoProp iri = isPredefOWLAnnoProp iri || isPredefRDFSAnnoProp iri
9c07aad044613547d61ab235665c08adcef03a1cChristian MaederisPredefPropOrClass :: IRI -> Bool
72b9099aeec0762bae4546db3bc4b48721027bf4Christian MaederisPredefPropOrClass iri = isPredefAnnoProp iri || isPredefDataProp iri
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder || isPredefObjProp iri || isThing iri
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaederpredefIRIs :: Set.Set IRI
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaederpredefIRIs = Set.fromList $ map (setPrefix "xsd" . mkQName) xsdKeys
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder ++ map (setPrefix "owl" . mkQName) owlNumbers
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder ++ map (setPrefix "rdf" . mkQName) [rdfsLiteral, stringS]
add9c81ed5250ba046a8581ff75b2284bd69e219Christian Maeder ++ [setPrefix "rdfs" $ mkQName xmlLiteral]
dcb9ff0e2c2379735acce7073196508d455e0b01Christian MaederisDatatypeKey :: IRI -> Bool
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaederisDatatypeKey = not . null . isDatatypeKeyAux
46d766efdf8beaaadf3f34d99c305738064e9216Christian MaederxsdMap :: PreDefMaps
7946f81bdc77b0790ac47ccaf2912a1d55c8336dChristian MaederxsdMap = makeXsdMap xsdKeys
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaederowlNumbersMap :: PreDefMaps
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaederowlNumbersMap = makeOWLPredefMaps owlNumbers
b734b51e16ca659814c11205dfb0e97d13bf7ef6Christian MaederrdfMap :: PreDefMaps
b734b51e16ca659814c11205dfb0e97d13bf7ef6Christian MaederrdfMap = preDefMaps [xmlLiteral, stringS] "rdf"
b734b51e16ca659814c11205dfb0e97d13bf7ef6Christian MaederrdfsMap :: PreDefMaps
6fc65e097da8013f5f4f96c8b343b9b48cd3d9e1Christian MaederrdfsMap = preDefMaps [rdfsLiteral] "rdfs"
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaederisDatatypeKeyAux :: IRI -> [(String, String)]
add9c81ed5250ba046a8581ff75b2284bd69e219Christian MaederisDatatypeKeyAux iri = mapMaybe (`checkPredefAux` iri)
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder [ xsdMap, owlNumbersMap, rdfMap, rdfsMap ]
dcb9ff0e2c2379735acce7073196508d455e0b01Christian Maedertype PreDefMaps = ([String], String, String)
ad187062b0009820118c1b773a232e29b879a2faChristian MaederpreDefMaps :: [String] -> String -> PreDefMaps
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian MaederpreDefMaps sl pref = let
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder Just puri = Map.lookup pref predefPrefixes
4b8e74c68d62fc4e5a1739b11f8df09beaecbee8Christian Maeder Just sp = stripPrefix "http://www.w3.org/" puri
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maeder in (sl, pref, sp)
dcb9ff0e2c2379735acce7073196508d455e0b01Christian MaedercheckPredefAux :: PreDefMaps -> IRI -> Maybe (String, String)
13b24998210d193b38cae06485da6f06c61d7f62Christian MaedercheckPredefAux (sl, pref, exPref) u =
13b24998210d193b38cae06485da6f06c61d7f62Christian Maeder let lp = localPart u
13b24998210d193b38cae06485da6f06c61d7f62Christian Maeder nn = dnamedS ++ "#"
53301de22afd7190981b363b57c48df86fcb50f7Christian Maeder res = Just (pref, lp)
4561227a776bdf0ab679b19fb92f1eaaed8786f7Christian Maeder in case namePrefix u of
9c07aad044613547d61ab235665c08adcef03a1cChristian Maeder "http" -> case stripPrefix "//www." lp of
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maeder Just q -> case stripPrefix "w3.org/" q of
dcb9ff0e2c2379735acce7073196508d455e0b01Christian Maeder Just r -> case stripPrefix exPref r of
dcb9ff0e2c2379735acce7073196508d455e0b01Christian Maeder Just s | elem s sl -> Just (pref, s)
4561227a776bdf0ab679b19fb92f1eaaed8786f7Christian Maeder Nothing -> case stripPrefix nn q of
9c07aad044613547d61ab235665c08adcef03a1cChristian Maeder Just s | elem s sl -> Just (pref, s)
9c07aad044613547d61ab235665c08adcef03a1cChristian Maeder Nothing -> Nothing
9c07aad044613547d61ab235665c08adcef03a1cChristian Maeder pu | elem lp sl -> case pu of
dcb9ff0e2c2379735acce7073196508d455e0b01Christian Maeder "" -> let ex = expandedIRI u in
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maeder case stripPrefix "http://www." ex of
dcb9ff0e2c2379735acce7073196508d455e0b01Christian Maeder Just r | r == "w3.org/" ++ exPref ++ lp || r == nn ++ lp
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian Maeder _ | null ex -> res
4561227a776bdf0ab679b19fb92f1eaaed8786f7Christian Maeder _ | pu == pref -> Just (pref, lp)
59a2f25e7d71b91b4eda6fa4da753473ad629619Christian MaedercheckPredef :: PreDefMaps -> IRI -> Bool
ac142c1b088711f911018d8108a64be80b2f2a58Christian MaedercheckPredef ms = isJust . checkPredefAux ms
ac142c1b088711f911018d8108a64be80b2f2a58Christian MaedermakeOWLPredefMaps :: [String] -> PreDefMaps
f1ef1c750f805c1732b01001f2b157c0077b808eChristian MaedermakeOWLPredefMaps sl = preDefMaps sl "owl"
{- | returns the name of the predefined IRI (e.g <xsd:string> returns "string"
or <http://www.w3.org/2002/07/owl#real> returns "real") -}
$ Map.elems predefPrefixes of