mbj4668 / pyang

An extensible YANG validator and converter in python
ISC License
537 stars 344 forks source link

yang2dsdl Data model defines no data. error: file ./dsdl.IDCSEpYN #874

Closed luc229516 closed 1 year ago

luc229516 commented 1 year ago

Hi,

I am new to data validation and is trying to use pyang to validate device configurations.

Appreciate if you can share insights on why I am seeing below error and how should I resolve it.

:~/yang_modules# pyang ./ietf-inet-types.yang :~/yang_modules# yang2dsdl -t get-config-reply -v ./int.xml ./ietf-inet-types.yang == Generating RELAX NG schema './ietf-inet-types-get-config-reply.rng' Data model defines no data. error: file ./dsdl.AyXCf0ij xsltRunStylesheet : run failed

llhotka commented 1 year ago

The error message tells it all: the ietf-inet-types module defines just types, so the schema is empty. I wonder what's in your instance data int.xml

luc229516 commented 1 year ago

Hi Ladislav,

int.xml is just a router configuration file get through netconf get-config. I am trying to validate the config piece against .yang and see what can I get. int.zip

In below example when I validate the config against all vendor specific .yangs I have I can get the schema generated: yang2dsdl -t get-config-reply -b jncxrfc -v ./int.xml ./junos*.yang == Generating RELAX NG schema './jncxrfc-get-config-reply.rng' Done. == Generating Schematron schema './jncxrfc-get-config-reply.sch' Done. == Generating DSRL schema './jncxrfc-get-config-reply.dsrl' Done. == Validating grammar and datatypes ...

However eventually the config will be subtree filtered, and thus I tried if I can validate against specific .yang which is related to the filtered config, when I see the data model defines no data error.

Thanks.

llhotka commented 1 year ago

yang2dsdl doesn't support validation against subtrees of the schema.