Skip to content

parse_data with more detailed error  #99

Open
@smark28

Description

@smark28

Hello Team,

I am executing xml validation against yang model.
In the case of yanglint, I see a more detailed description of the error location.
How can I get the same in python?
Thanks

# yanglint openconfig-interfaces.yang logical.xml
libyang err : Invalid identityref "ethernetCsmacd" value - identity not found in module "openconfig-interfaces". (Data location "/openconfig-interfaces:interfaces/interface[name='TenGigE0/0/0/0']/state/type", line number 129.)
# python3 test.py
Traceback (most recent call last):
  File "/libyang_fix/test.py", line 11, in <module>
    dnode = ctx.parse_data_mem(string_component, 'xml', validate_present=True, validate_multi_error=True)
  File "/usr/local/lib/python3.10/site-packages/libyang/context.py", line 411, in parse_data_mem
    return self.parse_data(
  File "/usr/local/lib/python3.10/site-packages/libyang/context.py", line 390, in parse_data
    raise self.error("failed to parse data tree")
libyang.util.LibyangError: failed to parse data tree: Invalid identityref "ethernetCsmacd" value - identity not found in module "openconfig-interfaces".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions