The following examples illustrates how to construct a simple leaf-list data node.

The leaf-list nodes can be constructed the same way as regular leaf nodes. However, there might be multiple instances, siblings of the same leaf-list node in the Data Tree.

The following example code illustrates how to construct 3 leaf-list siblings using the same API functions as for leaf node:


    ... 

    /* construct 3 leaf-list entries */ 
    val_value_t *leaflist_value1 = 
        val_make_simval_obj(leaflist_obj, (const xmlChar *)"53", &res); 
    if (!leaflist_value) { 
        return res;
    } 

    val_value_t *leaflist_value2 = 
        val_make_simval_obj(leaflist_obj, (const xmlChar *)"30", &res); 
    if (!leaflist_value) { 
        return res;
    } 

    val_value_t *leaflist_value3 = 
        val_make_simval_obj(leaflist_obj, (const xmlChar *)"80", &res); 
    if (!leaflist_value) { 
        return res;
    } 

   ...


Alternatively, the following example can be used in order to construct multiple leaf-list entries of, for instance, int32 type node and add them to the existent container parent:


    ... 

    status_t res = NO_ERR;
    int32 value = 0; 
    for (value = 10; value <= 15 && res==NO_ERR; value++) { 
        val_value_t *leaflist_value =
            agt_make_int_leaf(parentobj, 
                              leaflistname, 
                              value, 
                              &res);
        if (!leaflist_value) { 
            return res; 
        } 

        /* add a new leaf-list entry into target container */ 
        res = val_child_add(leaflist_value, container_value);
        if (res != NO_ERR) {
           val_free_value(leaflist_value);
        }
    }
   ...


As a result, all the leaf-list entries will be added to the parent container.