Package RDFClosure :: Module XsdDatatypes
[hide private]
[frames] | no frames]

Source Code for Module RDFClosure.XsdDatatypes

 1  #!/d/Bin/Python/python.exe 
 2  # -*- coding: utf-8 -*- 
 3  # 
 4  """ 
 5  Lists of XSD datatypes and their mutual relationships 
 6   
 7  @requires: U{RDFLib<http://rdflib.net>}, 2.2.2. and higher 
 8  @license: This software is available for use under the U{W3C Software License<http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231>} 
 9  @organization: U{World Wide Web Consortium<http://www.w3.org>} 
10  @author: U{Ivan Herman<a href="http://www.w3.org/People/Ivan/">} 
11   
12  """ 
13   
14  """ 
15  $Id: XsdDatatypes.py,v 1.3 2009/09/11 12:30:46 ivan Exp $ $Date: 2009/09/11 12:30:46 $ 
16  """ 
17   
18  __author__  = 'Ivan Herman' 
19  __contact__ = 'Ivan Herman, ivan@w3.org' 
20  __license__ = u'W3C® SOFTWARE NOTICE AND LICENSE, http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231' 
21   
22  from rdflib.RDF                 import RDFNS as ns_rdf 
23  from rdflib.Literal     import _XSD_NS as ns_xsd 
24  from rdflib.RDFS                import Literal 
25  from rdflib.RDF                 import XMLLiteral 
26   
27  #: The basic XSD types used everywhere; this means not the complete set of day/month types 
28  _Common_XSD_Datatypes = [ 
29          ns_xsd['integer'], ns_xsd['decimal'], ns_xsd['nonNegativeInteger'], ns_xsd['nonPositiveInteger'], 
30          ns_xsd['negativeInteger'], ns_xsd['positiveInteger'], ns_xsd['long'], ns_xsd['int'], ns_xsd['short'], 
31          ns_xsd['byte'], ns_xsd['unsignedLong'], ns_xsd['unsignedInt'], ns_xsd['unsignedShort'], 
32          ns_xsd['unsignedByte'], ns_xsd['float'], ns_xsd['double'], ns_xsd['string'], ns_xsd['normalizedString'], 
33          ns_xsd['token'], ns_xsd['language'], ns_xsd['Name'], ns_xsd['NCName'], ns_xsd['NMTOKEN'], 
34          ns_xsd['boolean'], ns_xsd['hexBinary'], ns_xsd['base64Binary'], ns_xsd['anyURI'], 
35          ns_xsd['dateTimeStamp'], ns_xsd['dateTime'], ns_xsd['time'], ns_xsd['date'], 
36          Literal, XMLLiteral 
37  ] 
38   
39  #: RDFS Datatypes: the basic ones plus the complete set of day/month ones 
40  RDFS_Datatypes   = _Common_XSD_Datatypes + [ ns_xsd['gYearMonth'], ns_xsd['gMonthDay'], ns_xsd['gYear'], ns_xsd['gDay'], ns_xsd['gMonth'] ] 
41   
42  #: OWL RL Datatypes: the basic ones plus plain literal 
43  OWL_RL_Datatypes = _Common_XSD_Datatypes + [ ns_rdf['PlainLiteral'] ] 
44   
45  #: XSD Datatype subsumptions 
46  _Common_Datatype_Subsumptions = { 
47          ns_xsd['dateTimeStamp']                 : [ ns_xsd['dateTime'] ], 
48          ns_xsd['integer']                               : [ ns_xsd['decimal'] ], 
49          ns_xsd['long']                                  : [ ns_xsd['integer'], ns_xsd['decimal'] ], 
50          ns_xsd['int']                                   : [ ns_xsd['long'], ns_xsd['integer'], ns_xsd['decimal'] ], 
51          ns_xsd['short']                                 : [ ns_xsd['int'], ns_xsd['long'], ns_xsd['integer'], ns_xsd['decimal'] ], 
52          ns_xsd['byte']                                  : [ ns_xsd['short'], ns_xsd['int'], ns_xsd['long'], ns_xsd['integer'], ns_xsd['decimal'] ], 
53   
54          ns_xsd['nonNegativeInteger']    : [ ns_xsd['integer'], ns_xsd['decimal'] ], 
55          ns_xsd['positiveInteger']               : [ ns_xsd['nonNegativeInteger'], ns_xsd['integer'], ns_xsd['decimal'] ], 
56          ns_xsd['unsignedLong']                  : [ ns_xsd['nonNegativeInteger'], ns_xsd['integer'], ns_xsd['decimal'] ], 
57          ns_xsd['unsignedInt']                   : [ ns_xsd['unsignedLong'], ns_xsd['nonNegativeInteger'], ns_xsd['integer'], ns_xsd['decimal'] ], 
58          ns_xsd['unsignedShort']                 : [ ns_xsd['unsignedInt'], ns_xsd['unsignedLong'], ns_xsd['nonNegativeInteger'], ns_xsd['integer'], ns_xsd['decimal'] ], 
59          ns_xsd['unsignedByte']                  : [ ns_xsd['unsignedShort'], ns_xsd['unsignedInt'], ns_xsd['unsignedLong'], ns_xsd['nonNegativeInteger'], ns_xsd['integer'], ns_xsd['decimal'] ], 
60   
61          ns_xsd['nonPositiveInteger']    : [ ns_xsd['integer'], ns_xsd['decimal'] ], 
62          ns_xsd['negativeInteger']               : [ ns_xsd['nonPositiveInteger'], ns_xsd['integer'], ns_xsd['decimal'] ], 
63   
64          ns_xsd['normalizedString']              : [ ns_xsd["string"] ], 
65          ns_xsd['token']                                 : [ ns_xsd['normalizedString'], ns_xsd["string"] ], 
66          ns_xsd['language']                              : [ ns_xsd['token'], ns_xsd['normalizedString'], ns_xsd["string"] ], 
67          ns_xsd['Name']                                  : [ ns_xsd['token'], ns_xsd['normalizedString'], ns_xsd["string"] ], 
68          ns_xsd['NCName']                                : [ ns_xsd['Name'], ns_xsd['token'], ns_xsd['normalizedString'], ns_xsd["string"] ], 
69          ns_xsd['NMTOKEN']                               : [ ns_xsd['Name'], ns_xsd['token'], ns_xsd['normalizedString'], ns_xsd["string"] ], 
70  } 
71   
72  #: RDFS Datatype subsumptions: at the moment, there is no extra to XSD 
73  RDFS_Datatype_Subsumptions      = _Common_Datatype_Subsumptions 
74   
75  #: OWL Datatype subsumptions: at the moment, there is no extra to XSD 
76  OWL_Datatype_Subsumptions       = _Common_Datatype_Subsumptions 
77