AS.hs revision 097bc9f18b722812d480df0f5c634d09cbca8e21
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder{-# LANGUAGE DeriveDataTypeable #-}
81d182b21020b815887e9057959228546cf61b6bChristian MaederModule : $Header$
62ecb1e7f8fd9573eea8369657de12c7bf9f4f25Christian MaederCopyright : (c) Heng Jiang, Uni Bremen 2004-2007
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian MaederLicense : GPLv2 or higher, see LICENSE.txt
3f69b6948966979163bdfe8331c38833d5d90ecdChristian MaederMaintainer : Christian.Maeder@dfki.de
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian MaederStability : provisional
fbb66ee3e170624835b99f7aa91980753cb5b472Christian MaederPortability : non-portable(deriving Typeable)
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian MaederThis module defines all the data types for the functional style Syntax
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian MaederIt is modeled after the W3C document:
0ea85310d2beb8aa03cac481ad2a6564e6b8ddbcChristian Maeder<http://www.w3.org/TR/2009/REC-owl2-syntax-20091027/#Functional-Style_Syntax>
0ea85310d2beb8aa03cac481ad2a6564e6b8ddbcChristian Maederimport Common.Id (GetRange)
ee9eddfa6953868fd6fbaff0d9ff68675a13675aChristian Maederimport qualified Data.Map as Map
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder{- | full or abbreviated IRIs with a possible uri for the prefix
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder or a local part following a hash sign -}
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maederdata QName = QN
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder { namePrefix :: String
ee9eddfa6953868fd6fbaff0d9ff68675a13675aChristian Maeder -- ^ the name prefix part of a qualified name \"namePrefix:localPart\"
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder , localPart :: String
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder -- ^ the local part of a qualified name \"namePrefix:localPart\"
33a5d53a412ba0a4e5847f7538d6da2e22bd116cChristian Maeder , isFullIri :: Bool
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder , namespaceUri :: String
e774ab5733a1d673b123b0e63b14dd533e6fd4fcChristian Maeder -- ^ the associated namespace uri (not printed)
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder } deriving (Typeable, Show)
6e39bfd041946fce4982ac89834be73fd1bfb39aChristian MaedershowQN :: QName -> String
62ecb1e7f8fd9573eea8369657de12c7bf9f4f25Christian MaedershowQN q = (if isFullIri q then showQI else showQU) q
2bf209888545860dc77b9c3f2198d00eeab30d20Christian Maeder-- | show QName as abbreviated iri
b645cf3dc1e449038ed291bbd11fcc6e02b2fc7fChristian MaedershowQU :: QName -> String
715ffaf874309df081d1e1cd8e05073fc1227729Christian MaedershowQU (QN pre local _ _) =
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder if null pre then local else pre ++ ":" ++ local
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder-- | show QName in ankle brackets as full iris
715ffaf874309df081d1e1cd8e05073fc1227729Christian MaedershowQI :: QName -> String
2bf209888545860dc77b9c3f2198d00eeab30d20Christian MaedershowQI = ('<' :) . (++ ">") . showQU
715ffaf874309df081d1e1cd8e05073fc1227729Christian MaedernullQName :: QName
715ffaf874309df081d1e1cd8e05073fc1227729Christian MaedernullQName = QN "" "" False ""
715ffaf874309df081d1e1cd8e05073fc1227729Christian MaederdummyQName :: QName
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian MaederdummyQName = QN "http" "//www.dfki.de/sks/hets/ontology/unamed" True ""
715ffaf874309df081d1e1cd8e05073fc1227729Christian MaedermkQName :: String -> QName
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian MaedermkQName s = nullQName { localPart = s }
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maederinstance Eq QName where
0ea85310d2beb8aa03cac481ad2a6564e6b8ddbcChristian Maeder p == q = compare p q == EQ
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maederinstance Ord QName where
e9490701e16d1e8abd995ef876d6f937da93b412Christian Maeder compare (QN p1 l1 b1 n1) (QN p2 l2 b2 n2) =
2bf209888545860dc77b9c3f2198d00eeab30d20Christian Maeder if null n1 then
c44c23429c72f3a709e22a18f2ed6f05fc8cc765Christian Maeder if null n2 then compare (b1, p1, l1) (b2, p2, l2) else LT
ccf3de3d66b521a260e5c22d335c64a48e3f0195Christian Maeder else if null n2 then GT else compare (b1, l1, n1) (b2, l2, n2)
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maedertype IRIreference = QName
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maedertype IRI = QName
2bf209888545860dc77b9c3f2198d00eeab30d20Christian Maeder-- | prefix -> localname
2bf209888545860dc77b9c3f2198d00eeab30d20Christian Maedertype PrefixMap = Map.Map String String
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maedertype NodeID = String
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maedertype LexicalForm = String
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maedertype LanguageTag = String
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maedertype PrefixName = String
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maedertype ImportIRI = IRI
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maedertype OntologyIRI = IRI
961fc5d08256957f68f245f2723085ced14a0a1fChristian Maedertype Class = IRI
961fc5d08256957f68f245f2723085ced14a0a1fChristian Maedertype Datatype = IRI
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maedertype ObjectProperty = IRI
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maedertype DataProperty = IRI
961fc5d08256957f68f245f2723085ced14a0a1fChristian Maedertype AnnotationProperty = IRI
961fc5d08256957f68f245f2723085ced14a0a1fChristian Maedertype NamedIndividual = IRI
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maedertype AnonymousIndividual = NodeID
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maederdata Individual = NamedInd IRI | AnonymousIndividual AnonymousIndividual
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maeder deriving (Typeable, Show, Eq, Ord)
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maeder------------------------
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maeder-- ONTOLOGIES SYNTAX
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maeder------------------------
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maederdata OntologyFile = OntologyFile
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maeder { prefixName :: PrefixMap
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maeder , ontology :: Ontology
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maeder } deriving (Typeable, Show, Eq, Ord)
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maederinstance GetRange OntologyFile
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maederdata Ontology = Ontology
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maeder { uri :: OntologyIRI
0ea85310d2beb8aa03cac481ad2a6564e6b8ddbcChristian Maeder , importsList :: [ImportIRI]
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maeder , annotationsList :: [Annotation]
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maeder , axiomsList :: [Axiom]
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder } deriving (Typeable, Show, Eq, Ord)
89dc77946055c0e4cb4671c4a74c3dcd55ed41a1Christian Maedertype OntologyMap = Map.Map String OntologyFile
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder------------------------
2bf209888545860dc77b9c3f2198d00eeab30d20Christian Maeder-- SYMBOL ITEMS FOR HETS
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder------------------------
836e72a3c413366ba9801726f3b249c7791cb9caChristian Maederdata SymbItems = SymbItems (Maybe EntityType) [IRI]
89dc77946055c0e4cb4671c4a74c3dcd55ed41a1Christian Maeder deriving (Typeable, Show, Eq)
2bf209888545860dc77b9c3f2198d00eeab30d20Christian Maederdata SymbMapItems = SymbMapItems (Maybe EntityType) [(IRI, Maybe IRI)]
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder deriving (Typeable, Show, Eq)
5964438458028e61fdabfa74ca3b4210206cdba6Christian Maeder-- | raw symbols
2bf209888545860dc77b9c3f2198d00eeab30d20Christian Maederdata RawSymb = ASymbol Entity | AnUri IRI deriving (Typeable, Show, Eq, Ord)
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder-------------------------
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder-------------------------
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maederdata TypedOrUntyped = Typed Datatype | Untyped (Maybe LanguageTag)
89dc77946055c0e4cb4671c4a74c3dcd55ed41a1Christian Maeder deriving (Typeable, Show, Eq, Ord)
36c6cc568751e4235502cfee00ba7b597dae78dcChristian MaedercTypeS :: String
797f811e57952d59e73b8cd03b667eef276db972Christian Maeder-- | a lexical representation either with an "^^" URI (typed) or
89dc77946055c0e4cb4671c4a74c3dcd55ed41a1Christian Maeder-- an optional language tag starting with "\@" (untyped)
3daa82a175c7cfabf22455aa77c4beda327404e4Christian Maederdata Literal = Literal LexicalForm TypedOrUntyped
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder deriving (Typeable, Show, Eq, Ord)
3daa82a175c7cfabf22455aa77c4beda327404e4Christian Maeder--------------------------
3daa82a175c7cfabf22455aa77c4beda327404e4Christian Maeder-- PROPERTY EXPRESSIONS
3daa82a175c7cfabf22455aa77c4beda327404e4Christian Maeder--------------------------
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maedertype InverseObjectProperty = ObjectPropertyExpression
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maederdata ObjectPropertyExpression = ObjectProp ObjectProperty | ObjectInverseOf InverseObjectProperty
89dc77946055c0e4cb4671c4a74c3dcd55ed41a1Christian Maeder deriving (Typeable, Show, Eq, Ord)
149e43c4a2705a86a0e5fa301ba849fdf19db32eChristian Maedertype DataPropertyExpression = DataProperty
1738d16957389457347bee85075d3d33d002158fChristian Maeder-- | data type strings (some are not listed in the grammar)
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian MaederdatatypeKeys :: [String]
6e39bfd041946fce4982ac89834be73fd1bfb39aChristian MaederdatatypeKeys =
304c84f22dd78f7979efd81b8fc38c8d2197ed39Christian Maeder , negativeIntegerS
304c84f22dd78f7979efd81b8fc38c8d2197ed39Christian Maeder , nonNegativeIntegerS
304c84f22dd78f7979efd81b8fc38c8d2197ed39Christian Maeder , nonPositiveIntegerS
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder , positiveIntegerS
e215ca0377dc79c9bcfb105157ecc4b958bec67bChristian Maeder--------------------------
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder-- DATA RANGES
7de39d39bc1700cc8a9bb9df90b920aad9e18d4aChristian Maeder--------------------------
88ece6e49930670e8fd3ee79c89a2e918d2fbd0cChristian Maederdata DatatypeFacet =
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder | MININCLUSIVE
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder | MINEXCLUSIVE
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder | MAXINCLUSIVE
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder | MAXEXCLUSIVE
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maeder | TOTALDIGITS
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maeder | FRACTIONDIGITS
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian Maeder deriving (Typeable, Show, Eq, Ord)
bdce0d5f7e435df37670d3720929d97ab0043b6bChristian MaedershowFacet :: DatatypeFacet -> String
| DatatypeRestriction Datatype [(ConstrainingFacet, RestrictionValue)] -- at least one element in the list
| EquivOrDisjointObjectProperties EquivOrDisjoint [ObjectPropertyExpression] -- min. 2 ObjectPropertyExpression
| EquivOrDisjointDataProperties EquivOrDisjoint [DataPropertyExpression] -- min. 2 DataPropertyExpressions
emptyOntologyFile = OntologyFile Map.empty emptyOntology
Map.null ns && isEmptyOntology onto