Transformation XSLT



我有一个有效负载响应Json如下

{
"instance" :{
"instanceId" : "AC"
},
"caseDetails":{
"id" : "100",
"decisionMaker" : "gljslgkj",
"state" : "decisionDiffused",

"caseTexts":[
{
"type":"DELIBERATION",
"language":"FR"
},
{
"type":"DELIBERATION",
"language":"NL"
}
],

"workflow":{
"locationFR": "dlfsjflj",
"locationNL": "jfdlksjfk",
"locationValidators" : [
{
"lastName":"lastName",
"firstName": "firstName"
}
]
}
}
}

这是我从后端得到的响应,当我把它转换成XML(使用属性messageType)casetext部分得到如下

<bos:caseTexts>
<bos:type>DELIBERATION</bos:type>
<bos:language>FR</bos:language>
</bos:caseTexts>
<bos:caseTexts>
<bos:type>DELIBERATION</bos:type>
<bos:language>NL</bos:language>
</bos:caseTexts>             

我希望它如下:casettextscaseText列表当孩子

<bos:caseTexts>
<bos:caseText>
<bos:type>DELIBERATION</bos:type>
<bos:language>FR</bos:language>
</bos:caseText>
....
</bos:caseTexts>

任何帮助都将是感激的:)

问候;

这样做的一个好方法是创建一个casetextsxml元素,执行"for-each"[1]在对每个case text执行"copy "[2] .

[1] https://www.w3schools.com/xml/xsl_for_each.asp

[2] https://www.w3schools.com/xml/ref_xsl_el_copy-of.asp

相关内容

  • 没有找到相关文章

最新更新