2

名前空間宣言を持つ xml 入力を適切に読み取るために、 ( WSO2 Developer Studio 3.1で) Smooks をセットアップする方法に関するアドバイスが見つかりませんでした。

名前空間がなくても、変換は問題なく機能します。

入力で 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)

さて、何か考えはありますか?

4

1 に答える 1

0

Smooks の代わりに XSLT を使用できませんか? 名前空間の問題を回避できます。

于 2013-07-24T10:48:16.057 に答える