我在pom.xml中添加了以下依赖项
<dependencies>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-parser-impl</artifactId>
<version>2.1.8</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-parser-api</artifactId>
<version>2.1.8</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-model-api</artifactId>
<version>2.1.8</version>
<type>jar</type>
</dependency>
</dependencies>
然后我试着找到有关如何解析.yang / .yi文件来构建Schema的文档。
我在这里找到了以下示例:
https://docs.opendaylight.org/en/stable-boron/developer-guide/yang-tools.html
StatementStreamSource yangModuleSource == new YangStatementSourceImpl("/example.yang", false);
StatementStreamSource yangModuleSource2 == new YangStatementSourceImpl("/example2.yang", false);
CrossSourceStatementReactor.BuildAction reactor == YangInferencePipeline.RFC6020_REACTOR.newBuild();
reactor.addSources(yangModuleSource, yangModuleSource2);
SchemaContext schemaContext == reactor.buildEffective();
但是我在这些jar中找不到类YangStatementSourceImpl或YinStatementSourceImpl。
所以我的问题是:
BR,
//麦克风
YangStatementStreamSource
和YinStatementStreamSource
。要初始化示例中的第一个流,您现在应该编写
YangTextSchemaSource yangTextSchemaSource = YangTextSchemaSource.forFile(new File("/example.yang"));
StatementStreamSource yangModuleSource = YangStatementStreamSource.create(yangTextSchemaSource);