datetimewso2xquerybpel

How to assign current-date in WSO2 BPEL?


I didn't found way how to assign current-date in WSO2 BPEL. I tried this:

$ode:currentEventDateTime

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

It raises error:

[UndeclaredVariable] Attempt to reference undeclared variable "currentEventDateTime" while deploying

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>

Fault Name {http: //docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure
Fault Message {http: //docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure: R-Value expression "{OXPath10Expression fn:current-dateTime}" did not select any nodes.
Fault Data No data available.

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

raises:

ERROR {org.wso2.carbon.bpel.ui.fileupload.BPELUploadExecutor} - BPEL Process Compilation Failure.
org.apache.ode.utils.NSContext$NSContextException: Namespace not found for prefix "fn" while deploying.

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

Fault Name {http: //docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure
Fault Message {http: //docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure: An exception occured while evaluating "{OXPath10Expression current-dateTime()}": No Such Function current-dateTime
Fault Data No data available.


Solution

  • I found solution by using xsl transformation
    BPEL:

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

    XSL:

    <xsl:stylesheet version="1.0">
    <xsl:template match="/">
    <!--variable structure--> 
    <cmism:deliveryDate><xsl:value-of select="current-dateTime()"/>
    </cmism:deliveryDate>
    </xsl:template>
    </xsl:stylesheet>