Wednesday 2 June 2010

MarkLogic: XQuery: Typeswitching based on input "type"

In a previous post I'd created on Function Overloading in XQuery, there has been a brief discussion (so far) on whether you can overload functions based on type.

This was the given example:


Calling:


Throws this:


Which appears to be part of the spec:
http://www.w3.org/TR/xquery/#ERRXQST0034.

Is there a workaround? The only way around this issue that I know of right now is to use a typeswitch:


Calling:


Will give you the expected results - albeit at the cost of having to write (and manage) more code.

No comments: