将XML转换为JAVA ....默认的assignement

时间:2015-08-30 08:39:56

标签: smooks

我在Smooks中分配默认字符串值时遇到问题。当我为"Unknown"分配默认值<jb:value>时,它不会接受它并抛出错误。

Smooks配置文件:

<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:core="http://www.milyn.org/xsd/smooks/smooks-core-1.3.xsd"
xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.4.xsd">

<jb:bean beanId="ResData" class="java.util.HashMap"
    createOnElement="perReturn" retain="true">
    <jb:value property="TransactionId" data="TransactionId" />
    <jb:value property="amount" data="amount" />
    <jb:value property="subscriberConfirmationNo" data="ConfirmationNo" />
    <jb:value property="errorMessage" data="errorMessage" />
    <jb:value property="status" data="status" />
    <jb:value property="Tokan" data="Tokan" />
    <jb:value property="Freefield1" data="Freefield1" />
</jb:bean>


<jb:bean beanId="ErrorMap" class="java.util.HashMap"
    createOnElement="Body" retain="true">
    <jb:expression property="errorText">
        if(VARS.isdef("ResData"))
        {
        if(ResData.status == "0" )
        {
        return "Success";
        }
        else if(ResData.status == "1")
        {
        return ResData.errorMessage;
        }
        else if(ResData.status == null)
        {
        return "Sorry! Request could not be processed due to a technical issue.
        Status will be updated in 48hrs.";
        }
        else
        {
        return ResData.errorMessage;
        }
        }
        else
        {
        return "Sorry! Request could not be processed due to a technical issue.
        Please try again later.";
        }
    </jb:expression>
    <jb:value property="errorCode" data="Response/perReturn/errorMessage"
        decoder="String" default="Error" />
    <jb:value property="errorFlag" data="Response/perReturn/status"
        decoder="Integer" default="2" />
    <jb:value property="partnerId" data="Body" decoder="String">
        <jb:decodeParam name="valuePreprocess">return "8011";</jb:decodeParam>
    </jb:value>
</jb:bean>

源文件:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sync="http://sync.partner.virtualization.xyzz.com">
<soapenv:Header />
<soapenv:Body>
    <sync:Response>
        <perReturn>
            <TransactionId>123456789</TransactionId>
            <amount>10</amount>
            <ConfirmationNo>0000000000</ConfirmationNo>
            <errorMessage></errorMessage>
            <status>0</status>
            <Tokan>01244243016</Tokan>
            <Freefield1>1437083181</Freefield1>
        </perReturn>
    </sync:Response>
</soapenv:Body>

我添加了Smooks配置文件和源数据。当源文件中的错误消息为空时,我想将错误代码默认为某些文本,但它不起作用。

0 个答案:

没有答案