def test_parse_any_element(self): element = Element("foo") element.set("a", "1") element.set("b", "2") element.set( QName(Namespace.XSI.uri, "type").text, QName(Namespace.XS.uri, "float").text ) element.text = "yes" element.tail = "no" actual = ParserUtils.parse_any_element(element) expected = AnyElement( qname=element.tag, text="yes", tail="no", attributes={ "a": "1", "b": "2", QName(Namespace.XSI.uri, "type"): QName(Namespace.XS.uri, "float"), }, ns_map=element.nsmap, ) self.assertEqual(expected, actual) actual = ParserUtils.parse_any_element(element, False) self.assertIsNone(actual.qname)
def parse_element(self, element: Element, objects: List[Any]) -> Tuple: """ Parse the given element attributes/text/tail, find all child objects and mixed content and initialize a new generic element instance. :return: A tuple of the object's qualified name and a new :class:`xsdata.formats.dataclass.models.generics.AnyElement` instance. """ obj = ParserUtils.parse_any_element(element) obj.children = ParserUtils.fetch_any_children(self.position, objects) return self.qname, obj
def parse_element(self, element: Element, objects: List[Any]) -> Tuple: obj = ParserUtils.parse_any_element(element) obj.children = ParserUtils.fetch_any_children(self.position, objects) return self.qname, obj