corenova / yang-js

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

[Question] Validate XML data against Yang model. #113

Closed eduardnegru closed 4 years ago

eduardnegru commented 4 years ago

I have a YANG model on disk. I want to validate an XML file against that YANG mode. Is there a way to accomplish this? I saw there is the validate function.

async validateModel() {
            const yangModelData = await fs.readFile(yangModelFilePath, 'utf8');
            const xmlData = await fs.readFile(xmlDataFilePath, 'utf8');
            const yang = new Yang(yangModelData);
            const nConfigJSON = JSON.parse(XmlParser.toJson(xmlData));
            yang.validate(xmlData);
}

But whenever I pass a JSON representation of the XML file I get :

Expression error unknown expression

sekur commented 4 years ago

Please see recent fix for validate at #121. Also, you should be passing in nConfigJSON as input to yang.validate.