【问题标题】:How to generate castor for XML attribute value如何为 XML 属性值生成 castor
【发布时间】:2013-02-04 06:39:44
【问题描述】:

我是脚轮映射的新手,谁能建议我如何为以下 xml 编写脚轮。

<Amt >
    <CustAmt Ccy="USD">35.47</CustAmt>
</Amt>

我特别在寻找属性值的映射。提前致谢。

【问题讨论】:

    标签: castor


    【解决方案1】:

    这是一个例子:

    <class name="mypackage.OrderItem" auto-complete="true">
       <map-to xml="Amt" />
       <field name="custAmt" type="double">
          <bind-xml name="CustAmt" node="element" />
       </field>
    
       <field name="ccy" type="string">
           <bind-xml name="Ccy" node="attribute" location="CustAmt" />
       </field>
    </class>
    

    【讨论】:

      【解决方案2】:
       <class name="mypackage.OrderItem">
              <map-to xml="Amt" />
              <field name="ccy" type="string">
                  <bind-xml name="Ccy" node="attribute"/>
              </field>
              <field name="custAmt" type="double">
                  <bind-xml name="Amt" node="text" />
              </field>
       </class>
      

      【讨论】:

      • 添加一些解释,说明此答案如何帮助 OP 解决当前问题
      猜你喜欢
      • 2011-09-06
      • 1970-01-01
      • 1970-01-01
      • 2012-05-23
      • 1970-01-01
      • 2013-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多