如何使用 Mule 4 删除 XML 中返回 null 的属性?
我需要使用 dataweave 2.0 从 XML 中删除“null”属性,
我尝试了skipNullOn =“everywhere”,并且skipOnNull =“attribute”仅适用于元素而不适用于属性。
使用skipNullOn时出错:
"Option `skipOnNull` is not valid. Valid options are: `writeDeclaration`, `indent`, `doubleQuoteInDeclaration`, `encoding`, `escapeGT`, `defaultNamespace`, `bufferSize`, `inlineCloseOn`, `onInvalidChar`, `writeNilOnNull`, `escapeCR`, `skipNullOn`, `writeDeclaredNamespaces`, `deferred`
输入XML:
<?xml version="1.0" encoding="UTF-8"?>
<DTOApplication id="Application-1660258480-1493174910" ApplicationNumber="AP-00006354">
<DTOLine id="Line-101746978-972142087" StatusCd="Active" >
<DTOCoverage id="Coverage-1713637162-341585712" CoverageCd="MINP" >
<DTOSteps>
<DTOStep Order="1" Name="Premium" value="8" factor="8"/>
<DTOStep Order="2" Name="Term Factor" value="9" factor="9">
<DTOSteps>
<DTOStep Order="1" Name="Minimum Premium" value="10" factor="10"/>
<DTOStep Order="2" Name="Rated Premium" value="null" factor="null"/>
</DTOSteps>
</DTOStep>
</DTOSteps>
</DTOCoverage>
<DTOCoverage id="Coverage-763105832-915106268" CoverageCd="TRIAL">
<DTOSteps id="Steps-Coverage-763105832-915106268">
<DTOStep Order="1" Name="Premium" value="18" factor="18" />
</DTOSteps>
</DTOCoverage>
</DTOLine>
<DTOCoverage id="Coverage-863105832-915106268" CoverageCd="EBRK" >
<DTOSteps id="Steps-Coverage-863105832-915106268">
<DTOStep Order="1" Name="Base Rate" value="null" factor="null"/>
</DTOSteps>
</DTOCoverage>
</DTOApplication>
预期XML输出:https://github。 com/Manikandan99/Map_request/blob/main/null_removed.xml
有关如何使用 dataweave 删除属性返回“null”的任何想法2.0?
I need to remove "null" attributes from an XML using dataweave 2.0,
I tried skipNullOn="everywhere" and skipOnNull="attribute" is working only on elements not on attributes.
Error on using skipNullOn :
"Option `skipOnNull` is not valid. Valid options are: `writeDeclaration`, `indent`, `doubleQuoteInDeclaration`, `encoding`, `escapeGT`, `defaultNamespace`, `bufferSize`, `inlineCloseOn`, `onInvalidChar`, `writeNilOnNull`, `escapeCR`, `skipNullOn`, `writeDeclaredNamespaces`, `deferred`
Input XML:
<?xml version="1.0" encoding="UTF-8"?>
<DTOApplication id="Application-1660258480-1493174910" ApplicationNumber="AP-00006354">
<DTOLine id="Line-101746978-972142087" StatusCd="Active" >
<DTOCoverage id="Coverage-1713637162-341585712" CoverageCd="MINP" >
<DTOSteps>
<DTOStep Order="1" Name="Premium" value="8" factor="8"/>
<DTOStep Order="2" Name="Term Factor" value="9" factor="9">
<DTOSteps>
<DTOStep Order="1" Name="Minimum Premium" value="10" factor="10"/>
<DTOStep Order="2" Name="Rated Premium" value="null" factor="null"/>
</DTOSteps>
</DTOStep>
</DTOSteps>
</DTOCoverage>
<DTOCoverage id="Coverage-763105832-915106268" CoverageCd="TRIAL">
<DTOSteps id="Steps-Coverage-763105832-915106268">
<DTOStep Order="1" Name="Premium" value="18" factor="18" />
</DTOSteps>
</DTOCoverage>
</DTOLine>
<DTOCoverage id="Coverage-863105832-915106268" CoverageCd="EBRK" >
<DTOSteps id="Steps-Coverage-863105832-915106268">
<DTOStep Order="1" Name="Base Rate" value="null" factor="null"/>
</DTOSteps>
</DTOCoverage>
</DTOApplication>
Expected XML Output : https://github.com/Manikandan99/Map_request/blob/main/null_removed.xml
Any ideas please on how to remove attribute return "null" using dataweave 2.0?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试下面的 DW
DW
输出
Try the below DW
DW
Output