Ask Your Question

How to parse Yang file to corresponding Java code?

asked 2015-06-05 13:30:02 -0700

shrenik gravatar image

updated 2015-06-05 13:30:29 -0700

I want parse my yang model to convert to corresponding java implementation. The repo I found was opendaylight. But since I'm new to this I need to know how to go about it. Maybe I just want to know which methods to be called and point it to my yang file which will do my job.

I found out that I could use this YangParserImpl parser = new YangParserImpl(); and call the method parseFile on the parser. For eg: parser.parseFie(new File(FIle),new File(FIle).getParentFile()): however I don't understand the return type for this particular method. There were few methods like ParseYangModels which are deprecated now. Is this way the correct way to do it, and also if anyone could tell me about what the return type of parseFile method and will it eventually help me parsing the yang to java?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-06-08 01:22:08 -0700

Dana gravatar image

Yangtools does parse your yang files automatically. You need to create maven project with your model in src/main/yang . Include yang-maven-plugin in your pom file. Check existing ODL projects for reference.

edit flag offensive delete publish link more


Thanks for the reply. I used the yang-parser-impl to parse the yang file.. So I'm guessing that to generate code corresponding to that I will need to use the code-generation part of the repo? Also earlier when I downloaded the yangtools repo it did not build perfectly so thats why I decided to build only those parts of the repo that were used by me.

shrenik ( 2015-06-08 07:21:32 -0700 )edit

If you want to do it manually, yes.

Dana ( 2015-06-09 02:12:15 -0700 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

1 follower


Asked: 2015-06-05 13:30:02 -0700

Seen: 548 times

Last updated: Jun 08 '15