Validating and filling default values in XML based on XSD in Python
- by PoltoS
I have an XML like
<a>
<b/>
<b c="2"/>
</a>
I have my XSD
<xs:element name="a">
<xs:complexType>
<xs:sequence>
<xs:element name="b" maxOccurs="unbounded">
<xs:attribute name="c" default="1"/>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
I want to use my XSD to validate my original XML and fill all default values:
<a>
<b c="1"/>
<b c="2"/>
</a>
How do I get it in Python?
With validation there is no problem (e.g. XMLSchema). The problem are the default values.