This code looks as if you are using the Saxon SQL extension, is that right?
If you want to store serialized XML in the database, create a string holding the serialized data, by calling saxon:serialize(), and then store the resulting string.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference