Function: rng-xsd-convert-decimal
rng-xsd-convert-decimal is a byte-compiled function defined in
rng-xsd.el.gz.
Signature
(rng-xsd-convert-decimal STRING)
Documentation
Convert a string representing a decimal to an object representing it values.
A decimal value is represented by a vector [SIGN INTEGER-DIGITS
FRACTION-DIGITS] where SIGN is 1 or -1, INTEGER-DIGITS is a string
containing zero or more digits, with no leading zero, and
FRACTION-DIGITS is a string containing zero or more digits with no
trailing digits. For example, -0021.0430 would be represented by [-1
"21" "043"].
Source Code
;; Defined in /usr/src/emacs/lisp/nxml/rng-xsd.el.gz
(defun rng-xsd-convert-decimal (string)
"Convert a string representing a decimal to an object representing it values.
A decimal value is represented by a vector [SIGN INTEGER-DIGITS
FRACTION-DIGITS] where SIGN is 1 or -1, INTEGER-DIGITS is a string
containing zero or more digits, with no leading zero, and
FRACTION-DIGITS is a string containing zero or more digits with no
trailing digits. For example, -0021.0430 would be represented by [-1
\"21\" \"043\"]."
(and (string-match "\\`[ \t\n\r]*\\([-+]\\)?\\(0*\\([1-9][0-9]*\\)?\\(\\.\\([0-9]*[1-9]\\)?0*\\)?\\)[ \t\n\r]*\\'" string)
(let ((digits (match-string 2 string)))
(and (not (string= digits "."))
(not (string= digits ""))))
(let ((integer-digits (match-string 3 string)))
(vector (if (and (equal (match-string 1 string) "-")
;; Normalize -0 to 0
integer-digits)
-1
1)
(or integer-digits "")
(or (match-string 5 string) "")))))