WSO2 删除文本文件开头的空格
WSO2 Remove Blank Spaces from beginning of text file
我写了一个调用 API 的 WSO2 集成,从 API 调用中获取我想要的属性,将有效负载放在一起,将该有效负载传递给 smooks 中介,右垫每个值都有适当数量的空格,然后写入 .txt 文件。一切都很好 - 除了 - 我的 .txt 文件中每一行的开头都预先添加了几个空格。所以文件看起来像这样:
value value value value
value value value value
而不是这个:
value value value value
value value value value
我的 smooks 生成器填充每个元素的部分如下所示:
<ftl:freemarker applyOnElement="Employee180">
<ftl:template>
<!--${.vars["Employee180"].RecordType?right_pad(3)}${.vars["Employee180"].BlankSpace1?right_pad(1)}${.vars["Employee180"].ContractNumber?right_pad(6)}${.vars["Employee180"].BlankSpace2?right_pad(1)}${.vars["Employee180"].EmployeeIDNumber?right_pad(9)?replace("-","")}${.vars["Employee180"].BlankSpace3?right_pad(1)}${.vars["Employee180"].EmployeeName?right_pad(24)}${.vars["Employee180"].DateOfBirth?right_pad(10)}${.vars["Employee180"].BlankSpace4?right_pad(1)}${.vars["Employee180"].DateOfEmployment?right_pad(10)}${.vars["Employee180"].BlankSpace5?right_pad(1)}${.vars["Employee180"].Sex?right_pad(1)}${.vars["Employee180"].BlankSpace6?right_pad(8)}${.vars["Employee180"].SocialSecurityNumber?right_pad(9)}${.vars["Employee180"].BlankSpace7?right_pad(133)}${.vars["Employee180"].BenefitEventDate?right_pad(10)}${.vars["Employee180"].BlankSpace8?right_pad(5)}${.vars["Employee180"].BenefitEventReason?right_pad(4)}${.vars["Employee180"].BlankSpace9?right_pad(3)}${'\r\n'}-->
</ftl:template>
</ftl:freemarker>
我不确定这是否是开始空格的原因,或者它是否是 .txt 的实际创建。文件。为此,我正在这样做:
<property expression="fn:concat(get-property('ContractNumber'), get-property('DATE_FOR_FILE'), '.txt')" name="transport.vfs.ReplyFileName" scope="transport" type="STRING" xmlns:ns2="http://org.apache.synapse/xsd"/>
<property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
<property name="messageType" scope="axis2" type="STRING" value="text/plain"/>
<send>
<endpoint name="FileEpr">
<address uri="vfs:file:///O:/myTestFolder/WSO2 Testing?transport.vfs.Append=true">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>1</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</address>
</endpoint>
</send>
有什么想法可以将这些初始空间放入我的文件中吗?或者甚至是一些方便的术语来开始谷歌搜索?到目前为止,我的搜索没有运气。
尝试从您的 Freemarker 模板中删除空格:
<ftl:freemarker applyOnElement="Employee180">
<ftl:template>
<!--${.vars["Employee180"].RecordType?right_pad(3)}${.vars["Employee180"].BlankSpace1?right_pad(1)}${.vars["Employee180"].ContractNumber?right_pad(6)}${.vars["Employee180"].BlankSpace2?right_pad(1)}${.vars["Employee180"].EmployeeIDNumber?right_pad(9)?replace("-","")}${.vars["Employee180"].BlankSpace3?right_pad(1)}${.vars["Employee180"].EmployeeName?right_pad(24)}${.vars["Employee180"].DateOfBirth?right_pad(10)}${.vars["Employee180"].BlankSpace4?right_pad(1)}${.vars["Employee180"].DateOfEmployment?right_pad(10)}${.vars["Employee180"].BlankSpace5?right_pad(1)}${.vars["Employee180"].Sex?right_pad(1)}${.vars["Employee180"].BlankSpace6?right_pad(8)}${.vars["Employee180"].SocialSecurityNumber?right_pad(9)}${.vars["Employee180"].BlankSpace7?right_pad(133)}${.vars["Employee180"].BenefitEventDate?right_pad(10)}${.vars["Employee180"].BlankSpace8?right_pad(5)}${.vars["Employee180"].BenefitEventReason?right_pad(4)}${.vars["Employee180"].BlankSpace9?right_pad(3)}${'\r\n'}-->
</ftl:template>
</ftl:freemarker>
我写了一个调用 API 的 WSO2 集成,从 API 调用中获取我想要的属性,将有效负载放在一起,将该有效负载传递给 smooks 中介,右垫每个值都有适当数量的空格,然后写入 .txt 文件。一切都很好 - 除了 - 我的 .txt 文件中每一行的开头都预先添加了几个空格。所以文件看起来像这样:
value value value value
value value value value
而不是这个:
value value value value
value value value value
我的 smooks 生成器填充每个元素的部分如下所示:
<ftl:freemarker applyOnElement="Employee180">
<ftl:template>
<!--${.vars["Employee180"].RecordType?right_pad(3)}${.vars["Employee180"].BlankSpace1?right_pad(1)}${.vars["Employee180"].ContractNumber?right_pad(6)}${.vars["Employee180"].BlankSpace2?right_pad(1)}${.vars["Employee180"].EmployeeIDNumber?right_pad(9)?replace("-","")}${.vars["Employee180"].BlankSpace3?right_pad(1)}${.vars["Employee180"].EmployeeName?right_pad(24)}${.vars["Employee180"].DateOfBirth?right_pad(10)}${.vars["Employee180"].BlankSpace4?right_pad(1)}${.vars["Employee180"].DateOfEmployment?right_pad(10)}${.vars["Employee180"].BlankSpace5?right_pad(1)}${.vars["Employee180"].Sex?right_pad(1)}${.vars["Employee180"].BlankSpace6?right_pad(8)}${.vars["Employee180"].SocialSecurityNumber?right_pad(9)}${.vars["Employee180"].BlankSpace7?right_pad(133)}${.vars["Employee180"].BenefitEventDate?right_pad(10)}${.vars["Employee180"].BlankSpace8?right_pad(5)}${.vars["Employee180"].BenefitEventReason?right_pad(4)}${.vars["Employee180"].BlankSpace9?right_pad(3)}${'\r\n'}-->
</ftl:template>
</ftl:freemarker>
我不确定这是否是开始空格的原因,或者它是否是 .txt 的实际创建。文件。为此,我正在这样做:
<property expression="fn:concat(get-property('ContractNumber'), get-property('DATE_FOR_FILE'), '.txt')" name="transport.vfs.ReplyFileName" scope="transport" type="STRING" xmlns:ns2="http://org.apache.synapse/xsd"/>
<property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
<property name="messageType" scope="axis2" type="STRING" value="text/plain"/>
<send>
<endpoint name="FileEpr">
<address uri="vfs:file:///O:/myTestFolder/WSO2 Testing?transport.vfs.Append=true">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>1</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</address>
</endpoint>
</send>
有什么想法可以将这些初始空间放入我的文件中吗?或者甚至是一些方便的术语来开始谷歌搜索?到目前为止,我的搜索没有运气。
尝试从您的 Freemarker 模板中删除空格:
<ftl:freemarker applyOnElement="Employee180">
<ftl:template>
<!--${.vars["Employee180"].RecordType?right_pad(3)}${.vars["Employee180"].BlankSpace1?right_pad(1)}${.vars["Employee180"].ContractNumber?right_pad(6)}${.vars["Employee180"].BlankSpace2?right_pad(1)}${.vars["Employee180"].EmployeeIDNumber?right_pad(9)?replace("-","")}${.vars["Employee180"].BlankSpace3?right_pad(1)}${.vars["Employee180"].EmployeeName?right_pad(24)}${.vars["Employee180"].DateOfBirth?right_pad(10)}${.vars["Employee180"].BlankSpace4?right_pad(1)}${.vars["Employee180"].DateOfEmployment?right_pad(10)}${.vars["Employee180"].BlankSpace5?right_pad(1)}${.vars["Employee180"].Sex?right_pad(1)}${.vars["Employee180"].BlankSpace6?right_pad(8)}${.vars["Employee180"].SocialSecurityNumber?right_pad(9)}${.vars["Employee180"].BlankSpace7?right_pad(133)}${.vars["Employee180"].BenefitEventDate?right_pad(10)}${.vars["Employee180"].BlankSpace8?right_pad(5)}${.vars["Employee180"].BenefitEventReason?right_pad(4)}${.vars["Employee180"].BlankSpace9?right_pad(3)}${'\r\n'}-->
</ftl:template>
</ftl:freemarker>