77from xmlschema .validators import (
88 XMLSchema ,
99 XMLSchemaValidationError ,
10+ XsdAnyAttribute ,
11+ XsdAnyElement ,
1012 XsdAttribute ,
1113 XsdElement ,
1214 XsdFacet ,
@@ -205,17 +207,18 @@ def _generate_xml_complex_type_element(self, xsd_element: XsdElement) -> Element
205207 xsd_simple_type = xsd_simple_type
206208 )
207209 attribute_name : str
208- xsd_attribute : XsdAttribute
210+ xsd_attribute : XsdAttribute | XsdAnyAttribute
209211 for attribute_name , xsd_attribute in xsd_element .attributes .items ():
210- if xsd_attribute .fixed is not None :
211- xml_element .attrib [attribute_name ] = xsd_attribute .fixed
212- elif xsd_attribute .default is not None and self ._force_default_value :
213- xml_element .attrib [attribute_name ] = xsd_attribute .default
214- else :
215- xml_element .attrib [attribute_name ] = self ._generate_xml_simple_type_value (
216- element_name = attribute_name ,
217- xsd_simple_type = xsd_attribute .type
218- )
212+ if isinstance (xsd_attribute , XsdAttribute ):
213+ if xsd_attribute .fixed is not None :
214+ xml_element .attrib [attribute_name ] = xsd_attribute .fixed
215+ elif xsd_attribute .default is not None and self ._force_default_value :
216+ xml_element .attrib [attribute_name ] = xsd_attribute .default
217+ else :
218+ xml_element .attrib [attribute_name ] = self ._generate_xml_simple_type_value (
219+ element_name = attribute_name ,
220+ xsd_simple_type = xsd_attribute .type
221+ )
219222 return xml_element
220223
221224 def _populate_xml_group_element (self , xml_parent_element : Element , xsd_group : XsdGroup ) -> None :
@@ -233,13 +236,19 @@ def _populate_xml_group_element(self, xml_parent_element: Element, xsd_group: Xs
233236 else :
234237 raise NotImplementedError (f'Unknown group model \' { xsd_group .model } \' ' )
235238
236- def _handle_group_content (self , xml_parent_element : Element , group_content : XsdElement | XsdGroup ) -> None :
239+ def _handle_group_content (
240+ self ,
241+ xml_parent_element : Element ,
242+ group_content : XsdElement | XsdAnyElement | XsdGroup
243+ ) -> None :
237244 number_of_occurrences : int = (
238245 self ._group_content_number_of_occurrences_getter .get_group_content_number_of_occurrences (group_content )
239246 )
240247 for _ in range (number_of_occurrences ):
241248 if isinstance (group_content , XsdElement ):
242249 xml_parent_element .append (self ._generate_xml_element (group_content ))
250+ elif isinstance (group_content , XsdAnyElement ):
251+ pass
243252 elif isinstance (group_content , XsdGroup ):
244253 self ._populate_xml_group_element (xml_parent_element = xml_parent_element , xsd_group = group_content )
245254 else :
0 commit comments