Function: soap-encode-xs-complex-type
soap-encode-xs-complex-type is a byte-compiled function defined in
soap-client.el.gz.
Signature
(soap-encode-xs-complex-type VALUE TYPE)
Documentation
Encode the VALUE according to TYPE.
The data is inserted in the current buffer at the current position.
This is a specialization of soap-encode-value for
soap-xs-complex-type objects.
Source Code
;; Defined in /usr/src/emacs/lisp/net/soap-client.el.gz
(defun soap-encode-xs-complex-type (value type)
"Encode the VALUE according to TYPE.
The data is inserted in the current buffer at the current
position.
This is a specialization of `soap-encode-value' for
`soap-xs-complex-type' objects."
(cl-case (soap-xs-complex-type-indicator type)
(array
(error "Arrays of type soap-encode-xs-complex-type are handled elsewhere"))
((sequence choice all nil)
(let ((type-list (list type))
(type-elements '()))
;; Collect all base types
(let ((base (soap-xs-complex-type-base type)))
(while base
(push base type-list)
(setq base (soap-xs-complex-type-base base))))
;; Collect type elements, eliminating duplicates from the type
;; hierarchy.
(dolist (type type-list)
(dolist (element (soap-xs-complex-type-elements type))
(unless (member element type-elements)
(setq type-elements (append type-elements (list element))))))
(dolist (element type-elements)
(catch 'done
(let ((instance-count 0))
(dolist (candidate (soap-get-candidate-elements element))
(let ((e-name (soap-xs-element-name candidate)))
(if e-name
(let ((e-name (intern e-name)))
(dolist (v value)
(when (equal (car v) e-name)
(incf instance-count)
(soap-encode-value (cdr v) candidate))))
(if (soap-xs-complex-type-indicator type)
(let ((current-point (point)))
;; Check if encoding happened by checking if
;; characters were inserted in the buffer.
(soap-encode-value value candidate)
(when (not (equal current-point (point)))
(incf instance-count)))
(dolist (v value)
(let ((current-point (point)))
(soap-encode-value v candidate)
(when (not (equal current-point (point)))
(incf instance-count))))))))
;; Do some sanity checking
(let* ((indicator (soap-xs-complex-type-indicator type))
(element-type (soap-xs-element-type element))
(reference (soap-xs-element-reference element))
(e-name (or (soap-xs-element-name element)
(and reference
(soap-xs-element-name reference)))))
(cond ((and (eq indicator 'choice)
(> instance-count 0))
;; This was a choice node and we encoded
;; one instance.
(throw 'done t))
((and (not (eq indicator 'choice))
(= instance-count 0)
(not (soap-xs-element-optional? element))
(not (soap-xs-complex-type-optional? type))
(and (soap-xs-complex-type-p element-type)
(not (soap-xs-complex-type-optional-p
element-type))))
(soap-warning
"While encoding %s: missing non-nillable slot %s"
value e-name))
((and (> instance-count 1)
(not (soap-xs-element-multiple? element))
(and (soap-xs-complex-type-p element-type)
(not (soap-xs-complex-type-multiple-p
element-type))))
(soap-warning
(concat "While encoding %s: expected single,"
" found multiple elements for slot %s")
value e-name)))))))))
(t
(error "Don't know how to encode complex type: %s"
(soap-xs-complex-type-indicator type)))))