acidjunk / pyang

Automatically exported from code.google.com/p/pyang
ISC License
0 stars 0 forks source link

DSDL plugin may think some case-stmt children are mandatory when they are not #113

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Generate dsdl schema for provided module.

What is the expected output? What do you see instead?
Examine generated schema and observe <rng:element name="schex:month-set"> not 
being wrapped in an <rng:optional> despite lack of a corresponding mandatory 
statement in the model. The corresponding YANG leaf references a typedef. The 
leaf before it gets mapped properly (no typedef).

What version of the product are you using? On what operating system?
Latest code on svn. Debugging in Eclipse on Windows.

Please provide any additional information below.
The culprit is the schemanode._element_format(occur) function, which is 
misbehaving, counting its own data node children instead of those of the parent 
node.

Line 217:

  or self.parent.name == "case" and self.data_nodes_count() == 1

, should probably be:

  or self.parent.name == "case" and self.parent.data_nodes_count() == 1

Jernej

Original issue reported on code.google.com by jernej.t...@gmail.com on 20 Oct 2014 at 1:57

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by mbj4...@gmail.com on 20 Oct 2014 at 2:07

GoogleCodeExporter commented 9 years ago
I cannot reproduce this. In the rng schema generated from your module with 
yang2dsdl I get

<optional>
   <element name="schex:month-set">
     <ref name="schedules-example__month-set-type"/>
   </element>
</optional>

Do you use the last version from SVN?

Original comment by lada.lho...@gmail.com on 20 Oct 2014 at 5:31

GoogleCodeExporter commented 9 years ago
It seems we have some weird version mismatch. The line in question is different 
in my schemanode.py, and it's been so for more than one year:

$ git blame -L 220 schemanode.py
b60114dd (lada.lhotka@gmail.com 2013-08-21 13:15:44 +0000 220)             or 
self.parent.name == "case" and len(self.parent.children) == 1):
.... 

Original comment by lada.lho...@gmail.com on 20 Oct 2014 at 6:16

GoogleCodeExporter commented 9 years ago
Oops. It's true. While I did update my repository to the latest version (975), 
Eclipse workspace is not seeing the change. My project seems to be corrupted 
somehow.

Anyways, if this gets generated properly you can close the issue. Sorry about 
this.

Original comment by jernej.t...@gmail.com on 21 Oct 2014 at 6:36

GoogleCodeExporter commented 9 years ago

Original comment by lada.lho...@gmail.com on 21 Oct 2014 at 8:26