Function: soap-decode-any-type

soap-decode-any-type is a byte-compiled function defined in soap-client.el.gz.

Signature

(soap-decode-any-type NODE)

Documentation

Decode NODE using type information inside it.

Source Code

;; Defined in /usr/src/emacs/lisp/net/soap-client.el.gz
(defun soap-decode-any-type (node)
  "Decode NODE using type information inside it."
  ;; If the NODE has type information, we use that...
  (let ((type (soap-xml-get-attribute-or-nil1 node 'xsi:type)))
    (when type
      (setq type (soap-l2fq type)))
    (if type
        (let ((wtype (soap-wsdl-get type soap-current-wsdl 'soap-xs-type-p)))
          (if wtype
              (soap-decode-type wtype node)
            ;; The node has type info encoded in it, but we don't know how
            ;; to decode it...
            (error "Node has unknown type: %s" type)))

      ;; No type info in the node...

      (let ((contents (xml-node-children node)))
        (if (and (= (length contents) 1) (stringp (car contents)))
            ;; contents is just a string
            (car contents)

          ;; we assume the NODE is a sequence with every element a
          ;; structure name
          (let (result)
            (dolist (element contents)
              ;; skip any string contents, assume they are whitespace
              (unless (stringp element)
                (let ((key (xml-node-name element))
                      (value (soap-decode-any-type element)))
                  (push (cons key value) result))))
            (nreverse result)))))))