views:

46

answers:

1
declare function Error:toString($this as javaObject) as xs:string external;

the previous binds a return String() to xs:string. is it possible to return a collection and bind it to an xQuery Sequence, say the following

declare function Error:toList($this as javaObject) as squenceType external;

so that it can be run through a flwr?

A: 

XQuery is a programming language for Xml World. W3C defines XQuery 1.0 Standard for the language.

in that by default XQuery support basic data-types as (int, float, decimal, boolean types ) & complex datatypes as Node, element, Text, Comment etc.

after that "external" keyword for function and variable are mainly for XQuery Engine implementors.

external variable type declaration closely work with the context & custom implementation specific to engine. e.g)

declare external variable $employeJavaObject as javaObject. 
                               or
declare function Error:toString($this as javaObject) as xs:string external;

this means javaObject needs to be defined by XQuery engine and provides marshalling behaviour to it.

I had worked with MarkLogic (4.x) , Zorba (1.4), Saxxon Xquery engine, So far i didn;t find any type of strict programming language related bindings.

comming to your issue-- if your collection is of type String then you can just sent them as sequence of string and get it back.

if you want some kind of robust object mapping system, then you need to develop such framework on top standard XQuery engine wrappers as like

"http://developer.marklogic.com/pubs/4.1/javadoc/com/marklogic/xcc/types/package-frame.html"

or use some kind of XmlBeans Mapper like XmlBeans or Castor.

##--- Editing after searching Looks liks XBird (code.google.com) has some interesting mapping scenrios http://code.google.com/p/xbird/wiki/XmlObjectBinding

I have started looking into this. my expertise is primarily on marklogic.

kadalamittai