    "xs:date" str
    "xs:dateTime" str
    "xs:dayTimeDuration" str
-   "xs:decimal" coerce-number
-   "xs:double" coerce-number
+   "xs:decimal" convert-number
+   "xs:double" convert-number
    "xs:duration" str
-   "xs:float" coerce-number
+   "xs:float" convert-number
    ;; Maybe strip hyphens from all Gregorian date-parts?
    ;; or make conform to a particular date type?
    "xs:gDay" str

;;;; Type coercion
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn coerce-number
  "Reads a number from a numeric Java object of a type from
  com.marklogic.xcc.types. Returns nil if not a number. Designed for
  robust number-handling while preventing read-string security

   ;; FIXME XDM keys have only been mocked; unknown if it matches getValueType

   ;; XdmAtomic TODO
   "attribute()" #(.asString %) ;; XdmAttribute TODO
   "binary()" #(.asString %) ;; XdmBinary -- XXX unknown if the key used matches getValueType
   "comment()" #(.asString %) ;; XdmComment
   "document-node()" #(.asString %) ;; XdmDocument
   "duration()" #(.toString %) ;; XdmDuration XXX may only ever come through as xs:duration
   "element()" #(.asString %) ;; XdmElement
   ;; XdmItem TODO
   "text()" #(.asString %)
   ;; XdmText -- XXX unknown if the key used matches getValueType
   "variable()" #(hash-map (.toString (.getName %))
                           (.asString (.getValue %))) ;; XdmVariable -- XXX unknown if the key used matches getValueType

