CZ-NIC / yangson

GNU Lesser General Public License v3.0
53 stars 20 forks source link

Fix errors in InstanceNode.to_xml() #121

Closed kwatsen closed 2 years ago

kwatsen commented 2 years ago

Previous logic assumes that sn.type exists before testing if sn is a TerminalNode. This PR wraps the existing logic with an if isinstance(sn, TerminalNode) condition.

Also note that the and sn.ns != self.value[1] condition has been removed. Otherwise converted identityrefs produce an invalid XML document and, in any case, it doesn't hurt to redundantly specify an xmlns. FWIW, I was using the Jukebox example. from RFC 8040. This is the identityref that wouldn't convert otherwise:

"genre" : "example-jukebox:alternative"

K.