[Home] [By Thread] [By Date] [Recent Entries]
Hi Senthil, Please try this stylesheet: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" indent="yes" /> <xsl:template match="/test">
<html>
<body>
<xsl:apply-templates select="content_vars/content" />
</body>
</html>
</xsl:template><xsl:template match="content">
<p>
<xsl:variable name="temp1" select="translate(., '[]', '')" />
<xsl:variable name="temp2"
select="normalize-space(../following-sibling::*[contains($temp1,
local-name())])" />
<xsl:variable name="temp3"
select="local-name(../following-sibling::*[contains($temp1,
local-name())])" />
<xsl:value-of select="substring-before($temp1, $temp3)"
/><xsl:value-of select="$temp2" /><xsl:value-of
select="substring-after($temp1, $temp3)" />
</p>
</xsl:template></xsl:stylesheet> This when applied to XML: <?xml version="1.0" encoding="UTF-8"?> <test> <content_vars> <content name="subject">Hello [[BUYERS_NAME]]</content> <content name="text">REF Order [ORDER_NUMBER]</content> </content_vars> <BUYERS_NAME> SENTHIL </BUYERS_NAME> <ORDER_NUMBER> 1234 </ORDER_NUMBER > </test> Produces the wanted output: <html> <body> <p>Hello SENTHIL</p> <p>REF Order 1234</p> </body> </html> This may not be the best answer, but it works for this case. On 9/25/06, Senthilkumaravelan Krishnanatham <senthil@xxxxxxxxx> wrote: Hi All, I need help in logic of replacing the string in XML for the below input. <test> <content_vars> <content name="subject"> Hello [[BUYERS_NAME]]</content> <content name="text"> REF Order [ORDER_NUMBER]</content> </content_vars> <BUYERS_NAME> SENTHIL </BUYERS_NAME> < ORDER_NUMBER > 1234 </ORDER_NUMBER > -- Regards, Mukul Gandhi http://gandhimukul.tripod.com
|

Cart



