Function: soap-decode-type

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

Signature

(soap-decode-type TYPE NODE)

Documentation

Use TYPE (an xsd type) to decode the contents of NODE.

NODE is an XML node, representing some SOAP encoded value or a reference to another XML node (a multiRef). This function will resolve the multiRef reference, if any, than call a TYPE specific decode function to perform the actual decoding.

Source Code

;; Defined in /usr/src/emacs/lisp/net/soap-client.el.gz
(defun soap-decode-type (type node)
  "Use TYPE (an xsd type) to decode the contents of NODE.

NODE is an XML node, representing some SOAP encoded value or a
reference to another XML node (a multiRef).  This function will
resolve the multiRef reference, if any, than call a TYPE specific
decode function to perform the actual decoding."
  (let ((href (xml-get-attribute-or-nil node 'href)))
    (cond (href
           (catch 'done
             ;; NODE is actually a HREF, find the target and decode that.
             ;; Check first if we already decoded this multiref.

             (let ((decoded (cdr (assoc href soap-decoded-multi-refs))))
               (when decoded
                 (throw 'done decoded)))

             (unless (string-match "^#\\(.*\\)$" href)
               (error "Invalid multiRef: %s" href))

             (let ((id (match-string 1 href)))
               (dolist (mr soap-multi-refs)
                 (let ((mrid (xml-get-attribute mr 'id)))
                   (when (equal id mrid)
                     ;; recurse here, in case there are multiple HREF's
                     (let ((decoded (soap-decode-type type mr)))
                       (push (cons href decoded) soap-decoded-multi-refs)
                       (throw 'done decoded)))))
               (error "Cannot find href %s" href))))
          (t
           (soap-with-local-xmlns node
             (if (equal (soap-xml-get-attribute-or-nil1 node 'xsi:nil) "true")
                 nil
               ;; Handle union types.
               (cond ((listp type)
                      (catch 'done
                        (dolist (union-member type)
                          (let* ((decoder (get (soap-type-of union-member)
                                               'soap-decoder))
                                 (result (ignore-errors
                                           (funcall decoder
                                                    union-member node))))
                            (when result (throw 'done result))))))
                     (t
                      (let ((decoder (get (soap-type-of type) 'soap-decoder)))
                        (cl-assert decoder nil
                                   "no soap-decoder for %s type"
                                   (soap-type-of type))
                        (funcall decoder type node))))))))))