【问题标题】:xml elements with same attribute names getting overriden具有相同属性名称的 xml 元素被覆盖
【发布时间】:2019-04-23 09:53:36
【问题描述】:
My XML Structure looks like below:-   
<element>
 <note nom="Rock" >Roll</note>
 <note nom="Bands" >
   <note nom="Unit" >jayz<note>
   <note nom="Unit" >eminem<note>
   <note nom="Unit" >drake<note>
 </note>
</element>

转换后我只能保留最后一个单位值 Drake。转换期间会覆盖前两个单位值。

Need help with the dataweave transformation (XML to JAVA) 

【问题讨论】:

    标签: mule mule-studio dataweave mule-el mule-esb


    【解决方案1】:

    是的,目前属性正在丢失,但您可以手动映射它们。

    payload.notes.*note map ((note, index) -> {
        (note: note) if note != null,
        (note.@)
    })
    

    将此xml作为输入

    <notes>
      <note nom="Rock" >Roll</note>
      <note nom="Bands"/>
      <note nom="Unit" >jayz</note>
      <note nom="Unit" >eminem</note>
      <note nom="Unit" >drake</note>
    </notes>
    

    话虽如此,下一个版本将有一个新的 writer 标志,以使 json writer 和 java writer 保持属性

    【讨论】:

    • 我希望输出是一个数组列表,例如 {Rock=Roll, Band ={Unit=Jayz,Unit=eminem,unit=drake}}
    • 一个数组列表?看起来更像一张地图
    猜你喜欢
    • 2022-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-10
    • 2015-04-09
    • 1970-01-01
    相关资源
    最近更新 更多