Browse 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 13 years ago
parent
commit
e340636418
2 changed files with 34 additions and 4 deletions
  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",

File diff suppressed because it is too large
+ 19 - 1
src/bin/stats/tests/b10-stats-httpd_test.py