-
Notifications
You must be signed in to change notification settings - Fork 314
Closed
Description
#include <stdio.h>
#include <stdlib.h>
#include <libyang/libyang.h>
int main(int argc, char **argv)
{
struct ly_ctx *ctx = ly_ctx_new(".");
if (NULL == ly_ctx_load_module(ctx, "test-module", NULL)){
puts("load module failed");
return 1;
}
struct lyd_node *data = lyd_parse_path(ctx, "test-module.data", LYD_XML, 0);
if (NULL == data){
puts("load data failed");
return 1;
}
lyd_free_withsiblings(data);
ly_ctx_destroy(ctx, NULL);
return 0;
}
test-module.data
<main xmlns="urn:ietf:params:xml:ns:yang:test-module">
<enum>maybe</enum>
<raw>SGVsbG8gd29ybGQh</raw>
<options>strict recursive</options>
<dec64>9.85</dec64>
<i8>8</i8>
<i16>16</i16>
<i32>32</i32>
<i64>64</i64>
<ui8>8</ui8>
<ui16>16</ui16>
<ui32>32</ui32>
<ui64>64</ui64>
<empty/>
<boolean>true</boolean>
<string>str</string>
<id_ref>id_1</id_ref>
<numbers>1</numbers>
<numbers>2</numbers>
<numbers>42</numbers>
</main>
<list xmlns="urn:ietf:params:xml:ns:yang:test-module">
<key>k2</key>
<id_ref>id_2</id_ref>
<union>infinity</union>
</list>
<list xmlns="urn:ietf:params:xml:ns:yang:test-module">
<key>k1</key>
<id_ref>id_1</id_ref>
<union>42</union>
<wireless/>
</list>
test-module.yin
<?xml version="1.0" encoding="UTF-8"?>
<module name="test-module"
xmlns="urn:ietf:params:xml:ns:yang:yin:1"
xmlns:tm="urn:ietf:params:xml:ns:yang:test-module">
<namespace uri="urn:ietf:params:xml:ns:yang:test-module"/>
<prefix value="tm"/>
<organization>
<text>organization</text>
</organization>
<description>
<text>example yang module</text>
</description>
<contact>
<text>example@example.org</text>
</contact>
<container name="main">
<leaf name="enum">
<type name="enumeration">
<enum name="yes">
<value value="1"/>
</enum>
<enum name="no">
<value value="2"/>
</enum>
<enum name="maybe">
<value value="3"/>
</enum>
</type>
</leaf>
<leaf name="options">
<type name="bits">
<bit name="strict"/>
<bit name="recursive"/>
<bit name="logging"/>
</type>
</leaf>
<leaf name="raw">
<type name="binary"/>
</leaf>
<leaf name="dec64">
<type name="decimal64">
<fraction-digits value="2"/>
</type>
</leaf>
<leaf name="i8">
<type name="int8"/>
</leaf>
<leaf name="i16">
<type name="int16"/>
</leaf>
<leaf name="i32">
<type name="int32"/>
</leaf>
<leaf name="i64">
<type name="int64"/>
</leaf>
<leaf name="ui8">
<type name="uint8"/>
</leaf>
<leaf name="ui16">
<type name="uint16"/>
</leaf>
<leaf name="ui32">
<type name="uint32"/>
</leaf>
<leaf name="ui64">
<type name="uint64"/>
</leaf>
<leaf name="empty">
<type name="empty"/>
</leaf>
<leaf name="boolean">
<type name="boolean"/>
</leaf>
<leaf name="string">
<type name="string"/>
</leaf>
<leaf name="id_ref">
<type name="identityref">
<base name="base_id"/>
</type>
</leaf>
<leaf-list name="numbers">
<type name="uint8"/>
</leaf-list>
</container>
<identity name="base_id"/>
<identity name="id_1">
<base name="base_id"/>
</identity>
<identity name="id_2">
<base name="base_id"/>
</identity>
<list name="list">
<key value="key"/>
<leaf name="key">
<type name="string"/>
</leaf>
<leaf name="id_ref">
<type name="identityref">
<base name="base_id"/>
</type>
</leaf>
<leaf name="union">
<type name="union">
<type name="uint8"/>
<type name="enumeration">
<enum name="infinity"/>
</type>
</type>
</leaf>
<container name="wireless">
<presence value="wireless is enabled"/>
<leaf name="vendor_name">
<type name="string"/>
</leaf>
</container>
</list>
</module>
Metadata
Metadata
Assignees
Labels
No labels