【问题标题】:How do I config xml namespace for a smooks input file using WSO2?如何使用 WSO2 为 smooks 输入文件配置 xml 命名空间?
【发布时间】:2013-07-08 14:36:10
【问题描述】:

我找不到任何关于如何设置 Smooks(在 WSO2 Developer Studio 3.1 上)以正确读取具有命名空间声明的 xml 输入的建议。

没有命名空间,转换工作正常!

通过在输入中通知 xmlns,我得到了这个异常:

Error on line 5, column 19 in free-marker-template
Expecting a string, date or number here, Expression .vars["order"]["order-items/order-item/@id"] is instead a freemarker.ext.dom.NodeListModel
The problematic instruction:
----------
==> ${.vars["order"]["order-items/order-item/@id"]} [on line 5, column 17 in free-marker-template]

这些都是我的输入和输出:

   <order id='444' xmlns="http://example.com">
            <header>
                <customer number="555">Amila</customer>
            </header>
            <order-items>
                <order-item id='1'>
                    <product>1</product>
                    <quantity>2</quantity>
                    <price>400</price>
                </order-item>
            </order-items>
        </order>
<salesorder>
        <details>
            <orderid></orderid>
            <customer>
                <id></id>
                <name></name>
            </customer>
        </details>
        <itemList>
            <item>
                <id></id>
                <productId></productId>
                <quantity></quantity>
                <price></price>
            </item>
        </itemList>
    </salesorder>

我还根据Smooks site 尝试了 Smooks 核心的命名空间声明:

<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" 
xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd"
xmlns:core="http://www.milyn.org/xsd/smooks/smooks-core-1.4.xsd"
>
  <core:namespaces>
        <core:namespace prefix="ex" uri="http://example.com/"/>
    </core:namespaces>

但由于配置编辑器引发了此异常,因此 IDE 似乎不支持它:

-Value 'org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@53abd5a9 (mixed: null, anyAttribute: null)' is not legal. (platform:/resource/Corp/smooks-config.xml,6,20)

嗯,有什么想法吗?

【问题讨论】:

    标签: eclipse wso2 wso2esb smooks


    【解决方案1】:

    你不能用 XSLT 代替 Smooks 吗?它将避免您遇到的命名空间问题。

    【讨论】:

    • 使用可视化工具是迄今为止创建转换的最佳方式,您同意吗?我想知道为什么 WSO2 还没有修复它。任何的想法?我们会期待这个修复吗?
    猜你喜欢
    • 1970-01-01
    • 2016-11-30
    • 1970-01-01
    • 1970-01-01
    • 2012-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多