Validating and filling default values in XML based on XSD in Python
        Posted  
        
            by PoltoS
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by PoltoS
        
        
        
        Published on 2010-06-10T09:43:30Z
        Indexed on 
            2010/06/10
            9:52 UTC
        
        
        Read the original article
        Hit count: 322
        
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.
© Stack Overflow or respective owner