Function: soap-sample-value-for-xs-simple-type
soap-sample-value-for-xs-simple-type is a byte-compiled function
defined in soap-inspect.el.gz.
Signature
(soap-sample-value-for-xs-simple-type TYPE)
Documentation
Provide a sample value for TYPE, a soap-xs-simple-type.
This is a specialization of soap-sample-value for
soap-xs-simple-type objects.
Source Code
;; Defined in /usr/src/emacs/lisp/net/soap-inspect.el.gz
(defun soap-sample-value-for-xs-simple-type (type)
"Provide a sample value for TYPE, a `soap-xs-simple-type'.
This is a specialization of `soap-sample-value' for
`soap-xs-simple-type' objects."
(append
(mapcar #'soap-sample-value-for-xs-attribute
(soap-xs-type-attributes type))
(cond
((soap-xs-simple-type-enumeration type)
(let ((enumeration (soap-xs-simple-type-enumeration type)))
(and enumeration (seq-random-elt enumeration))))
((soap-xs-simple-type-pattern type)
(format "a string matching %s" (soap-xs-simple-type-pattern type)))
((soap-xs-simple-type-length-range type)
(cl-destructuring-bind (low . high) (soap-xs-simple-type-length-range type)
(cond
((and low high)
(format "a string between %d and %d chars long" low high))
(low (format "a string at least %d chars long" low))
(high (format "a string at most %d chars long" high))
(t "a string OOPS"))))
((soap-xs-simple-type-integer-range type)
(cl-destructuring-bind (min . max) (soap-xs-simple-type-integer-range type)
(cond
((and min max) (+ min (random (- max min))))
(min (+ min (random 10)))
(max (random max))
(t (random 100)))))
((consp (soap-xs-simple-type-base type)) ; an union of values
(let ((base (soap-xs-simple-type-base type)))
(soap-sample-value (and base (seq-random-elt base)))))
((soap-xs-basic-type-p (soap-xs-simple-type-base type))
(soap-sample-value (soap-xs-simple-type-base type))))))