« Rewrite Rule Engine | Main | OINK Dashboard Widget »

2006-04-02

On Datatypes in Wilbur

One of the features I built into Wilbur but haven't used all that much is mapping of XSD datatypes to Common Lisp data. In my previous post I used a typed literal:

#"2006-04-02T14:45:57-05:00"^^<xsd:dateTime>

To turn this into something Common Lisp can handle, we say

(literal-value *)

and (assuming that * was bound to the particular literal) it returns

3352995745

which is the universal time representation of that particular timestamp. Parsing and conversion of the data values is done only once, and cached with the literal (since literals are immutable in Wilbur).

Wilbur now handles all the basic XSD datatypes. The method literal-value->string is the mapping in the opposite direction. For example, to create the above literal, one could say:

(db-make-literal *db*
                 (literal-value->string !xsd:dateTime 3352995745)
                 :datatype !xsd:dateTime)

Similarily, evaluating

(db-make-literal *db*
                 (literal-value->string !xsd:integer 13)
                 :datatype !xsd:integer)

would return

#"13"^^<xsd:integer>

Posted by ora at 18:53