diff options
author | adrianocrestani <adrianocrestani@13f79535-47bb-0310-9956-ffa450edef68> | 2008-07-01 06:16:32 +0000 |
---|---|---|
committer | adrianocrestani <adrianocrestani@13f79535-47bb-0310-9956-ffa450edef68> | 2008-07-01 06:16:32 +0000 |
commit | 7d26a1c96d494640313df50375ed200acac06ebc (patch) | |
tree | 5b005c104df471872b8d6dba69a49df1ef5c544c /java/sca/modules/implementation-xquery/src | |
parent | 2887a53b5caa0e676cdc6c5820ec58b5069f858e (diff) |
-adding to implementation.query support to return more than one result from a xquery execution
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@673004 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/implementation-xquery/src')
-rw-r--r-- | java/sca/modules/implementation-xquery/src/main/java/org/apache/tuscany/sca/implementation/xquery/XQueryInvoker.java | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/java/sca/modules/implementation-xquery/src/main/java/org/apache/tuscany/sca/implementation/xquery/XQueryInvoker.java b/java/sca/modules/implementation-xquery/src/main/java/org/apache/tuscany/sca/implementation/xquery/XQueryInvoker.java index 2190c45e64..2a9673068b 100644 --- a/java/sca/modules/implementation-xquery/src/main/java/org/apache/tuscany/sca/implementation/xquery/XQueryInvoker.java +++ b/java/sca/modules/implementation-xquery/src/main/java/org/apache/tuscany/sca/implementation/xquery/XQueryInvoker.java @@ -46,6 +46,7 @@ import net.sf.saxon.trans.XPathException; import net.sf.saxon.value.Value; import org.apache.tuscany.sca.databinding.saxon.SaxonDataBindingHelper; +import org.apache.tuscany.sca.databinding.saxon.collection.ItemList; import org.apache.tuscany.sca.interfacedef.DataType; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.interfacedef.java.JavaInterface; @@ -106,10 +107,7 @@ public class XQueryInvoker implements Invoker { * object be attached in some way to the invocation request? * 5. All parameters, reference proxies and property values are mapped * to external variables of the XQuery script - * 6. The query is executed and the result is returned depending on its type - * (i.e. it could be either a node NodeInfo or Value object). Currently - * no collections are supported, i.e. if there is more then one element - * in the result only the first one will be returned + * 6. The query is executed and all the results are stored in a ItemList object * * NOTE: During execution of the XQuery a static variable is set with * the current configuration. This variable is used by the NodeInfo transformers @@ -169,15 +167,33 @@ public class XQueryInvoker implements Invoker { } finally { SaxonDataBindingHelper.CURR_EXECUTING_CONFIG = oldConfigValue; } + + ItemList list = new ItemList(); Item item = iterator.next(); - if (item == null) { - return null; + + while (item != null) { + list.add(item); + item = iterator.next(); + } - if (item instanceof NodeInfo) { - return item; - } else { - return Value.asValue(item); + + if (list.size() == 0) { + return null; + + } else if (list.size() == 1) { + + item = list.iterator().next(); + + if (item instanceof NodeInfo) { + return item; + } else { + return Value.asValue(item); + } + } + + return list; + } public Message invoke(Message msg) { |