class Flight(xsd.ComplexType): tail_number = xsd.Attribute(xsd.String) type = xsd.Attribute(xsd.Integer, use=xsd.Use.OPTIONAL) takeoff_airport = xsd.Element(Airport) takeoff_datetime = xsd.Element(xsd.DateTime, minOccurs=0) landing_airport = xsd.Element(Airport) landing_datetime = xsd.Element(xsd.DateTime, minOccurs=0)
def test_attribute_nil(self): mixed = xsd.Attribute(xsd.Boolean, nillable=True, use=xsd.Use.OPTIONAL) xmlelement = etree.Element("complexType") mixed.render(xmlelement, "mixed", xsd.NIL) expected_xml = b"""<complexType mixed="nil"/>\n""" xml = etree.tostring(xmlelement, pretty_print=True) self.assertEqual(expected_xml, xml)
def test_attribute_false(self): mixed = xsd.Attribute(xsd.Boolean) xmlelement = etree.Element("complexType") mixed.render(xmlelement, "mixed", True) expected_xml = b"""<complexType mixed="true"/>\n""" xml = etree.tostring(xmlelement, pretty_print=True) self.assertEqual(expected_xml, xml)
class PredictorType(xsd.ComplexType): ''' ''' INHERITANCE = None INDICATOR = xsd.Sequence name = xsd.Attribute(xsd.String, use=xsd.Use.REQUIRED) file = xsd.Element(xsd.String) positions = xsd.Element('PositionsType') @classmethod def create(cls, file, positions): instance = cls() instance.file = file instance.positions = positions return instance
class Aircraft(xsd.ComplexType): tail_number = xsd.Attribute(xsd.String)
class Test(xsd.ComplexType): value = xsd.Attribute(xsd.String, nillable=True, use=xsd.Use.OPTIONAL)
class TBody(xsd.ComplexType): parts = xsd.Attribute(xsd.String) tBodyAttributes = xsd.Ref(TBodyAttributes)
class TBodyAttributes(xsd.AttributeGroup): encodingStyle = xsd.Attribute(xsd.String, use=xsd.Use.OPTIONAL) use = xsd.Attribute(xsd.String) namespace = xsd.Attribute(xsd.String)
class A(xsd.ComplexType): name = xsd.Attribute(xsd.String)
class B(A): type = xsd.Attribute(xsd.String)