如何在WSO2 BPEL中分配当前日期?

时间:2015-04-13 13:53:16

标签: datetime wso2 xquery bpel

我没有找到如何在WSO2 BPEL中分配当前日期的方法。 我试过这个:

$ode:currentEventDateTime

<bpel:from expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">
<![CDATA[$ode:currentEventDateTime]]>
</bpel:from>

它引发了错误:

  

[UndeclaredVariable]尝试引用未声明的变量&#34; currentEventDateTime&#34;在部署时

fn:current-dateTime or current-dateTime()

<bpel:from expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">
<![CDATA[fn:current-dateTime]]>
</bpel:from>
  

故障名称{http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure
  故障消息{http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure:R-Value表达式&#34; {OXPath10Expression fn:current-dateTime}&#34;没有选择任何节点   故障数据无可用数据。

<bpel:from expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">
<![CDATA[fn:current-dateTime()]]>
</bpel:from>

提出:

  

错误{org.wso2.carbon.bpel.ui.fileupload.BPELUploadExecutor} - BPEL流程编译失败。
  org.apache.ode.utils.NSContext $ NSContextException:找不到前缀&#34; fn&#34;的命名空间部署时。

<bpel:from expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">
<![CDATA[current-dateTime()]]>
</bpel:from>
  

故障名称{http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure
  故障消息{http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure:在评估&#34时发生异常; {OXPath10Expression current-dateTime()}&#34;:没有这样的功能当前,日期时间
  故障数据无可用数据。

1 个答案:

答案 0 :(得分:0)

我通过使用xsl转换找到了解决方案 BPEL:

package stackoverflow;

import java.util.*;

public class DemoMain
{
    final static int COUNT_COLUMNS =8;

    public static void main(String[] args) throws IllegalFormatException
    {
        StringBuilder[] attributes = new StringBuilder[COUNT_COLUMNS];
        for (int i=0; i< COUNT_COLUMNS; i++)
        {
            attributes[i]=new StringBuilder();
        }

        for (int numArgs=0; numArgs<args.length; numArgs++)
        {
            String[] values = args[numArgs].split(" *, *");
            if (values.length != COUNT_COLUMNS)
            {
                throw new IllegalArgumentException("invalid number of fields, must be "+ COUNT_COLUMNS);
            }

            int numVal=0;
            for (String val : values)
            {
                attributes[numVal].append(numArgs > 0 ? "," : "").append(val.trim());
                numVal++;
            }
        }

        for (StringBuilder att : attributes)
        {
            System.out.println(att);
        }
    }
}

XSL:

<bpel:copy> 
<bpel:from>bpel:doXslTransform("datetime.xsl", $variable.part)</bpel:from>
<bpel:to part="parameters" variable="var"></bpel:to>
</bpel:copy>