我找不到任何关于如何设置 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 站点尝试了 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)
嗯,有什么想法吗?