我需要将我的csv文件转换为带有带前缀" api"的元素的XML。 我有这样的WSO2 ESB配置:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
<proxy name="c"
transports="https http local vfs"
startOnLoad="true"
trace="enable">
<description/>
<target>
<inSequence>
<smooks config-key="sm">
<input type="text"/>
<output type="xml"/>
</smooks>
<log level="full"/>
</inSequence>
<outSequence/>
<faultSequence>
<log level="full"/>
</faultSequence>
</target>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.PollInterval">5</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file://D:\test\out</parameter>
<parameter name="transport.vfs.FileURI">file://D:\test</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file://D:\test\fail</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.csv</parameter>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
</proxy>
<localEntry key="sm">
<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:csv="http://www.milyn.org/xsd/smooks/csv-1.2.xsd">
<resource-config selector="org.xml.sax.driver">
<resource>org.milyn.csv.CSVReader</resource>
<param name="fields">code,name</param>
<param name="rootElementName">api:root</param>
<param name="recordElementName">api:rec</param>
</resource-config>
</smooks-resource-list>
</localEntry>
<sequence name="fault">
<log level="full">
<property name="MESSAGE" value="Executing default "fault" sequence"/>
<property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
<property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
</log>
<drop/>
</sequence>
<sequence name="main">
<log/>
<drop/>
</sequence>
</definitions>
没有前缀api它可以工作,否则 - 不是。 我刚刚没有添加名称空间 - 它对我没有帮助。 有人可以帮忙吗?感谢。