xmlclass/xsdschema.py
changeset 1734 750eeb7230a1
parent 1732 94ffe74e6895
child 1736 7e61baa047f0
equal deleted inserted replaced
1733:dea107dce0c4 1734:750eeb7230a1
    97     for child in children:
    97     for child in children:
    98         if child["type"] == "appinfo":
    98         if child["type"] == "appinfo":
    99             annotation["appinfo"].append((child["source"], child["content"]))
    99             annotation["appinfo"].append((child["source"], child["content"]))
   100         elif child["type"] == "documentation":
   100         elif child["type"] == "documentation":
   101             if child["source"] is not None:
   101             if child["source"] is not None:
   102                 text = "(source: %(source)s):\n%(content)s\n\n"%child
   102                 text = "(source: %(source)s):\n%(content)s\n\n" % child
   103             else:
   103             else:
   104                 text = child["content"] + "\n\n"
   104                 text = child["content"] + "\n\n"
   105             if not annotation["documentation"].has_key(child["language"]):
   105             if not annotation["documentation"].has_key(child["language"]):
   106                 annotation["documentation"] = text
   106                 annotation["documentation"] = text
   107             else:
   107             else:
   834             if not elmtgroup.has_key("elements") or not elmtgroup["order"]:
   834             if not elmtgroup.has_key("elements") or not elmtgroup["order"]:
   835                 raise ValueError("Only group composed of \"sequence\" can be referenced in \"sequence\" element!")
   835                 raise ValueError("Only group composed of \"sequence\" can be referenced in \"sequence\" element!")
   836             elements_tmp = []
   836             elements_tmp = []
   837             for element in elmtgroup["elements"]:
   837             for element in elmtgroup["elements"]:
   838                 if not isinstance(element["elmt_type"], (UnicodeType, StringType)) and element["elmt_type"]["type"] == COMPLEXTYPE:
   838                 if not isinstance(element["elmt_type"], (UnicodeType, StringType)) and element["elmt_type"]["type"] == COMPLEXTYPE:
   839                     elmt_type = "%s_%s"%(elmtgroup["name"], element["name"])
   839                     elmt_type = "%s_%s" % (elmtgroup["name"], element["name"])
   840                     if factory.TargetNamespace is not None:
   840                     if factory.TargetNamespace is not None:
   841                         elmt_type = "%s:%s" % (factory.TargetNamespace, elmt_type)
   841                         elmt_type = "%s:%s" % (factory.TargetNamespace, elmt_type)
   842                     new_element = element.copy()
   842                     new_element = element.copy()
   843                     new_element["elmt_type"] = elmt_type
   843                     new_element["elmt_type"] = elmt_type
   844                     elements_tmp.append(new_element)
   844                     elements_tmp.append(new_element)
  2132     "hexBinary": {
  2132     "hexBinary": {
  2133         "type": SIMPLETYPE,
  2133         "type": SIMPLETYPE,
  2134         "basename": "hexBinary",
  2134         "basename": "hexBinary",
  2135         "extract": GetHexInteger,
  2135         "extract": GetHexInteger,
  2136         "facets": STRING_FACETS,
  2136         "facets": STRING_FACETS,
  2137         "generate": GenerateSimpleTypeXMLText(lambda x: ("%."+str(int(round(len("%X"%x)/2.)*2))+"X")%x),
  2137         "generate": GenerateSimpleTypeXMLText(lambda x: ("%."+str(int(round(len("%X" % x)/2.)*2))+"X") % x),
  2138         "initial": lambda: 0,
  2138         "initial": lambda: 0,
  2139         "check": lambda x: isinstance(x, (IntType, LongType))
  2139         "check": lambda x: isinstance(x, (IntType, LongType))
  2140     },
  2140     },
  2141 
  2141 
  2142     "integer": {
  2142     "integer": {