wso2 esb文件处理示例smooks csv解析器第一行包括有效负载命名空间 [英] wso2 esb file processing example smooks csv parser first line includes payload namespace

查看:531
本文介绍了wso2 esb文件处理示例smooks csv解析器第一行包括有效负载命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用WSO2 ESB示例进行操作 http:// wso2 .org / library / articles / 2011/01 / wso2-esb-example-file-processing 但遇到一个问题,当一个简单的csv文件

Dabbling with WSO2 ESB example http://wso2.org/library/articles/2011/01/wso2-esb-example-file-processing but encountering a problem where when a simple csv file

name0,value0
name1,value1
name2,value2
name3,value3

使用此配置通过smooks解析

is parsed by smooks using this configuration

<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" xmlns:csv="http://www.milyn.org/xsd/smooks/csv-1.1.xsd">
<csv:reader fields="name,value" />
</smooks-resource-list>

会导致正确的输出,但第一行包括有效的命名空间不正确

results in largely the correct output but the first line includes the payload namespace which is incorrect

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
    <text xmlns="http://ws.apache.org/commons/ns/payload">name0,value0
name1,value1
name2,value2
name3,value3</text>
</soapenv:Body>
</soapenv:Envelope>

所以当第一个name0值被读取时,它包括那个也不正确。

so when the first name0 value is read it includes the which is also incorrect.

Smooks然后将其转换为

Smooks then converts this into

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
    <csv-set>
        <csv-record number="1">
            <name>&lt;?xml version='1.0' encoding='utf-8'?>&lt;text xmlns="http://ws.apache.org/commons/ns/payload">name0</name>
            <value>value0</value>
        </csv-record>
        <csv-record number="2">
            <name>name1</name>
            <value>value1</value>
        </csv-record>
        <csv-record number="3">
            <name>name2</name>
            <value>value2</value>
        </csv-record>
        <csv-record number="4">
            <name>name3</name>
            <value>value3&lt;/text></value>
        </csv-record>
    </csv-set>
</soapenv:Body>
</soapenv:Envelope>

所以,Smooks做所有要求,因为输入包括最后?然而,它所理解的元素数量被计为4,所以它不像csv应该有一个标题行。我可以通过包括一个标题行来解决(在一定程度上),但是元素计数不正确。我可以通过在csv的最后一行包括回车来解决结束。

So is Smooks doing all it is asked as the input includes the the as last? However, the number of elements it understands are counted as 4 so it isn't as if the csv is supposed to have a header row. I can resolve (to a certain extent) by including a header row but then the element count is incorrect. I can resolve the end closing by just including a carriage return on the last line of csv.

我如何解决这个问题?一年前我找到另一个线程,问同样的问题,但没有答案。

How can I resolve this? I have found one other thread a year ago asking the same question but no answers.

推荐答案

在我的smooks标记

I have sorted this now. In my smooks tag

<smooks xmlns="http://ws.apache.org/ns/synapse" config-key="conf:/smooks-config.xml">
   <input type="text"/>
   <output type="xml"/>
</smooks>

我有第一个输入元素设置为xml。改为文本解决了这个问题。 (在WSO2的GUI编辑器中,它默认有这些元素,而教程根本没有这些元素)。

I had the first input element set to xml. Changing to text solved the issue. (in the GUI editor in WSO2 it defaults to having these elements whereas the tutorial doesn't have these at all).

这篇关于wso2 esb文件处理示例smooks csv解析器第一行包括有效负载命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆