Hi,
You're right, there is no way to add custom datatype in Owlready... I've added the declare_datatype() global function for that, in the development version on BitBucket.
Here is an example:
class Hex(object):
def __init__(self, value):
self.value = value
def parser(s):
return Hex(int(s, 16))
def unparser(x):
h = hex(x.value)[2:]
if len(h) % 2 != 0: return "0%s" % h
return h
declare_datatype(Hex, "
http://www.w3.org/2001/XMLSchema#hexBinary", parser, unparser)
onto = world.get_ontology("
http://www.test.org/t.owl")
with onto:
class p(Thing >> Hex): pass
class C(Thing): pass
c1 = C()
c1.p.append(Hex(14))
Jiba