You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The test_xml_config pytest in test-models.py in my xml-improved fork currently comments-out anydA. But if its removal is commented-out in the xml_safe_data() as follows:
OLD:
data2['test:contA'].pop('anydA')
NEW:
#data2['test:contA'].pop('anydA')
And run:
pytest -sxvv -k test_xml_config
Then the following output is produced:
<snip/>
# convert InstanceValue to an XML-encoded string
> xml_obj = inst.to_xml()
tests/test_model.py:741:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
yangson/instance.py:708: in to_xml
et = super().to_xml(filter, element)
yangson/instance.py:540: in to_xml
m.to_xml(filter, child)
yangson/instance.py:540: in to_xml
m.to_xml(filter, child)
yangson/instance.py:507: in to_xml
m = self[cname]
yangson/instance.py:219: in __getitem__
return self._member(key)
yangson/instance.py:580: in _member
self._member_schema_node(name), self.value.timestamp)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <yangson.instance.ObjectMember object at 0x10777d4f0>, name = 'foo:bar'
def _member_schema_node(self: InstanceNode, name: InstanceName) -> DataNode:
qname = self.schema_node._iname2qname(name)
> res = self.schema_node.get_data_child(*qname)
E AttributeError: 'AnydataNode' object has no attribute 'get_data_child'
yangson/instance.py:609: AttributeError
=============================================== short test summary info ===============================================
FAILED tests/test_model.py::test_xml_config - AttributeError: 'AnydataNode' object has no attribute 'get_data_child'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================== 1 failed, 15 deselected in 0.67s ===========================================
The text was updated successfully, but these errors were encountered:
kwatsen
changed the title
AnyDataNode.to_xml() fails
AnydataNode.to_xml() fails
Dec 19, 2020
Since the anydata and anyxml statements are opaque, by definition, how would it be possible to serialize XML?
Maybe the code could blindly walk the data tree, converting namespace prefixes to xmlns entries. Since JSON lists are self-describing, the conversion seems possible.
Of course, this assumes that all the prefixes are recognized, which may not be true. A user-configurable "prefix to xml-namespace" table could be used to assist.
I don't think any general conversion method can work for everybody. For special use cases, I'd suggest to (fork and) extend Yangson in an ad hoc fashion.
@HRogge
The
test_xml_config
pytest intest-models.py
in myxml-improved
fork currently comments-outanydA
. But if its removal is commented-out in thexml_safe_data()
as follows:OLD:
NEW:
And run:
Then the following output is produced:
The text was updated successfully, but these errors were encountered: