10. A computer-readable storage medium that stores instructions which, when executed by one or more processors, cause the one or more processors to perform the steps of: a SQL/XML compiler rewriting a XQuery query that includes a XQuery function to generate a rewritten query, wherein said XQuery query applies XML data to said XQuery function, wherein rewriting said XQuery query includes: during compile time, said SQL/XML compiler determining that said XML data is dynamically typed; and in response to determining that said XML data is dynamically typed, said SQL/XML compiler replacing said XQuery function with an SQL polymorphic function that is able to handle a range of XML data types and performs type checking when computed at run time, said rewritten query applying said XML data to said SQL polymorphic function and typing said XML data as XMLType.
10. A computer-readable storage medium that stores instructions which, when executed by one or more processors, cause the one or more processors to perform the steps of: a SQL/XML compiler rewriting a XQuery query that includes a XQuery function to generate a rewritten query, wherein said XQuery query applies XML data to said XQuery function, wherein rewriting said XQuery query includes: during compile time, said SQL/XML compiler determining that said XML data is dynamically typed; and in response to determining that said XML data is dynamically typed, said SQL/XML compiler replacing said XQuery function with an SQL polymorphic function that is able to handle a range of XML data types and performs type checking when computed at run time, said rewritten query applying said XML data to said SQL polymorphic function and typing said XML data as XMLType. 15. The computer-readable storage medium of claim 10 , wherein the XQuery function is an XQuery order-by construct in a FLWOR expression.