CESNET / netopeer2

NETCONF toolset
BSD 3-Clause "New" or "Revised" License
296 stars 187 forks source link

XML tag in RPC response includes xmlns at each node of tree #1430

Closed spodrebersek closed 1 year ago

spodrebersek commented 1 year ago

I have a question concerning XML tags in a YANG RPC response message. Is the inclusion of 'xmlns=...' configurable or always present for child nodes in tree of an RPC response? I do not see them in notifications, or if code prints the parent node using lyd_print_file(stdout, input, LYD_XML, LYD_PRINT_WD_ALL);

I see something like this at client:

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="55">
    <status xmlns="urn:o-ran:file-management:1.0">FAILURE</status>
    <reject-reason xmlns="urn:o-ran:file-management:1.0">Unsupported 'local-logical-file-path'. </reject-reason>
</rpc-reply>

but was expecting child nodes without 'xmls' in tag like this:

<nc:rpc-reply xmlns:nc='urn:ietf:params:xml:ns:netconf:base:1.0' nc:message-id='7407b903-aec3-4f9c-a364-3d28e90f11d8:100'>
    <file-upload xmlns='urn:o-ran:file-management:1.0'>
            <status>FAILURE</status>
            <reject-reason>Unsupported 'local-logical-file-path'. </reject-reason>
    </file-upload>
</nc:rpc-reply>

How can I get it to not show xmlns in child nodes?

michalvasko commented 1 year ago

libyang should use as few namespaces as possible and it is true in this case as well. Your expected reply would not be valid according to NETCONF, in the reply there must not be the operation itself, only the output nodes. Hence the first XML is being sent. It could also be

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="55" xmlns:ormgmt="urn:o-ran:file-management:1.0">
    <ormgmt:status>FAILURE</ormgm:tstatus>
    <ormgm:reject-reason>Unsupported 'local-logical-file-path'. </ormgm:reject-reason>
</rpc-reply>

but that is hardly better, we have opted not to use XML prefixes unless necessary.

spodrebersek commented 1 year ago

Thanks for quick response.