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

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

问题描述

涉足 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 parser 第一行包含有效负载命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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