wso2 - WSO2 从文本文件的开头删除空格
问题描述
我编写了一个 WSO2 集成,它调用一个 API,从该 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>
推荐阅读
- html - 我怎样才能让一个 div 站在另一个元素(它下面的元素)的正上方?
- c# - SqlConnection 支持多少并发语句
- spring-boot - Spring Boot 执行器池化HttpClientConnectionManager 指标
- node.js - 无法为nodejs设置路径
- plugins - CENM (Corda Enterprise Network Manager) 1.2 自定义发行工作流插件
- c# - 如何将 directshow 应用程序(C++)的输出转发到 C# 应用程序?
- android - 启动画面内部变窄
- apollo - 将变量传递给外部解析引用
- node.js - 关于通过在 Hyperledger Fabric 中注册为 Nodejs 客户端创建的管理员/用户身份
- r - 通过基于 R 中的邮政编码等分行来创建两个数据集