我必须对来自excel.Input Excel的输入数据进行一级规范化。
现在输出应该是likeOutput文件。我尝试将MEL(将方法定义为全局配置)结合起来使用Dataweave。在数据编织中,我试图调用上面定义为全局配置的方法。此方法无法工作,因为生成的文件是空的。有人能在这个方法中提出更好的方法或问题吗?下面是代码@Manik:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw"
xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
<configuration doc:name="Configuration">
<expression-language>
<global-functions>
def getCompanyName(name){
if (flowVars.companyList contains name) {
return "";
} else {
flowVars.companyList.add(name);
return name;
}
}
</global-functions>
</expression-language>
</configuration>
<file:connector name="File" autoDelete="true" streaming="true" validateConnections="true" doc:name="File" readFromDirectory="C:\Users\Desktop\Mule-Doc"/>
<file:connector name="File1" autoDelete="true" outputAppend="true" streaming="true" validateConnections="true" doc:name="File"/>
<flow name="csvnormalizationFlow">
<file:inbound-endpoint path="C:\Users\Desktop\Mule-Doc" connector-ref="File" responseTimeout="10000" doc:name="File"/>
<set-variable value="#[[]]" variableName="companyList" doc:name="Variable" mimeType="application/csv"/>
<logger message="The payload is-----------------------#[payload]" level="INFO" doc:name="Logger"/>
<dw:transform-message doc:name="Transform Message">
<dw:set-payload><![CDATA[%dw 1.0
%output application/csv header=true
---
payload map {
CompanyName: getCompanyName($.Company),
location:$.Location
}]]></dw:set-payload>
</dw:transform-message>
<file:outbound-endpoint path="C:\Users\Desktop\Output" outputPattern="test.csv" connector-ref="File1" responseTimeout="10000" doc:name="File"/>
</flow>
</mule>发布于 2016-05-12 15:02:46
完整的答案在这里-https://stackoverflow.com/a/37123291/5616671
您能在这里张贴您的flow xml吗?我运行了这段代码,它给了我预期的输出。
发布于 2016-11-22 07:35:01
您可以添加一个空处理程序,取消您的数据编织表达式,并检查是否是有效负载没有写任何东西。下面是一个空句柄的例子。
(payload.listAllFlightsResponse.*return default [])https://stackoverflow.com/questions/37184590
复制相似问题