简体   繁体   English

杨 model 验证错误。 元素不允许在任何地方,预期的结束标签

[英]Yang model validation error. Element not allowed anywhere, expected end-tag

I have the following YANG model.我有以下YANG model。 I want to validate the model against custom xml data.我想根据自定义 xml 数据验证 model。

module turing-machine {

  namespace "http://example.net/turing-machine";

  prefix "tm";

  description
    "Data model for the Turing Machine.";

  revision 2013-12-27 {
    description
      "Initial revision.";
  }

  /* State data and Configuration */

  container turing-machine {
    list router {
      config false;
      leaf name {
        type string;
      }
      leaf interface {
        type string;
      }
    }
  }
}

The xml I want to validate is:我要验证的 xml 是:

<?xml version="1.0" encoding="utf-8"?>
<!-- file: turing-machine-config.xml -->
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <turing-machine xmlns="http://example.net/turing-machine">
    <router>
      <name>A</name>
    </router>
    <router>
      <interface>B</interface>
    </router>
  </turing-machine>
</config>

The validation is done using the following commands:使用以下命令完成验证:

yang2dsdl -t config model.yang
trang -I rng -O rnc model-config.rng model-config.rnc
yang2dsdl -s -j -b model -t config -v data.xml

The validation results in:验证结果为:

Element `router` not allowed anywhere, expected element end-tag.

Please note that since the child elements are not common inside router and therefore I cannot use a 'config true' because I cannot choose a key, I think that a workaround is to use config false.请注意,由于子元素在路由器内部并不常见,因此我无法使用“config true”,因为我无法选择密钥,我认为解决方法是使用 config false。

The problem is that config is used instead of data inside the xml and inside the validation commands.问题是在 xml 和验证命令中使用了配置而不是数据。 A valid xml is:一个有效的 xml 是:

<?xml version="1.0" encoding="utf-8"?>
<!-- file: turing-machine-config.xml -->
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <turing-machine xmlns="http://example.net/turing-machine">
    <router>
      <name>A</name>
    </router>
    <router>
      <interface>B</interface>
    </router>
  </turing-machine>
</data>

Then in order to validate the following commands must be executed.然后为了验证必须执行以下命令。 Note that -t data is optional since data is the default option anyway.请注意, -t data 是可选的,因为 data 无论如何都是默认选项。

yang2dsdl -t data model.yang
trang -I rng -O rnc model-config.rng model-config.rnc
yang2dsdl -s -j -b model -t data -v data.xml

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 元素类型“标签”必须以匹配的结束标签“</tag> ” - The element type "tag" must be terminated by the matching end-tag "</tag>" "xs:element" 必须由匹配的结束标签 "" 我找不到错误 - "xs:element" must be terminated by the matching end-tag "</xs:element>" i can´t find error 如何解决这个错误“元素类型”头“必须由匹配的结束标记”</ head>“终止>? - How to solve this error “The element type ”head“ must be terminated > by the matching end-tag ”</head>"? TypeError:错误#1085:元素类型“ opi1”必须以匹配的结束标记“ </opi1> ” - TypeError: Error #1085: The element type “opi1” must be terminated by the matching end-tag “</opi1>” XML CDATA错误:元素类型 <X> 必须以匹配的结束标签终止 </X> - XML CDATA error: The element type <X> must be terminated by the matching end-tag </X> 元素类型“META”必须以匹配的结束标签“</META> ” - The element type “META” must be terminated by the matching end-tag “</META>” XSD元素类型不会以匹配的结束标签终止 - XSD element type won't terminate with matching end-tag 元素类型 X 必须由匹配的结束标记终止 - The element type X must be terminated by the matching end-tag 如何在Blogger上的JavaScript中修复匹配的结束标记错误? - How to fix matching end-tag error within JavaScript on Blogger? SaxParseException 元素类型“hr”必须由匹配的结束标记“终止</hr> “。在使用 jaxb 读取 xml 时 - SaxParseException The element type "hr" must be terminated by the matching end-tag "</hr>". while reading xml with jaxb
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM