module OWL2.XMLConversion where
import Common.AS_Annotation (Named, sentence)
import Common.GlobalAnnotations as GA (PrefixMap)
import Common.IRI hiding (showIRI)
import Common.Id
import OWL2.AS
import OWL2.Sign
import OWL2.XMLKeywords
import OWL2.Keywords (DatatypeFacet(..))
import Text.XML.Light
import Data.Maybe
import qualified Data.Set as Set
import qualified Data.Map as Map
showIRI :: IRI -> String
showIRI :: IRI -> String
showIRI iri :: IRI
iri = (if IRI -> Bool
isURN IRI
iri then IRI -> String
showURN else IRI -> String
showIRIFull) IRI
iri {hasAngles :: Bool
hasAngles = Bool
False}
nullQN :: Text.XML.Light.QName
nullQN :: QName
nullQN = String -> Maybe String -> Maybe String -> QName
QName "" Maybe String
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
nullElem :: Element
nullElem :: Element
nullElem = QName -> [Attr] -> [Content] -> Maybe Line -> Element
Element QName
nullQN [] [] Maybe Line
forall a. Maybe a
Nothing
makeQN :: String -> Text.XML.Light.QName
makeQN :: String -> QName
makeQN s :: String
s = QName
nullQN {qName :: String
qName = String
s}
setContent :: [Element] -> Element -> Element
setContent :: [Element] -> Element -> Element
setContent cl :: [Element]
cl e :: Element
e = Element
e {elContent :: [Content]
elContent = (Element -> Content) -> [Element] -> [Content]
forall a b. (a -> b) -> [a] -> [b]
map Element -> Content
Elem [Element]
cl}
setText :: String -> Element -> Element
setText :: String -> Element -> Element
setText s :: String
s e :: Element
e = Element
e {elContent :: [Content]
elContent = [CData -> Content
Text CData :: CDataKind -> String -> Maybe Line -> CData
CData {cdVerbatim :: CDataKind
cdVerbatim = CDataKind
CDataText,
cdData :: String
cdData = String
s, cdLine :: Maybe Line
cdLine = Maybe Line
forall a. Maybe a
Nothing}]}
setQNPrefix :: String -> Text.XML.Light.QName -> Text.XML.Light.QName
setQNPrefix :: String -> QName -> QName
setQNPrefix s :: String
s qn :: QName
qn = QName
qn {qPrefix :: Maybe String
qPrefix = String -> Maybe String
forall a. a -> Maybe a
Just String
s}
setName :: String -> Element -> Element
setName :: String -> Element -> Element
setName s :: String
s e :: Element
e = Element
e {elName :: QName
elName = QName
nullQN {qName :: String
qName = String
s,
qURI :: Maybe String
qURI = String -> Maybe String
forall a. a -> Maybe a
Just "http://www.w3.org/2002/07/owl#"} }
setIRI :: IRI -> Element -> Element
setIRI :: IRI -> Element -> Element
setIRI iri :: IRI
iri e :: Element
e =
let (ty :: String
ty, fn :: IRI -> String
fn)
| IRI -> Bool
isAbbrev IRI
iri = ("abbreviatedIRI", IRI -> String
showIRICompact)
| IRI -> Bool
isBlankNode IRI
iri = (String
nodeID, IRI -> String
showIRI)
| Bool
otherwise = (String
iriK, IRI -> String
showIRI)
in Element
e {elAttribs :: [Attr]
elAttribs = [Attr :: QName -> String -> Attr
Attr {attrKey :: QName
attrKey = String -> QName
makeQN String
ty,
attrVal :: String
attrVal = IRI -> String
fn (IRI -> String) -> IRI -> String
forall a b. (a -> b) -> a -> b
$ IRI -> IRI
setReservedPrefix IRI
iri}]}
mwIRI :: IRI -> Element
mwIRI :: IRI -> Element
mwIRI iri :: IRI
iri = IRI -> Element -> Element
setIRI IRI
iri Element
nullElem
mwNameIRI :: String -> IRI -> Element
mwNameIRI :: String -> IRI -> Element
mwNameIRI s :: String
s iri :: IRI
iri = String -> Element -> Element
setName String
s (Element -> Element) -> Element -> Element
forall a b. (a -> b) -> a -> b
$ IRI -> Element
mwIRI IRI
iri
mwString :: String -> Element
mwString :: String -> Element
mwString s :: String
s = String -> Element -> Element
setName String
s Element
nullElem
makeElementWith1 :: String -> Element -> Element
makeElementWith1 :: String -> Element -> Element
makeElementWith1 s :: String
s e :: Element
e = [Element] -> Element -> Element
setContent [Element
e] (Element -> Element) -> Element -> Element
forall a b. (a -> b) -> a -> b
$ String -> Element
mwString String
s
makeElement :: String -> [Element] -> Element
makeElement :: String -> [Element] -> Element
makeElement s :: String
s el :: [Element]
el = [Element] -> Element -> Element
setContent [Element]
el (Element -> Element) -> Element -> Element
forall a b. (a -> b) -> a -> b
$ String -> Element
mwString String
s
mwText :: String -> Element
mwText :: String -> Element
mwText s :: String
s = String -> Element -> Element
setText String
s Element
nullElem
mwSimpleIRI :: IRI -> Element
mwSimpleIRI :: IRI -> Element
mwSimpleIRI s :: IRI
s = String -> Element -> Element
setName (if IRI -> Bool
hasFullIRI IRI
s then String
iriK
else String
abbreviatedIRI) (Element -> Element) -> Element -> Element
forall a b. (a -> b) -> a -> b
$ String -> Element
mwText (String -> Element) -> String -> Element
forall a b. (a -> b) -> a -> b
$ IRI -> String
showIRI
(IRI -> String) -> IRI -> String
forall a b. (a -> b) -> a -> b
$ IRI -> IRI
setReservedPrefix IRI
s
make1 :: Bool -> String -> String -> (String -> IRI -> Element) -> IRI ->
[([Element], Element)] -> [Element]
make1 :: Bool
-> String
-> String
-> (String -> IRI -> Element)
-> IRI
-> [([Element], Element)]
-> [Element]
make1 rl :: Bool
rl hdr :: String
hdr shdr :: String
shdr f :: String -> IRI -> Element
f iri :: IRI
iri = (([Element], Element) -> Element)
-> [([Element], Element)] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map (\ (a :: [Element]
a, b :: Element
b) -> String -> [Element] -> Element
makeElement String
hdr
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Element]
a [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ (if Bool
rl then [String -> IRI -> Element
f String
shdr IRI
iri, Element
b] else [Element
b, String -> IRI -> Element
f String
shdr IRI
iri]))
make2 :: Bool -> String -> (a -> Element) -> a ->
[([Element], Element)] -> [Element]
make2 :: Bool
-> String
-> (a -> Element)
-> a
-> [([Element], Element)]
-> [Element]
make2 rl :: Bool
rl hdr :: String
hdr f :: a -> Element
f expr :: a
expr = (([Element], Element) -> Element)
-> [([Element], Element)] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map (\ (x :: [Element]
x, y :: Element
y) -> String -> [Element] -> Element
makeElement String
hdr
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Element]
x [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ (if Bool
rl then [a -> Element
f a
expr, Element
y] else [Element
y, a -> Element
f a
expr]))
setInt :: Int -> Element -> Element
setInt :: Int -> Element -> Element
setInt i :: Int
i e :: Element
e = Element
e {elAttribs :: [Attr]
elAttribs = [Attr :: QName -> String -> Attr
Attr {attrKey :: QName
attrKey = String -> QName
makeQN "cardinality",
attrVal :: String
attrVal = Int -> String
forall a. Show a => a -> String
show Int
i}]}
correctFacet :: ConstrainingFacet -> ConstrainingFacet
correctFacet :: IRI -> IRI
correctFacet c :: IRI
c = case IRI -> String
getPredefName IRI
c of
">" -> DatatypeFacet -> IRI
facetToIRINoSign DatatypeFacet
MAXEXCLUSIVE
"<" -> DatatypeFacet -> IRI
facetToIRINoSign DatatypeFacet
MINEXCLUSIVE
">=" -> DatatypeFacet -> IRI
facetToIRINoSign DatatypeFacet
MAXINCLUSIVE
"<=" -> DatatypeFacet -> IRI
facetToIRINoSign DatatypeFacet
MININCLUSIVE
_ -> IRI
c
setDt :: Bool -> IRI -> Element -> Element
setDt :: Bool -> IRI -> Element -> Element
setDt b :: Bool
b dt :: IRI
dt e :: Element
e = Element
e {elAttribs :: [Attr]
elAttribs = Element -> [Attr]
elAttribs Element
e [Attr] -> [Attr] -> [Attr]
forall a. [a] -> [a] -> [a]
++ [Attr :: QName -> String -> Attr
Attr {attrKey :: QName
attrKey
= String -> QName
makeQN (if Bool
b then "datatypeIRI" else "facet"),
attrVal :: String
attrVal = IRI -> String
showIRI (IRI -> String) -> IRI -> String
forall a b. (a -> b) -> a -> b
$ if Bool
b then IRI -> IRI
setReservedPrefix IRI
dt else IRI -> IRI
correctFacet IRI
dt}]}
setLangTag :: Maybe LanguageTag -> Element -> Element
setLangTag :: Maybe String -> Element -> Element
setLangTag ml :: Maybe String
ml e :: Element
e = case Maybe String
ml of
Nothing -> Element
e
Just lt :: String
lt -> Element
e {elAttribs :: [Attr]
elAttribs = Element -> [Attr]
elAttribs Element
e [Attr] -> [Attr] -> [Attr]
forall a. [a] -> [a] -> [a]
++ [Attr :: QName -> String -> Attr
Attr {attrKey :: QName
attrKey
= String -> QName -> QName
setQNPrefix "xml" (String -> QName
makeQN "lang"), attrVal :: String
attrVal = String
lt}]}
xmlEntity :: Entity -> Element
xmlEntity :: Entity -> Element
xmlEntity (Entity _ ty :: EntityType
ty ent :: IRI
ent) = String -> IRI -> Element
mwNameIRI (case EntityType
ty of
Class -> String
classK
Datatype -> String
datatypeK
ObjectProperty -> String
objectPropertyK
DataProperty -> String
dataPropertyK
AnnotationProperty -> String
annotationPropertyK
NamedIndividual -> String
namedIndividualK) IRI
ent
xmlLiteral :: Literal -> Element
xmlLiteral :: Literal -> Element
xmlLiteral l :: Literal
l = case Literal
l of
Literal lf :: String
lf tu :: TypedOrUntyped
tu ->
let part :: Element
part = String -> Element -> Element
setName String
literalK (Element -> Element) -> Element -> Element
forall a b. (a -> b) -> a -> b
$ String -> Element
mwText String
lf
in case TypedOrUntyped
tu of
Typed dt :: IRI
dt -> Bool -> IRI -> Element -> Element
setDt Bool
True IRI
dt Element
part
Untyped lang :: Maybe String
lang -> Maybe String -> Element -> Element
setLangTag Maybe String
lang (Element -> Element) -> Element -> Element
forall a b. (a -> b) -> a -> b
$ Bool -> IRI -> Element -> Element
setDt Bool
True IRI
plainDatatypeIRI Element
part
NumberLit f :: FloatLit
f -> Bool -> IRI -> Element -> Element
setDt Bool
True (IRI
nullIRI {iriScheme :: String
iriScheme = "http:",
iriPath :: Id
iriPath = String -> Id
stringToId (String -> Id) -> String -> Id
forall a b. (a -> b) -> a -> b
$ "//www.w3.org/2001/XMLSchema#" String -> String -> String
forall a. [a] -> [a] -> [a]
++ FloatLit -> String
numberName FloatLit
f})
(Element -> Element) -> Element -> Element
forall a b. (a -> b) -> a -> b
$ String -> Element -> Element
setName String
literalK (Element -> Element) -> Element -> Element
forall a b. (a -> b) -> a -> b
$ String -> Element
mwText (String -> Element) -> String -> Element
forall a b. (a -> b) -> a -> b
$ FloatLit -> String
forall a. Show a => a -> String
show FloatLit
f
xmlIndividual :: IRI -> Element
xmlIndividual :: IRI -> Element
xmlIndividual iri :: IRI
iri =
String -> IRI -> Element
mwNameIRI (if IRI -> Bool
isAnonymous IRI
iri then String
anonymousIndividualK
else String
namedIndividualK) IRI
iri
xmlFVPair :: (ConstrainingFacet, RestrictionValue) -> Element
xmlFVPair :: (IRI, Literal) -> Element
xmlFVPair (cf :: IRI
cf, rv :: Literal
rv) = Bool -> IRI -> Element -> Element
setDt Bool
False IRI
cf (Element -> Element) -> Element -> Element
forall a b. (a -> b) -> a -> b
$ String -> [Element] -> Element
makeElement String
facetRestrictionK
[Literal -> Element
xmlLiteral Literal
rv]
xmlObjProp :: ObjectPropertyExpression -> Element
xmlObjProp :: ObjectPropertyExpression -> Element
xmlObjProp ope :: ObjectPropertyExpression
ope = case ObjectPropertyExpression
ope of
ObjectProp op :: IRI
op -> String -> IRI -> Element
mwNameIRI String
objectPropertyK IRI
op
ObjectInverseOf i :: ObjectPropertyExpression
i -> String -> [Element] -> Element
makeElement String
objectInverseOfK [ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
i]
xmlDataRange :: DataRange -> Element
xmlDataRange :: DataRange -> Element
xmlDataRange dr :: DataRange
dr = case DataRange
dr of
DataType dt :: IRI
dt cfl :: [(IRI, Literal)]
cfl ->
let dtelem :: Element
dtelem = String -> IRI -> Element
mwNameIRI String
datatypeK IRI
dt
in if [(IRI, Literal)] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(IRI, Literal)]
cfl then Element
dtelem
else String -> [Element] -> Element
makeElement String
datatypeRestrictionK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ Element
dtelem Element -> [Element] -> [Element]
forall a. a -> [a] -> [a]
: ((IRI, Literal) -> Element) -> [(IRI, Literal)] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map (IRI, Literal) -> Element
xmlFVPair [(IRI, Literal)]
cfl
DataJunction jt :: JunctionType
jt drl :: [DataRange]
drl -> String -> [Element] -> Element
makeElement (
case JunctionType
jt of
IntersectionOf -> String
dataIntersectionOfK
UnionOf -> String
dataUnionOfK)
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ (DataRange -> Element) -> [DataRange] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map DataRange -> Element
xmlDataRange [DataRange]
drl
DataComplementOf drn :: DataRange
drn -> String -> [Element] -> Element
makeElement String
dataComplementOfK
[DataRange -> Element
xmlDataRange DataRange
drn]
DataOneOf ll :: [Literal]
ll -> String -> [Element] -> Element
makeElement String
dataOneOfK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ (Literal -> Element) -> [Literal] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map Literal -> Element
xmlLiteral [Literal]
ll
xmlClassExpression :: ClassExpression -> Element
xmlClassExpression :: ClassExpression -> Element
xmlClassExpression ce :: ClassExpression
ce = case ClassExpression
ce of
Expression c :: IRI
c -> String -> IRI -> Element
mwNameIRI String
classK IRI
c
ObjectJunction jt :: JunctionType
jt cel :: [ClassExpression]
cel -> String -> [Element] -> Element
makeElement (
case JunctionType
jt of
IntersectionOf -> String
objectIntersectionOfK
UnionOf -> String
objectUnionOfK)
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ (ClassExpression -> Element) -> [ClassExpression] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map ClassExpression -> Element
xmlClassExpression [ClassExpression]
cel
ObjectComplementOf cex :: ClassExpression
cex -> String -> [Element] -> Element
makeElement String
objectComplementOfK
[ClassExpression -> Element
xmlClassExpression ClassExpression
cex]
ObjectOneOf il :: [IRI]
il -> String -> [Element] -> Element
makeElement String
objectOneOfK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ (IRI -> Element) -> [IRI] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map IRI -> Element
xmlIndividual [IRI]
il
ObjectValuesFrom qt :: QuantifierType
qt ope :: ObjectPropertyExpression
ope cex :: ClassExpression
cex -> String -> [Element] -> Element
makeElement (
case QuantifierType
qt of
AllValuesFrom -> String
objectAllValuesFromK
SomeValuesFrom -> String
objectSomeValuesFromK)
[ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
ope, ClassExpression -> Element
xmlClassExpression ClassExpression
cex]
ObjectHasValue ope :: ObjectPropertyExpression
ope i :: IRI
i -> String -> [Element] -> Element
makeElement String
objectHasValueK
[ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
ope, IRI -> Element
xmlIndividual IRI
i]
ObjectHasSelf ope :: ObjectPropertyExpression
ope -> String -> [Element] -> Element
makeElement String
objectHasSelfK [ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
ope]
ObjectCardinality (Cardinality ct :: CardinalityType
ct i :: Int
i op :: ObjectPropertyExpression
op mce :: Maybe ClassExpression
mce) -> Int -> Element -> Element
setInt Int
i (Element -> Element) -> Element -> Element
forall a b. (a -> b) -> a -> b
$ String -> [Element] -> Element
makeElement (
case CardinalityType
ct of
MinCardinality -> String
objectMinCardinalityK
MaxCardinality -> String
objectMaxCardinalityK
ExactCardinality -> String
objectExactCardinalityK)
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
op Element -> [Element] -> [Element]
forall a. a -> [a] -> [a]
:
case Maybe ClassExpression
mce of
Nothing -> []
Just cexp :: ClassExpression
cexp -> [ClassExpression -> Element
xmlClassExpression ClassExpression
cexp]
DataValuesFrom qt :: QuantifierType
qt dp :: [IRI]
dp dr :: DataRange
dr -> String -> [Element] -> Element
makeElement (
case QuantifierType
qt of
AllValuesFrom -> String
dataAllValuesFromK
SomeValuesFrom -> String
dataSomeValuesFromK)
[String -> IRI -> Element
mwNameIRI String
dataPropertyK ([IRI] -> IRI
forall a. [a] -> a
head [IRI]
dp), DataRange -> Element
xmlDataRange DataRange
dr]
DataHasValue dp :: IRI
dp l :: Literal
l -> String -> [Element] -> Element
makeElement String
dataHasValueK
[String -> IRI -> Element
mwNameIRI String
dataPropertyK IRI
dp, Literal -> Element
xmlLiteral Literal
l]
DataCardinality (Cardinality ct :: CardinalityType
ct i :: Int
i dp :: IRI
dp mdr :: Maybe DataRange
mdr) -> Int -> Element -> Element
setInt Int
i (Element -> Element) -> Element -> Element
forall a b. (a -> b) -> a -> b
$ String -> [Element] -> Element
makeElement (
case CardinalityType
ct of
MinCardinality -> String
dataMinCardinalityK
MaxCardinality -> String
dataMaxCardinalityK
ExactCardinality -> String
dataExactCardinalityK)
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ String -> IRI -> Element
mwNameIRI String
dataPropertyK IRI
dp Element -> [Element] -> [Element]
forall a. a -> [a] -> [a]
:
case Maybe DataRange
mdr of
Nothing -> []
Just dr :: DataRange
dr -> [DataRange -> Element
xmlDataRange DataRange
dr]
xmlAnnotation :: Annotation -> Element
xmlAnnotation :: Annotation -> Element
xmlAnnotation (Annotation al :: [Annotation]
al ap :: IRI
ap av :: AnnotationValue
av) = String -> [Element] -> Element
makeElement String
annotationK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ (Annotation -> Element) -> [Annotation] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map Annotation -> Element
xmlAnnotation [Annotation]
al [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [String -> IRI -> Element
mwNameIRI String
annotationPropertyK IRI
ap,
case AnnotationValue
av of
AnnValue iri :: IRI
iri -> IRI -> Element
xmlSubject IRI
iri
AnnValLit l :: Literal
l -> Literal -> Element
xmlLiteral Literal
l
AnnAnInd iri :: IRI
iri -> IRI -> Element
xmlSubject IRI
iri]
xmlSubject :: IRI -> Element
xmlSubject :: IRI -> Element
xmlSubject iri :: IRI
iri = if IRI -> Bool
isAnonymous IRI
iri then IRI -> Element
xmlIndividual IRI
iri
else IRI -> Element
mwSimpleIRI IRI
iri
xmlAnnotations :: [Annotation] -> [Element]
xmlAnnotations :: [Annotation] -> [Element]
xmlAnnotations = (Annotation -> Element) -> [Annotation] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map Annotation -> Element
xmlAnnotation
xmlAssertion :: IRI -> [Annotation] -> [Element]
xmlAssertion :: IRI -> [Annotation] -> [Element]
xmlAssertion iri :: IRI
iri = (Annotation -> Element) -> [Annotation] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map (\ (Annotation as :: [Annotation]
as ap :: IRI
ap av :: AnnotationValue
av) ->
String -> [Element] -> Element
makeElement String
annotationAssertionK ([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
as
[Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [String -> IRI -> Element
mwNameIRI String
annotationPropertyK IRI
ap]
[Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [IRI -> Element
xmlSubject IRI
iri, case AnnotationValue
av of
AnnValue avalue :: IRI
avalue -> IRI -> Element
xmlSubject IRI
avalue
AnnAnInd ind :: IRI
ind -> IRI -> Element
xmlSubject IRI
ind
AnnValLit l :: Literal
l -> Literal -> Element
xmlLiteral Literal
l])
xmlAxioms :: Axiom -> [Element]
xmlAxioms :: Axiom -> [Element]
xmlAxioms axiom :: Axiom
axiom = case Axiom
axiom of
Declaration anns :: [Annotation]
anns entity :: Entity
entity ->
[String -> [Element] -> Element
makeElement String
declarationK ([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [Entity -> Element
xmlEntity Entity
entity]]
ClassAxiom clAxiom :: ClassAxiom
clAxiom -> case ClassAxiom
clAxiom of
SubClassOf anns :: [Annotation]
anns sub :: ClassExpression
sub sup :: ClassExpression
sup -> Bool
-> String
-> (ClassExpression -> Element)
-> ClassExpression
-> [([Element], Element)]
-> [Element]
forall a.
Bool
-> String
-> (a -> Element)
-> a
-> [([Element], Element)]
-> [Element]
make2 Bool
True String
subClassOfK ClassExpression -> Element
xmlClassExpression
ClassExpression
sub [([Annotation] -> [Element]
xmlAnnotations [Annotation]
anns, ClassExpression -> Element
xmlClassExpression ClassExpression
sup)]
EquivalentClasses anns :: [Annotation]
anns ces :: [ClassExpression]
ces ->
[String -> [Element] -> Element
makeElement String
equivalentClassesK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ (ClassExpression -> Element) -> [ClassExpression] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map ClassExpression -> Element
xmlClassExpression [ClassExpression]
ces]
DisjointClasses anns :: [Annotation]
anns ces :: [ClassExpression]
ces ->
[String -> [Element] -> Element
makeElement String
disjointClassesK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ (ClassExpression -> Element) -> [ClassExpression] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map ClassExpression -> Element
xmlClassExpression [ClassExpression]
ces]
DisjointUnion anns :: [Annotation]
anns clIri :: IRI
clIri ces :: [ClassExpression]
ces ->
[String -> [Element] -> Element
makeElement String
disjointUnionK ([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns
[Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ (ClassExpression -> Element) -> [ClassExpression] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map ClassExpression -> Element
xmlClassExpression ((IRI -> ClassExpression
Expression IRI
clIri) ClassExpression -> [ClassExpression] -> [ClassExpression]
forall a. a -> [a] -> [a]
: [ClassExpression]
ces)]
ObjectPropertyAxiom opAxiom :: ObjectPropertyAxiom
opAxiom -> case ObjectPropertyAxiom
opAxiom of
SubObjectPropertyOf anns :: [Annotation]
anns sub :: SubObjectPropertyExpression
sub sup :: ObjectPropertyExpression
sup -> case SubObjectPropertyExpression
sub of
SubObjPropExpr_obj op :: ObjectPropertyExpression
op ->
Bool
-> String
-> (ObjectPropertyExpression -> Element)
-> ObjectPropertyExpression
-> [([Element], Element)]
-> [Element]
forall a.
Bool
-> String
-> (a -> Element)
-> a
-> [([Element], Element)]
-> [Element]
make2 Bool
True String
subObjectPropertyOfK ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
op
[([Annotation] -> [Element]
xmlAnnotations [Annotation]
anns, ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
sup)]
SubObjPropExpr_exprchain ops :: PropertyExpressionChain
ops ->
let xmlop :: [Element]
xmlop = (ObjectPropertyExpression -> Element)
-> PropertyExpressionChain -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map ObjectPropertyExpression -> Element
xmlObjProp PropertyExpressionChain
ops
in [String -> [Element] -> Element
makeElement String
subObjectPropertyOfK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns
[Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [String -> [Element] -> Element
makeElement String
objectPropertyChainK [Element]
xmlop
, ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
sup]]
EquivalentObjectProperties anns :: [Annotation]
anns ops :: PropertyExpressionChain
ops ->
[String -> [Element] -> Element
makeElement String
equivalentObjectPropertiesK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ (ObjectPropertyExpression -> Element)
-> PropertyExpressionChain -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map ObjectPropertyExpression -> Element
xmlObjProp PropertyExpressionChain
ops]
DisjointObjectProperties anns :: [Annotation]
anns ops :: PropertyExpressionChain
ops ->
[String -> [Element] -> Element
makeElement String
disjointObjectPropertiesK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ (ObjectPropertyExpression -> Element)
-> PropertyExpressionChain -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map ObjectPropertyExpression -> Element
xmlObjProp PropertyExpressionChain
ops]
InverseObjectProperties anns :: [Annotation]
anns op1 :: ObjectPropertyExpression
op1 op2 :: ObjectPropertyExpression
op2 ->
Bool
-> String
-> (ObjectPropertyExpression -> Element)
-> ObjectPropertyExpression
-> [([Element], Element)]
-> [Element]
forall a.
Bool
-> String
-> (a -> Element)
-> a
-> [([Element], Element)]
-> [Element]
make2 Bool
True String
inverseObjectPropertiesK ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
op1
[([Annotation] -> [Element]
xmlAnnotations [Annotation]
anns, ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
op2)]
ObjectPropertyDomain anns :: [Annotation]
anns op :: ObjectPropertyExpression
op ce :: ClassExpression
ce ->
Bool
-> String
-> (ObjectPropertyExpression -> Element)
-> ObjectPropertyExpression
-> [([Element], Element)]
-> [Element]
forall a.
Bool
-> String
-> (a -> Element)
-> a
-> [([Element], Element)]
-> [Element]
make2 Bool
True String
objectPropertyDomainK ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
op
[([Annotation] -> [Element]
xmlAnnotations [Annotation]
anns, ClassExpression -> Element
xmlClassExpression ClassExpression
ce)]
ObjectPropertyRange anns :: [Annotation]
anns op :: ObjectPropertyExpression
op ce :: ClassExpression
ce ->
Bool
-> String
-> (ObjectPropertyExpression -> Element)
-> ObjectPropertyExpression
-> [([Element], Element)]
-> [Element]
forall a.
Bool
-> String
-> (a -> Element)
-> a
-> [([Element], Element)]
-> [Element]
make2 Bool
True String
objectPropertyRangeK ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
op
[([Annotation] -> [Element]
xmlAnnotations [Annotation]
anns, ClassExpression -> Element
xmlClassExpression ClassExpression
ce)]
FunctionalObjectProperty anns :: [Annotation]
anns op :: ObjectPropertyExpression
op ->
[String -> [Element] -> Element
makeElement String
functionalObjectPropertyK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
op]]
InverseFunctionalObjectProperty anns :: [Annotation]
anns op :: ObjectPropertyExpression
op ->
[String -> [Element] -> Element
makeElement String
inverseFunctionalObjectPropertyK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
op]]
ReflexiveObjectProperty anns :: [Annotation]
anns op :: ObjectPropertyExpression
op ->
[String -> [Element] -> Element
makeElement String
reflexiveObjectPropertyK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
op]]
IrreflexiveObjectProperty anns :: [Annotation]
anns op :: ObjectPropertyExpression
op ->
[String -> [Element] -> Element
makeElement String
irreflexiveObjectPropertyK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
op]]
SymmetricObjectProperty anns :: [Annotation]
anns op :: ObjectPropertyExpression
op ->
[String -> [Element] -> Element
makeElement String
symmetricObjectPropertyK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
op]]
AsymmetricObjectProperty anns :: [Annotation]
anns op :: ObjectPropertyExpression
op ->
[String -> [Element] -> Element
makeElement String
asymmetricObjectPropertyK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
op]]
TransitiveObjectProperty anns :: [Annotation]
anns op :: ObjectPropertyExpression
op ->
[String -> [Element] -> Element
makeElement String
transitiveObjectPropertyK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
op]]
DataPropertyAxiom dpAxiom :: DataPropertyAxiom
dpAxiom -> case DataPropertyAxiom
dpAxiom of
SubDataPropertyOf anns :: [Annotation]
anns sub :: IRI
sub sup :: IRI
sup ->
Bool
-> String
-> String
-> (String -> IRI -> Element)
-> IRI
-> [([Element], Element)]
-> [Element]
make1 Bool
True String
subDataPropertyOfK String
dataPropertyK
String -> IRI -> Element
mwNameIRI IRI
sub [([Annotation] -> [Element]
xmlAnnotations [Annotation]
anns, String -> IRI -> Element
mwNameIRI String
dataPropertyK IRI
sup)]
EquivalentDataProperties anns :: [Annotation]
anns dps :: [IRI]
dps ->
[String -> [Element] -> Element
makeElement String
equivalentDataPropertiesK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ (IRI -> Element) -> [IRI] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map (String -> IRI -> Element
mwNameIRI String
dataPropertyK) [IRI]
dps]
DisjointDataProperties anns :: [Annotation]
anns dps :: [IRI]
dps ->
[String -> [Element] -> Element
makeElement String
disjointDataPropertiesK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ (IRI -> Element) -> [IRI] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map (String -> IRI -> Element
mwNameIRI String
dataPropertyK) [IRI]
dps]
DataPropertyDomain anns :: [Annotation]
anns dpe :: IRI
dpe ce :: ClassExpression
ce ->
Bool
-> String
-> String
-> (String -> IRI -> Element)
-> IRI
-> [([Element], Element)]
-> [Element]
make1 Bool
True String
dataPropertyDomainK String
dataPropertyK String -> IRI -> Element
mwNameIRI IRI
dpe
[([Annotation] -> [Element]
xmlAnnotations [Annotation]
anns, ClassExpression -> Element
xmlClassExpression ClassExpression
ce)]
DataPropertyRange anns :: [Annotation]
anns dpe :: IRI
dpe dr :: DataRange
dr ->
Bool
-> String
-> String
-> (String -> IRI -> Element)
-> IRI
-> [([Element], Element)]
-> [Element]
make1 Bool
True String
dataPropertyRangeK String
dataPropertyK String -> IRI -> Element
mwNameIRI IRI
dpe
[([Annotation] -> [Element]
xmlAnnotations [Annotation]
anns, DataRange -> Element
xmlDataRange DataRange
dr)]
FunctionalDataProperty anns :: [Annotation]
anns dpe :: IRI
dpe ->
[String -> [Element] -> Element
makeElement String
functionalDataPropertyK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [String -> IRI -> Element
mwNameIRI String
dataPropertyK IRI
dpe]]
DatatypeDefinition anns :: [Annotation]
anns dt :: IRI
dt dr :: DataRange
dr ->
[String -> [Element] -> Element
makeElement String
datatypeDefinitionK ([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns
[Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [String -> IRI -> Element
mwNameIRI String
datatypeK IRI
dt, DataRange -> Element
xmlDataRange DataRange
dr]]
HasKey anns :: [Annotation]
anns ce :: ClassExpression
ce ops :: PropertyExpressionChain
ops dps :: [IRI]
dps ->
[String -> [Element] -> Element
makeElement String
hasKeyK ([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [ClassExpression -> Element
xmlClassExpression ClassExpression
ce]
[Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ (ObjectPropertyExpression -> Element)
-> PropertyExpressionChain -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map ObjectPropertyExpression -> Element
xmlObjProp PropertyExpressionChain
ops [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ (IRI -> Element) -> [IRI] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map (String -> IRI -> Element
mwNameIRI String
dataPropertyK) [IRI]
dps]
Assertion aAxiom :: Assertion
aAxiom -> case Assertion
aAxiom of
SameIndividual anns :: [Annotation]
anns inds :: [IRI]
inds ->
[String -> [Element] -> Element
makeElement String
sameIndividualK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ (IRI -> Element) -> [IRI] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map IRI -> Element
xmlIndividual [IRI]
inds]
DifferentIndividuals anns :: [Annotation]
anns inds :: [IRI]
inds ->
[String -> [Element] -> Element
makeElement String
differentIndividualsK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ (IRI -> Element) -> [IRI] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map IRI -> Element
xmlIndividual [IRI]
inds]
ClassAssertion anns :: [Annotation]
anns ce :: ClassExpression
ce ind :: IRI
ind ->
Bool
-> String
-> (IRI -> Element)
-> IRI
-> [([Element], Element)]
-> [Element]
forall a.
Bool
-> String
-> (a -> Element)
-> a
-> [([Element], Element)]
-> [Element]
make2 Bool
False String
classAssertionK IRI -> Element
xmlIndividual IRI
ind
[([Annotation] -> [Element]
xmlAnnotations [Annotation]
anns, ClassExpression -> Element
xmlClassExpression ClassExpression
ce)]
ObjectPropertyAssertion anns :: [Annotation]
anns op :: ObjectPropertyExpression
op sInd :: IRI
sInd tInd :: IRI
tInd ->
[String -> [Element] -> Element
makeElement String
objectPropertyAssertionK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
op]
[Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ (IRI -> Element) -> [IRI] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map IRI -> Element
xmlIndividual [IRI
sInd, IRI
tInd]]
NegativeObjectPropertyAssertion anns :: [Annotation]
anns op :: ObjectPropertyExpression
op sInd :: IRI
sInd tInd :: IRI
tInd ->
[String -> [Element] -> Element
makeElement String
negativeObjectPropertyAssertionK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
op]
[Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ (IRI -> Element) -> [IRI] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map IRI -> Element
xmlIndividual [IRI
sInd, IRI
tInd]]
DataPropertyAssertion anns :: [Annotation]
anns dp :: IRI
dp sInd :: IRI
sInd tVal :: Literal
tVal ->
[String -> [Element] -> Element
makeElement String
dataPropertyAssertionK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [String -> IRI -> Element
mwNameIRI String
dataPropertyK IRI
dp]
[Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [IRI -> Element
xmlIndividual IRI
sInd] [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [Literal -> Element
xmlLiteral Literal
tVal]]
NegativeDataPropertyAssertion anns :: [Annotation]
anns dp :: IRI
dp sInd :: IRI
sInd tVal :: Literal
tVal ->
[String -> [Element] -> Element
makeElement String
negativeDataPropertyAssertionK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [String -> IRI -> Element
mwNameIRI String
dataPropertyK IRI
dp]
[Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [IRI -> Element
xmlIndividual IRI
sInd] [Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [Literal -> Element
xmlLiteral Literal
tVal]]
AnnotationAxiom annAxiom :: AnnotationAxiom
annAxiom -> case AnnotationAxiom
annAxiom of
AnnotationAssertion anns :: [Annotation]
anns prop :: IRI
prop subj :: AnnotationSubject
subj value :: AnnotationValue
value ->
let iri :: IRI
iri = case AnnotationSubject
subj of
AnnSubIri i :: IRI
i -> IRI
i
AnnSubAnInd i :: IRI
i -> IRI
i
in IRI -> [Annotation] -> [Element]
xmlAssertion IRI
iri [[Annotation] -> IRI -> AnnotationValue -> Annotation
Annotation [Annotation]
anns IRI
prop AnnotationValue
value]
SubAnnotationPropertyOf anns :: [Annotation]
anns sub :: IRI
sub sup :: IRI
sup ->
Bool
-> String
-> String
-> (String -> IRI -> Element)
-> IRI
-> [([Element], Element)]
-> [Element]
make1 Bool
True String
subAnnotationPropertyOfK String
annotationPropertyK
String -> IRI -> Element
mwNameIRI IRI
sub
[([Annotation] -> [Element]
xmlAnnotations [Annotation]
anns, String -> IRI -> Element
mwNameIRI String
annotationPropertyK IRI
sup)]
AnnotationPropertyDomain anns :: [Annotation]
anns prop :: IRI
prop iri :: IRI
iri ->
Bool
-> String
-> String
-> (String -> IRI -> Element)
-> IRI
-> [([Element], Element)]
-> [Element]
make1 Bool
True String
annotationPropertyDomainK
String
annotationPropertyK String -> IRI -> Element
mwNameIRI IRI
prop
[([Annotation] -> [Element]
xmlAnnotations [Annotation]
anns, IRI -> Element
mwSimpleIRI IRI
iri)]
AnnotationPropertyRange anns :: [Annotation]
anns prop :: IRI
prop iri :: IRI
iri ->
Bool
-> String
-> String
-> (String -> IRI -> Element)
-> IRI
-> [([Element], Element)]
-> [Element]
make1 Bool
True String
annotationPropertyRangeK
String
annotationPropertyK String -> IRI -> Element
mwNameIRI IRI
prop
[([Annotation] -> [Element]
xmlAnnotations [Annotation]
anns, IRI -> Element
mwSimpleIRI IRI
iri)]
Rule rule :: Rule
rule -> case Rule
rule of
DLSafeRule anns :: [Annotation]
anns bd :: Body
bd hd :: Body
hd ->
[String -> [Element] -> Element
makeElement String
dlSafeRuleK ([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ [Annotation] -> [Element]
xmlAnnotations [Annotation]
anns
[Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ [String -> [Element] -> Element
makeElement "Body" ([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ (Atom -> Element) -> Body -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map Atom -> Element
xmlAtom Body
bd
, String -> [Element] -> Element
makeElement "Head" ([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ (Atom -> Element) -> Body -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map Atom -> Element
xmlAtom Body
hd]]
DGRule _ _ _ -> String -> [Element]
forall a. HasCallStack => String -> a
error "DG Rules are not supported in XML yet"
DGAxiom _ _ _ _ _ -> String -> [Element]
forall a. HasCallStack => String -> a
error "DG Axioms are not supported in XML yet"
xmlAtom :: Atom -> Element
xmlAtom :: Atom -> Element
xmlAtom atom :: Atom
atom = case Atom
atom of
ClassAtom ce :: ClassExpression
ce ia :: IndividualArg
ia -> String -> [Element] -> Element
makeElement String
classAtomK
[ClassExpression -> Element
xmlClassExpression ClassExpression
ce, IndividualArg -> Element
xmlIndividualArg IndividualArg
ia]
DataRangeAtom dr :: DataRange
dr da :: DataArg
da -> String -> [Element] -> Element
makeElement String
dataRangeAtomK
[DataRange -> Element
xmlDataRange DataRange
dr, DataArg -> Element
xmlDataArg DataArg
da]
ObjectPropertyAtom oe :: ObjectPropertyExpression
oe ia1 :: IndividualArg
ia1 ia2 :: IndividualArg
ia2 -> String -> [Element] -> Element
makeElement String
objectPropertyAtomK
[ObjectPropertyExpression -> Element
xmlObjProp ObjectPropertyExpression
oe, IndividualArg -> Element
xmlIndividualArg IndividualArg
ia1, IndividualArg -> Element
xmlIndividualArg IndividualArg
ia2]
DataPropertyAtom dp :: IRI
dp ia :: IndividualArg
ia da :: DataArg
da -> String -> [Element] -> Element
makeElement String
dataPropertyAtomK
[String -> IRI -> Element
mwNameIRI String
dataPropertyK IRI
dp, IndividualArg -> Element
xmlIndividualArg IndividualArg
ia, DataArg -> Element
xmlDataArg DataArg
da]
BuiltInAtom iri :: IRI
iri das :: [DataArg]
das -> IRI -> Element -> Element
setIRI IRI
iri (Element -> Element) -> Element -> Element
forall a b. (a -> b) -> a -> b
$ String -> [Element] -> Element
makeElement String
builtInAtomK
([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ (DataArg -> Element) -> [DataArg] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map DataArg -> Element
xmlDataArg [DataArg]
das
SameIndividualAtom ia1 :: IndividualArg
ia1 ia2 :: IndividualArg
ia2 -> String -> [Element] -> Element
makeElement String
sameIndividualAtomK
([Element] -> Element)
-> ([IndividualArg] -> [Element]) -> [IndividualArg] -> Element
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (IndividualArg -> Element) -> [IndividualArg] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map IndividualArg -> Element
xmlIndividualArg ([IndividualArg] -> Element) -> [IndividualArg] -> Element
forall a b. (a -> b) -> a -> b
$ [IndividualArg
ia1, IndividualArg
ia2]
DifferentIndividualsAtom ia1 :: IndividualArg
ia1 ia2 :: IndividualArg
ia2 -> String -> [Element] -> Element
makeElement String
differentIndividualsAtomK
([Element] -> Element)
-> ([IndividualArg] -> [Element]) -> [IndividualArg] -> Element
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (IndividualArg -> Element) -> [IndividualArg] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map IndividualArg -> Element
xmlIndividualArg ([IndividualArg] -> Element) -> [IndividualArg] -> Element
forall a b. (a -> b) -> a -> b
$ [IndividualArg
ia1, IndividualArg
ia2]
_ -> String -> Element
forall a. HasCallStack => String -> a
error "XML Converter: Uknown atom"
xmlIndividualArg :: IndividualArg -> Element
xmlIndividualArg :: IndividualArg -> Element
xmlIndividualArg ia :: IndividualArg
ia = case IndividualArg
ia of
IArg i :: IRI
i -> String -> IRI -> Element
mwNameIRI String
namedIndividualK IRI
i
IVar i :: IRI
i -> String -> IRI -> Element
mwNameIRI String
variableK IRI
i
xmlDataArg :: DataArg -> Element
xmlDataArg :: DataArg -> Element
xmlDataArg da :: DataArg
da = case DataArg
da of
DArg lit :: Literal
lit -> Literal -> Element
xmlLiteral Literal
lit
DVar iri :: IRI
iri -> String -> IRI -> Element
mwNameIRI String
variableK IRI
iri
xmlUnknownArg :: UnknownArg -> Element
xmlUnknownArg :: UnknownArg -> Element
xmlUnknownArg ua :: UnknownArg
ua = case UnknownArg
ua of
IndividualArg ia :: IndividualArg
ia -> IndividualArg -> Element
xmlIndividualArg IndividualArg
ia
DataArg da :: DataArg
da -> DataArg -> Element
xmlDataArg DataArg
da
Variable v :: IRI
v -> String -> IRI -> Element
mwNameIRI String
variableK IRI
v
mkElemeDecl :: Sign -> String -> (Sign -> Set.Set IRI) -> [Element]
mkElemeDecl :: Sign -> String -> (Sign -> Set IRI) -> [Element]
mkElemeDecl s :: Sign
s k :: String
k f :: Sign -> Set IRI
f = (IRI -> Element) -> [IRI] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map (String -> Element -> Element
makeElementWith1 String
declarationK (Element -> Element) -> (IRI -> Element) -> IRI -> Element
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IRI -> Element
mwNameIRI String
k)
([IRI] -> [Element]) -> [IRI] -> [Element]
forall a b. (a -> b) -> a -> b
$ Set IRI -> [IRI]
forall a. Set a -> [a]
Set.toList (Set IRI -> [IRI]) -> Set IRI -> [IRI]
forall a b. (a -> b) -> a -> b
$ Sign -> Set IRI
f Sign
s
signToDec :: Sign -> [Element]
signToDec :: Sign -> [Element]
signToDec s :: Sign
s = ((String, Sign -> Set IRI) -> [Element])
-> [(String, Sign -> Set IRI)] -> [Element]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ((String -> (Sign -> Set IRI) -> [Element])
-> (String, Sign -> Set IRI) -> [Element]
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry ((String -> (Sign -> Set IRI) -> [Element])
-> (String, Sign -> Set IRI) -> [Element])
-> (String -> (Sign -> Set IRI) -> [Element])
-> (String, Sign -> Set IRI)
-> [Element]
forall a b. (a -> b) -> a -> b
$ Sign -> String -> (Sign -> Set IRI) -> [Element]
mkElemeDecl Sign
s)
[ (String
classK, Sign -> Set IRI
concepts)
, (String
objectPropertyK, Sign -> Set IRI
objectProperties)
, (String
dataPropertyK, Sign -> Set IRI
dataProperties)
, (String
annotationPropertyK, Sign -> Set IRI
annotationRoles)
, (String
datatypeK, Sign -> Set IRI
datatypes)
, (String
namedIndividualK, Sign -> Set IRI
individuals)]
xmlImport :: ImportIRI -> Element
xmlImport :: IRI -> Element
xmlImport i :: IRI
i = String -> Element -> Element
setName String
importK (Element -> Element) -> Element -> Element
forall a b. (a -> b) -> a -> b
$ String -> Element
mwText (String -> Element) -> String -> Element
forall a b. (a -> b) -> a -> b
$ IRI -> String
showIRI IRI
i
setPref :: String -> Element -> Element
setPref :: String -> Element -> Element
setPref s :: String
s e :: Element
e = Element
e {elAttribs :: [Attr]
elAttribs = Attr :: QName -> String -> Attr
Attr {attrKey :: QName
attrKey = String -> QName
makeQN "name"
, attrVal :: String
attrVal = String
s} Attr -> [Attr] -> [Attr]
forall a. a -> [a] -> [a]
: Element -> [Attr]
elAttribs Element
e}
set1Map :: (String, IRI) -> Element
set1Map :: (String, IRI) -> Element
set1Map (s :: String
s, iri :: IRI
iri) = String -> Element -> Element
setPref String
s (Element -> Element) -> Element -> Element
forall a b. (a -> b) -> a -> b
$ IRI -> Element
mwIRI IRI
iri
xmlPrefixes :: GA.PrefixMap -> [Element]
xmlPrefixes :: PrefixMap -> [Element]
xmlPrefixes pm :: PrefixMap
pm = let allpm :: PrefixMap
allpm = PrefixMap -> PrefixMap -> PrefixMap
forall k a. Ord k => Map k a -> Map k a -> Map k a
Map.union PrefixMap
pm (PrefixMap -> PrefixMap) -> PrefixMap -> PrefixMap
forall a b. (a -> b) -> a -> b
$ PrefixMap
predefPrefixesGA in
((String, IRI) -> Element) -> [(String, IRI)] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map (String -> Element -> Element
setName String
prefixK (Element -> Element)
-> ((String, IRI) -> Element) -> (String, IRI) -> Element
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String, IRI) -> Element
set1Map) ([(String, IRI)] -> [Element]) -> [(String, IRI)] -> [Element]
forall a b. (a -> b) -> a -> b
$ PrefixMap -> [(String, IRI)]
forall k a. Map k a -> [(k, a)]
Map.toList PrefixMap
allpm
setOntIRI :: Maybe OntologyIRI -> Element -> Element
setOntIRI :: Maybe IRI -> Element -> Element
setOntIRI mIri :: Maybe IRI
mIri e :: Element
e = case Maybe IRI
mIri of
Nothing -> Element
e
Just iri :: IRI
iri -> Element
e { elAttribs :: [Attr]
elAttribs = Attr :: QName -> String -> Attr
Attr {
attrKey :: QName
attrKey = String -> QName
makeQN "ontologyIRI"
, attrVal :: String
attrVal = IRI -> String
showIRI IRI
iri } Attr -> [Attr] -> [Attr]
forall a. a -> [a] -> [a]
: Element -> [Attr]
elAttribs Element
e }
setOntVersionIRI :: Maybe OntologyIRI -> Element -> Element
setOntVersionIRI :: Maybe IRI -> Element -> Element
setOntVersionIRI mIri :: Maybe IRI
mIri e :: Element
e = case Maybe IRI
mIri of
Nothing -> Element
e
Just iri :: IRI
iri -> Element
e { elAttribs :: [Attr]
elAttribs = Attr :: QName -> String -> Attr
Attr {
attrKey :: QName
attrKey = String -> QName
makeQN "versionIRI"
, attrVal :: String
attrVal = IRI -> String
showIRI IRI
iri } Attr -> [Attr] -> [Attr]
forall a. a -> [a] -> [a]
: Element -> [Attr]
elAttribs Element
e }
setBase :: String -> Element -> Element
setBase :: String -> Element -> Element
setBase s :: String
s e :: Element
e = Element
e {elAttribs :: [Attr]
elAttribs = Attr :: QName -> String -> Attr
Attr {attrKey :: QName
attrKey = QName
nullQN {qName :: String
qName = "base",
qPrefix :: Maybe String
qPrefix = String -> Maybe String
forall a. a -> Maybe a
Just "xml"}, attrVal :: String
attrVal = String
s} Attr -> [Attr] -> [Attr]
forall a. a -> [a] -> [a]
: Element -> [Attr]
elAttribs Element
e}
setXMLNS :: Element -> Element
setXMLNS :: Element -> Element
setXMLNS e :: Element
e = Element
e {elAttribs :: [Attr]
elAttribs = Attr :: QName -> String -> Attr
Attr {attrKey :: QName
attrKey = String -> QName
makeQN "xmlns", attrVal :: String
attrVal =
"http://www.w3.org/2002/07/owl#"} Attr -> [Attr] -> [Attr]
forall a. a -> [a] -> [a]
: Element -> [Attr]
elAttribs Element
e}
xmlOntologyDoc :: Sign -> OntologyDocument -> Element
xmlOntologyDoc :: Sign -> OntologyDocument -> Element
xmlOntologyDoc s :: Sign
s od :: OntologyDocument
od =
let ont :: Ontology
ont = OntologyDocument -> Ontology
ontology OntologyDocument
od
pd :: PrefixMap
pd = OntologyDocument -> PrefixMap
prefixDeclaration OntologyDocument
od
emptyPref :: String
emptyPref = IRI -> String
showIRI (IRI -> String) -> IRI -> String
forall a b. (a -> b) -> a -> b
$ IRI -> Maybe IRI -> IRI
forall a. a -> Maybe a -> a
fromMaybe IRI
dummyIRI (Maybe IRI -> IRI) -> Maybe IRI -> IRI
forall a b. (a -> b) -> a -> b
$ String -> PrefixMap -> Maybe IRI
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup "" PrefixMap
pd
in String -> Element -> Element
setBase String
emptyPref (Element -> Element) -> Element -> Element
forall a b. (a -> b) -> a -> b
$ Element -> Element
setXMLNS
(Element -> Element) -> Element -> Element
forall a b. (a -> b) -> a -> b
$ Maybe IRI -> Element -> Element
setOntIRI (Ontology -> Maybe IRI
mOntologyIRI Ontology
ont)
(Element -> Element) -> Element -> Element
forall a b. (a -> b) -> a -> b
$ Maybe IRI -> Element -> Element
setOntVersionIRI (Ontology -> Maybe IRI
mOntologyVersion Ontology
ont)
(Element -> Element) -> Element -> Element
forall a b. (a -> b) -> a -> b
$ String -> [Element] -> Element
makeElement "Ontology" ([Element] -> Element) -> [Element] -> Element
forall a b. (a -> b) -> a -> b
$ PrefixMap -> [Element]
xmlPrefixes PrefixMap
pd
[Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ (IRI -> Element) -> [IRI] -> [Element]
forall a b. (a -> b) -> [a] -> [b]
map IRI -> Element
xmlImport (Ontology -> [IRI]
importsDocuments Ontology
ont)
[Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ (Axiom -> [Element]) -> [Axiom] -> [Element]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Axiom -> [Element]
xmlAxioms (Ontology -> [Axiom]
axioms Ontology
ont)
[Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ ([Annotation] -> [Element]) -> [[Annotation]] -> [Element]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap [Annotation] -> [Element]
xmlAnnotations [(Ontology -> [Annotation]
ontologyAnnotation Ontology
ont)]
[Element] -> [Element] -> [Element]
forall a. [a] -> [a] -> [a]
++ Sign -> [Element]
signToDec Sign
s
mkODoc :: Sign -> [Named Axiom] -> String
mkODoc :: Sign -> [Named Axiom] -> String
mkODoc s :: Sign
s = Element -> String
ppTopElement (Element -> String)
-> ([Named Axiom] -> Element) -> [Named Axiom] -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sign -> OntologyDocument -> Element
xmlOntologyDoc Sign
s
(OntologyDocument -> Element)
-> ([Named Axiom] -> OntologyDocument) -> [Named Axiom] -> Element
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OntologyMetadata -> PrefixMap -> Ontology -> OntologyDocument
OntologyDocument (OntologySyntaxType -> OntologyMetadata
OntologyMetadata OntologySyntaxType
AS) (PrefixMap -> PrefixMap
changePrefixMapTypeToGA (PrefixMap -> PrefixMap) -> PrefixMap -> PrefixMap
forall a b. (a -> b) -> a -> b
$ Sign -> PrefixMap
prefixMap Sign
s)
(Ontology -> OntologyDocument)
-> ([Named Axiom] -> Ontology) -> [Named Axiom] -> OntologyDocument
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe IRI
-> Maybe IRI -> [IRI] -> [Annotation] -> [Axiom] -> Ontology
Ontology Maybe IRI
forall a. Maybe a
Nothing Maybe IRI
forall a. Maybe a
Nothing [] [] ([Axiom] -> Ontology)
-> ([Named Axiom] -> [Axiom]) -> [Named Axiom] -> Ontology
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Named Axiom -> Axiom) -> [Named Axiom] -> [Axiom]
forall a b. (a -> b) -> [a] -> [b]
map Named Axiom -> Axiom
forall s a. SenAttr s a -> s
sentence