Pinaki Sarkar

Greenhorn
+ Follow
since Jul 01, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Pinaki Sarkar

sorry i missed the response XML

<PERSONAL>
<PERSONALDETAILS>
<NAME>String</NAME>
<AGE>String</AGE>
<ADDRESS>
<ADDRESS1>String</ADDRESS1>
<ADDRESS2>String</ADDRESS2>
</ADDRESS>
</PERSONALDETAILS>
</PERSONAL>

If you see XML1 and XML2, the <address> element and its childs can come either within the <personalDetails> element or within the <personal> element.

But the transformed XML must always have the <ADDRESS> element within the <PERSONALDETAILS> tag.

So the problem i am currently facing is how to manipulate the position of address element.
Hi,

I am a beginner in using XSLT. I am having a problem in tranforming an XML element to a fixed position in a message when the position of the corresponding element in the source message is variable.

eg:

XML1:

<personal>
<personalDetails>
<name>String</name>
<age>String</age>
<address>
<address1>String</address1>
<address2>String</address2>
</address>
</personalDetails>
</personal>

XML2:

<personal>
<personalDetails>
<name>String</name>
<age>String</age>
</personalDetails>
<address>
<address1>String</address1>
<address2>String</address2>
</address>
</personal>


The response XML should look like this
<xsl:template match="address">
<ADDRESS>
<xsl:choose>
<xsl:when test="ancestor: ersonal">
<ADDRESS1>
<xsl:value-of select="address1"/>
</ADDRESS1>
<ADDRESS2>
<xsl:value-of select="address1"/>
</ADDRESS2>
</xsl:when>
<xsl therwise>
<ADDRESS1>
<xsl:value-of select="address1"/>
</ADDRESS1>
<ADDRESS2>
<xsl:value-of select="address1"/>
</ADDRESS2>
</xsl therwise>
</xsl:choose>
</ADDRESS>
</xsl:template>

But the problem it just prints the nodes in what format it comes. Please could anyone suggest a way out of this problem.