Parcourir la source

[917] support conversion of the item_type and item_format in the
specfile into the date, time and dataTime datatypes in XSD

Naoki Kambe il y a 13 ans
Parent
commit
e340636418
2 fichiers modifiés avec 34 ajouts et 4 suppressions
  1. 15 3
      src/bin/stats/stats_httpd.py.in
  2. 19 1
      src/bin/stats/tests/b10-stats-httpd_test.py

+ 15 - 3
src/bin/stats/stats_httpd.py.in

@@ -575,13 +575,25 @@ class StatsHttpd:
                         elem.append(complextype)
                         xsd_elem.append(elem)
                     else:
+                        # determine the datatype of XSD
+                        # TODO: Should consider other item_format types
+                        datatype = stats_spec["item_type"] \
+                            if stats_spec["item_type"].lower() != 'real' \
+                            else 'float'
+                        if "item_format" in stats_spec:
+                            item_format = stats_spec["item_format"]
+                            if datatype.lower() == 'string' \
+                                    and item_format.lower() == 'date-time':
+                                 datatype = 'dateTime'
+                            elif datatype.lower() == 'string' \
+                                    and (item_format.lower() == 'date' \
+                                             or item_format.lower() == 'time'):
+                                 datatype = item_format.lower()
                         elem = xml.etree.ElementTree.Element(
                             "element",
                             attrib={
                                 'name' : stats_spec["item_name"],
-                                'type' : stats_spec["item_type"] \
-                                    if stats_spec["item_type"].lower() != 'real' \
-                                    else 'float',
+                                'type' : datatype,
                                 'minOccurs' : "0" \
                                     if stats_spec["item_optional"] \
                                     else "1",

Fichier diff supprimé car celui-ci est trop grand
+ 19 - 1
src/bin/stats/tests/b10-stats-httpd_test.py