on ‎2023 Jun 22 11:13 AM
Experts,
Source Data
<root>
<test>
<product>
<box>square</box>
<qty>5</qty>
</product>
</test>
</root>
Expected Data
<root>
<Level1>test<Level1>
<Level2>Product<Level2>
<Level3>square</Level3>
<Level4>5</Level4>
</root>
Can you please advice me on how to achieve the above requirement?
TIA,
Barath
Request clarification before answering.
Hi, I can recommend you to use the XSLT to achieve your output
XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<root>
<xsl:apply-templates select="root/test/product"/>
</root>
</xsl:template>
<xsl:template match="product">
<Level1>
<xsl:value-of select="ancestor::test[1]/name()"/>
</Level1>
<Level2>
<xsl:value-of select="name()"/>
</Level2>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="box">
<Level3>
<xsl:value-of select="."/>
</Level3>
</xsl:template>
<xsl:template match="qty">
<Level4>
<xsl:value-of select="."/>
</Level4>
</xsl:template>
</xsl:stylesheet>
Output:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<Level1>test</Level1>
<Level2>product</Level2>
<Level3>square</Level3>
<Level4>5</Level4>
</root>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
It depends if the incoming messages are always the same structure?
If so, then you could use message mapping, create the source and target xsd accordingly.
Alternatively, you could do this with a groovy script which will be much more flexible.
Kind regards,
David
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 8 | |
| 7 | |
| 6 | |
| 6 | |
| 5 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.