xmlrpc::decode_value (private)

 xmlrpc::decode_value node

Defined in packages/xml-rpc/tcl/xml-rpc-procs.tcl

Unpack the data in a value element. Most value elements will have a subnode describing the datatype (e.g. <string> or <int>). If no subnode is present, then we should assume the value is a string.

Parameters:
node (required)
<value> node that we're decoding
Returns:
Returns the contents of the <value> node. If the value is a <struct> then returns the data in a TCL array. If the value is an <array> then returns the data in a TCL list.

Partial Call Graph (max 5 caller/called nodes):
%3 test_xml_rpc_decode_value xml_rpc_decode_value (test xml-rpc) xmlrpc::decode_value xmlrpc::decode_value test_xml_rpc_decode_value->xmlrpc::decode_value test_xml_rpc_fault xml_rpc_fault (test xml-rpc) test_xml_rpc_fault->xmlrpc::decode_value test_xml_rpc_respond xml_rpc_respond (test xml-rpc) test_xml_rpc_respond->xmlrpc::decode_value xml_node_get_children xml_node_get_children (public) xmlrpc::decode_value->xml_node_get_children xml_node_get_children_by_name xml_node_get_children_by_name (public) xmlrpc::decode_value->xml_node_get_children_by_name xml_node_get_content xml_node_get_content (public) xmlrpc::decode_value->xml_node_get_content xml_node_get_first_child xml_node_get_first_child (public) xmlrpc::decode_value->xml_node_get_first_child xml_node_get_name xml_node_get_name (public) xmlrpc::decode_value->xml_node_get_name xmlrpc::invoke xmlrpc::invoke (private) xmlrpc::invoke->xmlrpc::decode_value xmlrpc::parse_response xmlrpc::parse_response (private) xmlrpc::parse_response->xmlrpc::decode_value xmlrpc::test::decode_test_prep xmlrpc::test::decode_test_prep (private) xmlrpc::test::decode_test_prep->xmlrpc::decode_value

Testcases:
xml_rpc_fault, xml_rpc_decode_value, xml_rpc_respond
Source code:
    set result ""
    if {[llength [xml_node_get_children $node]]} {
        # subnode is specified
        set subnode [xml_node_get_first_child $node]
        set datatype [xml_node_get_name $subnode]

        switch -- $datatype {
            string -
            i4 -
            int -
            double -
            base64 {
                set result [xml_node_get_content $subnode]
            }

            boolean {
                set result [string is true [xml_node_get_content $subnode]]
            }

            dateTime.iso8601 {
                set result [clock scan [string trimright [xml_node_get_content $subnode] Z]]
            }

            struct {
                foreach member  [xml_node_get_children_by_name $subnode member] {
                        lappend result  [xml_node_get_content  [xml_node_get_children_by_name  $member name]]
                        lappend result  [xmlrpc::decode_value  [xml_node_get_children_by_name  $member value]]
                    }
            }

            array {
                foreach entry [xml_node_get_children  [xml_node_get_children_by_name  $subnode data]] {
                    lappend result [xmlrpc::decode_value $entry]
                }
            }

            default {
                # we received a tag which is not a recognized datatype.
                ns_log notice xmlrpc::decode_value ignored type: $datatype
            }
        }
    } else {
        # no datatype subnode, therefore, it's a string
        set result [xml_node_get_content $node]
    }
    return $result
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: