xsdata.formats.dataclass.parsers.utils module¶
-
class
xsdata.formats.dataclass.parsers.utils.
ParserUtils
[source]¶ Bases:
object
-
classmethod
data_type
(attrs, ns_map)[source]¶ Convert the xsi:type attribute to a DataType, defaults to DataType.STRING.
-
classmethod
parse_value
(value, types, default=None, ns_map=None, tokens=False)[source]¶ Convert xml string values to s python primitive type.
-
classmethod
bind_objects
(params, meta, position, objects)[source]¶ Return a dictionary of qualified object names and their values for the given queue item.
-
classmethod
bind_mixed_objects
(params, var, pos, objects)[source]¶ Return a dictionary of qualified object names and their values for the given mixed content xml var.
-
classmethod
bind_var
(params, var, value)[source]¶ Add the given value to the params dictionary with the var name as key.
Wrap the value to a list if var is a list. If the var name already exists it means we have a name conflict and the parser needs to lookup for any available wildcard fields.
-
classmethod
bind_wild_var
(params, var, qname, value)[source]¶ Add the given value to the params dictionary with the wildcard var name as key.
If the key is already present wrap the previous value into a generic AnyElement instance. If the previous value is already a generic instance add the current value as a child object.
-
classmethod
bind_wild_content
(params, var, txt, tail, attrs, ns_map)[source]¶ Extract the text and tail content and bind it accordingly in the params dictionary. Return if any data was bound.
var is a list prepend the text and append the tail.
var is present in the params assign the text and tail to the generic object.
Otherwise bind the given element to a new generic object.
-
classmethod
bind_content
(params, metadata, txt, ns_map)[source]¶ Add the given element’s text content if any to the params dictionary with the text var name as key.
Return if any data was bound.
-
classmethod
bind_attrs
(params, metadata, attrs, ns_map)[source]¶ Parse the given element’s attributes and any text content and return a dictionary of field names and values based on the given class metadata.
-
classmethod
prepare_generic_value
(qname, value)[source]¶ Prepare parsed value before binding to a wildcard field.
-
classmethod
normalize_content
(value)[source]¶ Normalize element text or tail content.
If content is just whitespace return None, otherwise preserve the original content.
-
classmethod