def __init__(self, schema, options): HTMLElement.__init__(self, "pre", cls="servicedef") self.options = options self.text = self.process(self, schema, 0) if type(schema) is reschema.jsonschema.Ref: example = schema.refschema.example elif schema.xmlExample is not None: # XXX/demmer hack to support types that don't have # GL4-compliant XML/JSON self.span().text = "\n\nExample:\n%s\n" % schema.xmlExample example = None else: example = schema.example if example is not None: example_xml = schema.toxml(example) x2 = xml.dom.minidom.parseString(ET.tostring(example_xml)) xs = x2.toprettyxml(indent=" ").split("\n") if re.search("\?xml", xs[0]): # Remove the leading "xml" tag xs = xs[1:] example_str = "\n".join(xs) self.span().text = "\n\nExample:\n%s\n" % example_str
def __init__(self, schema, options): HTMLElement.__init__(self, "pre", cls="servicedef") self.options = options self.process(self, schema, 0) if isinstance(schema, reschema.jsonschema.Ref): example = schema.refschema.example else: example = schema.example if example is not None: self.span().text = ("\n\nExample:\n%s\n" % json.dumps(example, indent=2))