dataweave xml 根元素的命名空间声明
dataweave xml namespace declarations at root element
我有一个生成一些 xml.
的数据编织脚本
%dw 1.0
%output application/xml skipNullOn="everywhere"
%namespace soap http://www.w3.org/2003/05/soap-envelope
%namespace ns http://www.mycompany/2015/07
---
{
soap#Envelope: {
soap#Header: {
},
soap#Body: {
ns#GetVehDetails: {
}
}
}
}
}
它产生这样的东西...
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header/>
<soap:Body>
<ns:GetVehDetails xmlns:ns="http://www.mycompany/2015/07">
如何更改 dataweave 脚本以在根元素处输出 xml 命名空间声明:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:ns="http://www.mycompany/2015/07">
<soap:Header/>
<soap:Body>
<ns:GetVehDetails>
这应该可以解决问题。
%dw 1.0
%output application/xml skipNullOn="everywhere"
%namespace soap http://www.w3.org/2003/05/soap-envelope
%namespace ns http://www.mycompany/2015/07
---
{
soap#Envelope @("xmlns:ns":'http://www.mycompany/2015/07'): {
soap#Header: {
},
soap#Body: {
ns#GetVehDetails: {
}
}
}
}
}
这是一个老的 Dataweave 问题,唯一的解决方法如下:
您需要在最顶部的根标记中添加一个虚拟属性 @(ns#name:"")
以及您希望位于顶部的名称空间,例如 Envelope
标记,在本例中为
%dw 1.0
%output application/xml skipNullOn="everywhere"
%namespace soap http://www.w3.org/2003/05/soap-envelope
%namespace ns http://www.mycompany/2015/07
---
{
soap#Envelope @(ns#name:""): {
soap#Header: {
},
soap#Body: {
ns#GetVehDetails: {
}
}
}
}
我有一个生成一些 xml.
的数据编织脚本%dw 1.0
%output application/xml skipNullOn="everywhere"
%namespace soap http://www.w3.org/2003/05/soap-envelope
%namespace ns http://www.mycompany/2015/07
---
{
soap#Envelope: {
soap#Header: {
},
soap#Body: {
ns#GetVehDetails: {
}
}
}
}
}
它产生这样的东西...
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header/>
<soap:Body>
<ns:GetVehDetails xmlns:ns="http://www.mycompany/2015/07">
如何更改 dataweave 脚本以在根元素处输出 xml 命名空间声明:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:ns="http://www.mycompany/2015/07">
<soap:Header/>
<soap:Body>
<ns:GetVehDetails>
这应该可以解决问题。
%dw 1.0
%output application/xml skipNullOn="everywhere"
%namespace soap http://www.w3.org/2003/05/soap-envelope
%namespace ns http://www.mycompany/2015/07
---
{
soap#Envelope @("xmlns:ns":'http://www.mycompany/2015/07'): {
soap#Header: {
},
soap#Body: {
ns#GetVehDetails: {
}
}
}
}
}
这是一个老的 Dataweave 问题,唯一的解决方法如下:
您需要在最顶部的根标记中添加一个虚拟属性 @(ns#name:"")
以及您希望位于顶部的名称空间,例如 Envelope
标记,在本例中为
%dw 1.0
%output application/xml skipNullOn="everywhere"
%namespace soap http://www.w3.org/2003/05/soap-envelope
%namespace ns http://www.mycompany/2015/07
---
{
soap#Envelope @(ns#name:""): {
soap#Header: {
},
soap#Body: {
ns#GetVehDetails: {
}
}
}
}