corenova / yang-js

YANG parser and composer
Apache License 2.0
56 stars 18 forks source link

if-feature in feature #62

Closed vcshox closed 5 years ago

vcshox commented 7 years ago
feature feature-foo;
feature feature-bar{
  if-feature foo;
}
container c {
  if-feature "feature-bar";
}

It seems that container c is always active when feature-bar is "on", no matter what feature-foo is. According to RFC if-feature, I think the if-feature in a feature should influence its effectiveness

sekur commented 7 years ago

You're correct, it's just that I have yet to come up with a good way of dealing with feature statements...

It's supposed to denote an external condition outside of the schema and data. The problem is, we need to have this external state known at the time when we eval the schema with data. One possibility is to pass in this information at the time of parse itself. Another way would be to enable the bind operation dealing with feature specially to perform the relationship enforcement. A different way would be to allow configuration state of the Yang parser itself to become aware of the external feature availability state (such as Yang.use syntax).

Let me know if any suggestions.

sekur commented 5 years ago

The latest yang-js enforces if-feature by checking if the referenced feature has a .binding when the schema is being eval. If it finds that the feature does not contain any binding, the parent node containing the if-feature will be removed from the resulting data model.