Parsing YANG Model in java

馋奶兔 提交于 2020-05-29 02:30:26

问题


How do I parse YANG models in java ? I need to convert the yang model into a xml format.

I have already tried pyang. But since it is in python, it does not suite my requirement.


回答1:


Yes, that's true.

Use yang-parser-impl from Open daylight. It provides a yang parser and returns a set of parsed modules. Which you can further query to get more node objects.




回答2:


The above API is valid for previous versions. Use the following API for the current version

    YangTextSchemaContextResolver yangContextResolver = YangTextSchemaContextResolver.create("yang-context-resolver");

    yangContextResolver.registerSource(new URL("file:///home/ABA/XXX/Workspaces/ABC/X/config.yang"));
    yangContextResolver.registerSource(new URL("file:///home/ABC/XXX/Workspaces/ABC/X/XXX-YY.yang"));


    Optional<SchemaContext> sc = yangContextResolver.getSchemaContext();


来源:https://stackoverflow.com/questions/24950398/parsing-yang-model-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!