Генерация XML из списка в Python
Я хочу сгенерировать XML-Scheme/XSD из списков. Форма Пути представляет собой список, как например:
l1 = ['Customers', 'CustomerType', 'B2B', 'Industry', 'Manufacturing', 'ManufactureOfFurniture']
l2 = ['Customers', 'CustomerType', 'B2B', 'Industry', 'Manufacturing', 'ManufactureOfJewellery']
l3 = ['Customers', 'CustomerType', 'B2C', 'Industry' ...]
...
И с диктой, которая содержит все классы в соответствующих списках:
schema_dict = {
"c-customertype-b2b-industry-manufacturingoffurnite" : l1,
"c-customertype-b2b-industry-manufacturingofjewellery": l2, ...
}
И из этого я хочу создать XML-схему следующего вида:
<xs:element name="customers">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="customertype">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="b2b">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="industry"/>
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="manufacturing" type="c-customertype-b2b-industry-manufacturing" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="b2c">
{...}
У меня уже есть простые типы. Значение Last в path должно иметь typename простого типа. СимплТипы выглядят следующим образом:
<xs:simpleType name="c-customertype-b2b-industry-manufacturing" final="restriction">
<xs:restriction base="xs:ENTITY">
<xs:enumeration value="cars" />
<xs:enumeration value="knifes" />
</xs:restriction>
</xs:simpleType>
В настоящее время я работаю с xml.etree.ElementTree над созданием Elements, но я открыт для других предложений.