Function: soap-xs-parse-extension-or-restriction

soap-xs-parse-extension-or-restriction is a byte-compiled function defined in soap-client.el.gz.

Signature

(soap-xs-parse-extension-or-restriction NODE)

Documentation

Parse an extension or restriction definition from XML NODE.

Return a soap-xs-complex-type.

Source Code

;; Defined in /usr/src/emacs/lisp/net/soap-client.el.gz
(defun soap-xs-parse-extension-or-restriction (node)
  "Parse an extension or restriction definition from XML NODE.
Return a `soap-xs-complex-type'."
  (cl-assert (memq (soap-l2wk (xml-node-name node))
                   '(xsd:extension xsd:restriction))
             nil
             "unexpected node: %s" (soap-l2wk (xml-node-name node)))
  (let (type
        attributes
        attribute-groups
        array?
        (base (xml-get-attribute-or-nil node 'base)))

    ;; Array declarations are recognized specially, it is unclear to me how
    ;; they could be treated generally...
    (setq array?
          (and (eq (soap-l2wk (xml-node-name node)) 'xsd:restriction)
               (equal base (soap-wk2l "soapenc:Array"))))

    (dolist (def (xml-node-children node))
      (when (consp def)                 ; skip text nodes
        (cl-case (soap-l2wk (xml-node-name def))
          ((xsd:sequence xsd:choice xsd:all)
           (setq type (soap-xs-parse-sequence def)))
          (xsd:attribute
           (if array?
               (let ((array-type
                      (soap-xml-get-attribute-or-nil1 def 'wsdl:arrayType)))
                 (when (and array-type
                            (string-match "^\\(.*\\)\\[\\]$" array-type))
                   ;; Override
                   (setq base (match-string 1 array-type))))
             ;; else
             (push (soap-xs-parse-attribute def) attributes)))
          (xsd:attributeGroup
           (push (soap-xs-parse-attribute-group def) attribute-groups)))))

    (unless type
      (setq type (make-soap-xs-complex-type))
      (when array?
        (setf (soap-xs-complex-type-indicator type) 'array)))

    (setf (soap-xs-complex-type-base type) (soap-l2fq base))
    (setf (soap-xs-complex-type-attributes type) attributes)
    (setf (soap-xs-complex-type-attribute-groups type) attribute-groups)
    type))