Author: rr
Date: Fri Sep 25 07:49:30 2009
New Revision: 818759
URL: http://svn.apache.org/viewvc?rev=818759&view=rev
Log:
ODE-667: Fixed simple types conversions for bpel variables + test case
Added:
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/TestAssignDate.bpel
(with props)
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/TestAssignDate.wsdl
(with props)
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/deploy.xml
(with props)
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/test.properties
(with props)
Modified:
ode/trunk/bpel-test/src/test/java/org/apache/ode/test/DataHandling20Test.java
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/HelloXQueryWorld.bpel
ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xpath10/JaxenContexts.java
ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xpath20/JaxpVariableResolver.java
ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xquery10/runtime/XQuery10ExpressionRuntime.java
Modified:
ode/trunk/bpel-test/src/test/java/org/apache/ode/test/DataHandling20Test.java
URL:
http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/DataHandling20Test.java?rev=818759&r1=818758&r2=818759&view=diff
==============================================================================
---
ode/trunk/bpel-test/src/test/java/org/apache/ode/test/DataHandling20Test.java
(original)
+++
ode/trunk/bpel-test/src/test/java/org/apache/ode/test/DataHandling20Test.java
Fri Sep 25 07:49:30 2009
@@ -68,10 +68,19 @@
@Test public void testCounter() throws Throwable {
go("/bpel/2.0/TestCounter");
}
- @Test public void testDate() throws Throwable {
+
+ @Test
+ public void testAssignDate() throws Throwable {
go("/bpel/2.0/TestAssignDate");
}
- @Test public void testMsgDate() throws Throwable {
+
+ @Test
+ public void testAssignDate2() throws Throwable {
+ go("/bpel/2.0/TestAssignDate2");
+ }
+
+ @Test
+ public void testMsgDate() throws Throwable {
go("/bpel/2.0/TestMsgDate");
}
@Test public void testDuration() throws Throwable {
Added:
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/TestAssignDate.bpel
URL:
http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/TestAssignDate.bpel?rev=818759&view=auto
==============================================================================
---
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/TestAssignDate.bpel
(added)
+++
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/TestAssignDate.bpel
Fri Sep 25 07:49:30 2009
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<bpws:process
xmlns:bpws="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sam="http://sample.bpel.org/bpel/sample" exitOnStandardFault="yes"
name="TestAssignDate2" suppressJoinFailure="yes"
targetNamespace="http://sample.bpel.org/bpel/sample"
expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://docs.oasis-open.org/wsbpel/2.0/process/executable
/usr/share/bpel-schema/ws-bpel_executable.xsd">
+ <bpws:import importType="http://schemas.xmlsoap.org/wsdl/"
location="TestAssignDate.wsdl" namespace="http://sample.bpel.org/bpel/sample"/>
+ <bpws:partnerLinks>
+ <bpws:partnerLink myRole="TestAssignDateProvider" name="client"
partnerLinkType="sam:TestAssignDate"/>
+ </bpws:partnerLinks>
+ <bpws:variables>
+ <bpws:variable messageType="sam:TestAssignDateMessage" name="input"/>
+ <bpws:variable messageType="sam:TestAssignDateMessage" name="output"/>
+ <bpws:variable type="xsd:string" name="s"/>
+ <bpws:variable name="d" type="xsd:date"></bpws:variable>
+ <bpws:variable name="dt" type="xsd:dateTime"></bpws:variable>
+ <bpws:variable name="d2" type="xsd:anyType"></bpws:variable>
+ <bpws:variable name="dt2" type="xsd:anyType"></bpws:variable>
+ </bpws:variables>
+ <bpws:sequence name="main">
+ <bpws:receive createInstance="yes" operation="run" partnerLink="client"
portType="sam:TestAssignDate" variable="input"/>
+
+ <bpws:assign>
+ <bpws:copy>
+ <bpws:from>xsd:date('2009-01-02')</bpws:from>
+ <bpws:to>$d</bpws:to>
+ </bpws:copy>
+ <bpws:copy>
+ <bpws:from>xsd:dateTime('2009-02-03T09:34:43')</bpws:from>
+ <bpws:to>$dt</bpws:to>
+ </bpws:copy>
+ <bpws:copy>
+ <bpws:from><bpws:literal><val><val2/></val></bpws:literal></bpws:from>
+ <bpws:to>$d2</bpws:to>
+ </bpws:copy>
+ <bpws:copy>
+ <bpws:from><bpws:literal><val><val2/></val></bpws:literal></bpws:from>
+ <bpws:to>$dt2</bpws:to>
+ </bpws:copy>
+ <bpws:copy>
+ <bpws:from>$d</bpws:from>
+ <bpws:to>$d2/*</bpws:to>
+ </bpws:copy>
+ <bpws:copy>
+ <bpws:from>$dt</bpws:from>
+ <bpws:to>$dt2/*</bpws:to>
+ </bpws:copy>
+ </bpws:assign>
+
+ <bpws:if>
+ <bpws:condition>not( xsd:string($d2/*) = '2009-01-02' and
xsd:string($dt2/*) = '2009-02-03T09:34:43' ) </bpws:condition>
+ <bpws:throw faultName="error"></bpws:throw>
+ </bpws:if>
+
+ <bpws:assign>
+ <bpws:copy>
+ <bpws:from>$dt + xsd:dayTimeDuration ("P1D")</bpws:from>
+ <bpws:to>$dt</bpws:to>
+ </bpws:copy>
+ <bpws:copy>
+ <bpws:from>$d + xsd:dayTimeDuration ("P2D")</bpws:from>
+ <bpws:to>$d</bpws:to>
+ </bpws:copy>
+ </bpws:assign>
+
+ <bpws:if>
+ <bpws:condition>not( xsd:string($d) = '2009-01-04' and xsd:string($dt)
= '2009-02-04T09:34:43' ) </bpws:condition>
+ <bpws:throw faultName="error2"></bpws:throw>
+ </bpws:if>
+
+ <bpws:assign>
+ <bpws:copy>
+ <bpws:from>xsd:date('2009-01-02Z')</bpws:from>
+ <bpws:to>$d</bpws:to>
+ </bpws:copy>
+ <bpws:copy>
+ <bpws:from>xsd:dateTime('2009-02-03T09:34:43Z')</bpws:from>
+ <bpws:to>$dt</bpws:to>
+ </bpws:copy>
+ <bpws:copy>
+ <bpws:from>$d</bpws:from>
+ <bpws:to>$d2/*</bpws:to>
+ </bpws:copy>
+ <bpws:copy>
+ <bpws:from>$dt</bpws:from>
+ <bpws:to>$dt2/*</bpws:to>
+ </bpws:copy>
+ </bpws:assign>
+
+ <bpws:if>
+ <bpws:condition>not( xsd:string($d2/*) = '2009-01-02Z' and
xsd:string($dt2/*) = '2009-02-03T09:34:43Z' ) </bpws:condition>
+ <bpws:throw faultName="error"></bpws:throw>
+ </bpws:if>
+
+ <bpws:assign>
+ <bpws:copy>
+ <bpws:from>'OK'</bpws:from>
+ <bpws:to>$output.payload</bpws:to>
+ </bpws:copy>
+ </bpws:assign>
+
+ <bpws:reply operation="run" partnerLink="client" variable="output"/>
+ </bpws:sequence>
+</bpws:process>
+
+
Propchange:
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/TestAssignDate.bpel
------------------------------------------------------------------------------
svn:eol-style = native
Added:
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/TestAssignDate.wsdl
URL:
http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/TestAssignDate.wsdl?rev=818759&view=auto
==============================================================================
---
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/TestAssignDate.wsdl
(added)
+++
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/TestAssignDate.wsdl
Fri Sep 25 07:49:30 2009
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
xmlns:tns="http://sample.bpel.org/bpel/sample"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" name="TestAssignDate"
targetNamespace="http://sample.bpel.org/bpel/sample"
+xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+>
+ <message name="TestAssignDateMessage">
+ <part type="xsd:string" name="payload"/>
+ </message>
+ <portType name="TestAssignDate">
+ <operation name="run">
+ <input message="tns:TestAssignDateMessage"/>
+ <output message="tns:TestAssignDateMessage"/>
+ </operation>
+ </portType>
+ <binding name="TestAssignDateBinding" type="tns:TestAssignDate">
+ <wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="run">
+ <wsdlsoap:operation soapAction="opInOut"/>
+ <input>
+ <wsdlsoap:body use="literal"/>
+ </input>
+ <output>
+ <wsdlsoap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="TestAssignDate">
+ <port binding="tns:TestAssignDateBinding" name="TestAssignDate">
+ <wsdlsoap:address
location="http://localhost:8080/ode/processes/TestAssignDate/"/>
+ </port>
+ </service>
+ <plnk:partnerLinkType name="TestAssignDate">
+ <plnk:role name="TestAssignDateProvider"
portType="tns:TestAssignDate"/>
+ </plnk:partnerLinkType>
+</definitions>
Propchange:
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/TestAssignDate.wsdl
------------------------------------------------------------------------------
svn:eol-style = native
Added:
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/deploy.xml
URL:
http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/deploy.xml?rev=818759&view=auto
==============================================================================
--- ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/deploy.xml
(added)
+++ ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/deploy.xml
Fri Sep 25 07:49:30 2009
@@ -0,0 +1,30 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<dd:deploy xmlns:dd="http://www.apache.org/ode/schemas/dd/2007/03"
+ xmlns:sam="http://sample.bpel.org/bpel/sample"
+ >
+
+ <dd:process name="sam:TestAssignDate2" fileName="TestAssignDate.bpel">
+ <dd:provide partnerLink="client">
+ <dd:service name="sam:TestAssignDate" port="TestAssignDate" />
+ </dd:provide>
+ </dd:process>
+</dd:deploy>
+
Propchange:
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/deploy.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/test.properties
URL:
http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/test.properties?rev=818759&view=auto
==============================================================================
---
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/test.properties
(added)
+++
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/test.properties
Fri Sep 25 07:49:30 2009
@@ -0,0 +1,22 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+namespace=http://sample.bpel.org/bpel/sample
+service=TestAssignDate
+operation=run
+request1=<message><payload>run</payload></message>
+response1=.*OK.*
Propchange:
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignDate2/test.properties
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/HelloXQueryWorld.bpel
URL:
http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/HelloXQueryWorld.bpel?rev=818759&r1=818758&r2=818759&view=diff
==============================================================================
---
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/HelloXQueryWorld.bpel
(original)
+++
ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/HelloXQueryWorld.bpel
Fri Sep 25 07:49:30 2009
@@ -97,6 +97,35 @@
<to variable="myVar" part="TestPart"/>
</copy>
</assign>
+ <scope>
+ <variables>
+ <variable name="date" type="xsd:date"></variable>
+ <variable name="dateTime" type="xsd:dateTime"></variable>
+ <variable name="result" type="xsd:string"></variable>
+ </variables>
+ <sequence>
+ <assign>
+ <copy>
+ <from>'2009-01-02'</from>
+ <to>$date</to>
+ </copy>
+ <copy>
+ <from>'2009-01-02T08:34:45'</from>
+ <to>$dateTime</to>
+ </copy>
+ <copy>
+ <from
expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xquery1.0">
+ if ($date + xsd:dayTimeDuration('P3D') =
xsd:date('2009-01-05') and $dateTime + xsd:dayTimeDuration('P2D') =
xsd:dateTime('2009-01-04T08:34:45')) then "OK" else "BAD"
+ </from>
+ <to>$result</to>
+ </copy>
+ </assign>
+ <if>
+ <condition>not($result = 'OK')</condition>
+ <throw faultName="error"></throw>
+ </if>
+ </sequence>
+ </scope>
<reply name="end"
partnerLink="HelloXQueryPartnerLink"
portType="test:HelloXQueryPortType"
Modified:
ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xpath10/JaxenContexts.java
URL:
http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xpath10/JaxenContexts.java?rev=818759&r1=818758&r2=818759&view=diff
==============================================================================
---
ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xpath10/JaxenContexts.java
(original)
+++
ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xpath10/JaxenContexts.java
Fri Sep 25 07:49:30 2009
@@ -23,7 +23,6 @@
import org.apache.ode.bpel.common.FaultException;
import org.apache.ode.bpel.rtrep.v2.*;
import org.apache.ode.utils.DOMUtils;
-import org.apache.ode.utils.xsd.XSTypes;
import org.apache.ode.utils.xsl.XslTransformHandler;
import org.jaxen.Context;
import org.jaxen.Function;
Modified:
ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xpath20/JaxpVariableResolver.java
URL:
http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xpath20/JaxpVariableResolver.java?rev=818759&r1=818758&r2=818759&view=diff
==============================================================================
---
ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xpath20/JaxpVariableResolver.java
(original)
+++
ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xpath20/JaxpVariableResolver.java
Fri Sep 25 07:49:30 2009
@@ -19,12 +19,13 @@
package org.apache.ode.bpel.rtrep.v2.xpath20;
-import java.util.Calendar;
-
import javax.xml.namespace.QName;
import javax.xml.xpath.XPathVariableResolver;
import net.sf.saxon.Configuration;
+import net.sf.saxon.type.AtomicType;
+import net.sf.saxon.type.SchemaType;
+import net.sf.saxon.value.StringValue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -36,7 +37,6 @@
import org.apache.ode.bpel.rtrep.v2.OXsdTypeVarType;
import org.apache.ode.bpel.rtrep.v2.xpath10.OXPath10ExpressionBPEL20;
import org.apache.ode.utils.Namespaces;
-import org.apache.ode.utils.xsd.XSTypes;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@@ -123,15 +123,22 @@
: simpleNode.getOwnerDocument();
String text = simpleNode.getTextContent();
try {
- Object jobj = XSTypes.toJavaObject(type,text);
- if (jobj instanceof Calendar) {
- // Saxon 9.x prefers Dates over Calendars.
- return ((Calendar) jobj).getTime();
- } else if (jobj instanceof String) {
- // Saxon 9.x has a bug for which this is a workaround.
- return doc.createTextNode(jobj.toString());
- }
- return jobj;
+ {
+ int fp = _config.getNamePool().allocate("",
type.getNamespaceURI(), type.getLocalPart());
+ SchemaType type2 = _config.getSchemaType(fp);
+ if (type2 == null || !type2.isAtomicType()) {
+ if (__log.isDebugEnabled()) {
+ __log.debug("converting " + type + " value " + text +
" result: " + null);
+ }
+ return null;
+ } else {
+ Object value = StringValue.convertStringToAtomicType(text,
(AtomicType) type2 , null);
+ if (__log.isDebugEnabled()) {
+ __log.debug("converting " + type + " value " + text +
" result: " + value);
+ }
+ return value;
+ }
+ }
} catch (Exception e) {
// Elegant way failed, trying brute force
try {
Modified:
ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xquery10/runtime/XQuery10ExpressionRuntime.java
URL:
http://svn.apache.org/viewvc/ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xquery10/runtime/XQuery10ExpressionRuntime.java?rev=818759&r1=818758&r2=818759&view=diff
==============================================================================
---
ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xquery10/runtime/XQuery10ExpressionRuntime.java
(original)
+++
ode/trunk/runtimes/src/main/java/org/apache/ode/bpel/rtrep/v2/xquery10/runtime/XQuery10ExpressionRuntime.java
Fri Sep 25 07:49:30 2009
@@ -45,9 +45,13 @@
import net.sf.saxon.Configuration;
import net.sf.saxon.om.Validation;
import net.sf.saxon.trans.DynamicError;
+import net.sf.saxon.trans.XPathException;
+import net.sf.saxon.value.AtomicValue;
import net.sf.saxon.value.DurationValue;
import net.sf.saxon.xqj.SaxonXQConnection;
+import net.sf.saxon.xqj.SaxonXQDataFactory;
import net.sf.saxon.xqj.SaxonXQDataSource;
+import net.sf.saxon.xqj.SaxonXQItem;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -351,34 +355,42 @@
for (QName variable : exp.getAllUnboundExternalVariables()) {
// Evaluate referenced variable
Object value = variableResolver.resolveVariable(variable);
+ if (value instanceof AtomicValue) {
+ AtomicValue v = (AtomicValue) value;
+ try {
+ exp.bindItem(variable, new SaxonXQItem(v.asItem(),
(SaxonXQConnection) xqconn));
+ } catch (XPathException e) {
+ __log.error("", e);
+ }
+ } else {
+
+ // Figure out type of variable
+ XQSequenceType xqType = getItemType(xqconn, value);
+
+ // Saxon doesn't like binding sequences to variables
+ if (value instanceof Node) {
+ // a node is a node-list, but the inverse isn't true.
+ // so, if the value is truly a node, leave it alone.
+ } else if (value instanceof NodeList) {
+ // So extract the first item from the node list
+ NodeList nodeList = (NodeList) value;
+ ArrayList nodeArray = new ArrayList();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ nodeArray.add(nodeList.item(i));
+ }
+ value = xqconn.createSequence(nodeArray.iterator());
+ }
- // Figure out type of variable
- XQSequenceType xqType = getItemType(xqconn, value);
-
- // Saxon doesn't like binding sequences to variables
- if (value instanceof Node) {
- // a node is a node-list, but the inverse isn't true.
- // so, if the value is truly a node, leave it alone.
- } else if (value instanceof NodeList) {
- // So extract the first item from the node list
- NodeList nodeList = (NodeList) value;
- ArrayList nodeArray = new ArrayList();
- for (int i = 0; i < nodeList.getLength(); i++) {
- nodeArray.add(nodeList.item(i));
- }
- value = xqconn.createSequence(nodeArray.iterator());
- }
-
-
- // Bind value with external variable
- if (value != null && xqType != null) {
- if (value instanceof XQSequence) {
- exp.bindSequence(variable, (XQSequence) value);
- } else {
- if (xqType instanceof XQItemType) {
- exp.bindObject(variable, value,
(XQItemType) xqType);
- }
- }
+ // Bind value with external variable
+ if (value != null && xqType != null) {
+ if (value instanceof XQSequence) {
+ exp.bindSequence(variable, (XQSequence) value);
+ } else {
+ if (xqType instanceof XQItemType) {
+ exp.bindObject(variable, value,
(XQItemType) xqType);
+ }
+ }
+ }
}
}