Source code for xsdata.codegen.handlers.attribute_implied

from xsdata.codegen.mixins import HandlerInterface
from xsdata.codegen.models import Attr
from xsdata.codegen.models import AttrType
from xsdata.codegen.models import Class
from xsdata.models.enums import DataType
from xsdata.models.enums import NamespaceType
from xsdata.models.enums import Tag


[docs]class AttributeImpliedHandler(HandlerInterface): """Add attributes to classes that are implied from the class other properties."""
[docs] @classmethod def process(cls, target: Class): """Add an xs:anyType attribute to the given class if it supports mixed content and doesn't have a wildcard attribute yet.""" if not target.mixed or target.has_wild_attr: return attr = Attr( name="content", local_name="content", index=0, types=[AttrType(name=DataType.ANY_TYPE.code, native=True)], tag=Tag.ANY, namespace=NamespaceType.ANY.value, ) target.attrs.insert(0, attr)