Пример #1
0
    def set_schema_forms(self, obj: xsd.Schema):
        """
        Set the default form type for elements and attributes.

        Global elements and attributes are by default qualified.
        """
        if self.element_form:
            obj.element_form_default = FormType(self.element_form)
        if self.attribute_form:
            obj.attribute_form_default = FormType(self.attribute_form)

        for child_element in obj.elements:
            child_element.form = FormType.QUALIFIED

        for child_attribute in obj.attributes:
            child_attribute.form = FormType.QUALIFIED
Пример #2
0
 def end_attribute(self, obj: T, element: Element):
     """Assign the schema's default form for attributes if the given
     attribute form is None."""
     if isinstance(
             obj,
             xsd.Attribute) and obj.form is None and self.attribute_form:
         obj.form = FormType(self.attribute_form)
Пример #3
0
 def end_element(self, obj: T, element: Element):
     """Assign the schema's default form for elements if the given element
     form is None."""
     if isinstance(obj,
                   xsd.Element) and obj.form is None and self.element_form:
         obj.form = FormType(self.element_form)