TypeFox / yang-lsp

A Language Server for YANG
http://www.yang-central.org
Apache License 2.0
51 stars 13 forks source link

Serialization of xpath results in wrong prefix #171

Closed andreasjakobik closed 4 years ago

andreasjakobik commented 4 years ago

Hi,

When parsing and subsequently serializing a yang file the deviation xpaths are changed and become invalid.

Here we use confdc as validator to point out the problem after serialization:

<issuepath># confdc -c ericsson-mf-vdu-deviations.yang 
ericsson-mf-vdu-deviations.yang:22: error: node 'peeParametersList' in module '_3gpp-nr-nrm-gnbdufunction' not found
ericsson-mf-vdu-deviations.yang:29: error: node 'priorityLabel' in module '_3gpp-nr-nrm-gnbdufunction' not found
<issuepath>#

The original file is fine:

# confdc -c ericsson-mf-vdu-deviations.yang 
#

In ericsson-mf-vdu-deviations.yang the correct xpath is

deviation /me3gpp:ManagedElement/gnbdu3gpp:GNBDUFunction/nrcelldu3gpp:NRCellDU/nrcelldu3gpp:attributes/nrcelldu3gpp:priorityLabel {

However, after serialization, this path has become:

deviation /me3gpp:ManagedElement/gnbdu3gpp:GNBDUFunction/nrcelldu3gpp:NRCellDU/nrcelldu3gpp:attributes/gnbdu3gpp:priorityLabel {

Notice that the nrcelldu3gpp prefix has become gnbdu3gpp, which is invalid since the priorityLabel is part of a used grouping, and its prefix must be the same as the data schema node that is using the grouping.

Attached archive contains the original files (in root folder) as well as the generated yang files (in Output/eyang_preprocessor folder) from a preprocessor program using the yang-lsp api.

models.zip

In the case with the ericsson-mf-vdu-deviations.yang file, nothing is supposed to be changed by the preprocessor, however the yang-lsp serializer is changing the xpaths.

The files in archive have been reduced from a bigger set and simplified to a bare minimum while keeping the original structure and naming, in order to be easier to analyze.

It seems the yang-lsp serializer is confused by the multiple augments using the same grouping:

In _3gpp-nr-nrm-gnbdufunction.yang;

   augment "/me3gpp:ManagedElement" {
        list GNBDUFunction {
         ...
          uses mf3gpp:ManagedFunctionGrp;

In _3gpp-nr-nrm-nrcelldu.yang:

   augment "/me3gpp:ManagedElement/gnbdu3gpp:GNBDUFunction" {
        list NRCellDU {
        ...
            uses mf3gpp:ManagedFunctionGrp;
        ....

Both augments uses the same grouping and the second augment augments the first. Herein lies the crux probably.

Thanks, Andreas