MCPcopy Create free account
hub / github.com/sissaschool/xmlschema / DataElement

Class DataElement

xmlschema/dataobjects.py:33–425  ·  view source on GitHub ↗

Data Element, an Element like object with decoded data and schema bindings. :param tag: a string containing a QName in extended format. :param value: the simple typed value of the element. :param attrib: the typed attributes of the element. :param nsmap: an optional map from pr

Source from the content-addressed store, hash-verified

31
32
33class DataElement(MutableSequence['DataElement']):
34 """
35 Data Element, an Element like object with decoded data and schema bindings.
36
37 :param tag: a string containing a QName in extended format.
38 :param value: the simple typed value of the element.
39 :param attrib: the typed attributes of the element.
40 :param nsmap: an optional map from prefixes to namespaces.
41 :param xsd_element: an optional XSD element association.
42 :param xsd_type: an optional XSD type association. Can be provided \
43 also if the instance is not bound with an XSD element.
44 """
45 _children: list['DataElement']
46 tag: str
47 attrib: dict[str, Any]
48 nsmap: dict[str, str]
49
50 value: Optional[Any] = None
51 tail: Optional[str] = None
52 xmlns: Optional[list[tuple[str, str]]] = None
53 xsd_element: Optional['XsdElement'] = None
54 xsd_type: Optional[BaseXsdType] = None
55 _encoder: Optional['XsdElement'] = None
56
57 def __init__(self, tag: str,
58 value: Optional[Any] = None,
59 attrib: Optional[dict[str, Any]] = None,
60 nsmap: Optional[MutableMapping[str, str]] = None,
61 xmlns: Optional[list[tuple[str, str]]] = None,
62 xsd_element: Optional['XsdElement'] = None,
63 xsd_type: Optional[BaseXsdType] = None) -> None:
64
65 super().__init__()
66 self._children = []
67 self.tag = tag
68 self.attrib = {}
69 self.nsmap = {}
70
71 if value is not None:
72 self.value = value
73 if attrib is not None:
74 self.attrib.update(attrib)
75 if nsmap is not None:
76 self.nsmap.update(nsmap)
77 if xmlns is not None:
78 self.xmlns = xmlns
79
80 if xsd_element is not None:
81 self.xsd_element = xsd_element
82 self.xsd_type = xsd_type or xsd_element.type
83 elif xsd_type is not None:
84 self.xsd_type = xsd_type
85 elif self.xsd_element is not None:
86 self._encoder = self.xsd_element
87
88 @overload
89 def __getitem__(self, i: int) -> 'DataElement': ... # pragma: no cover
90

Callers 14

test_reprMethod · 0.90
test_valueMethod · 0.90
test_attributesMethod · 0.90
test_nsmapMethod · 0.90
test_text_valueMethod · 0.90
test_namespaceMethod · 0.90
test_xsd_versionMethod · 0.90
test_xsd_type_bindingMethod · 0.90
test_schema_bindingsMethod · 0.90

Calls

no outgoing calls

Tested by 14

test_reprMethod · 0.72
test_valueMethod · 0.72
test_attributesMethod · 0.72
test_nsmapMethod · 0.72
test_text_valueMethod · 0.72
test_namespaceMethod · 0.72
test_xsd_versionMethod · 0.72
test_xsd_type_bindingMethod · 0.72
test_schema_bindingsMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…