Subject: Re: [xsl] String Replacement in XML using XSLT From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx> Date: Mon, 25 Sep 2006 23:09:53 +0530 |
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: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>
<?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>
<html> <body> <p>Hello SENTHIL</p> <p>REF Order 1234</p> </body> </html>
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 >
</test>
Output should be <html> <body> <P>Hello SENTHIL</p> <p> REF Order 1234</p> </body> </html>
Is there anyway I can do it in XSLT? Any suggestion are welcome.
Thanks, Senthil
-- Regards, Mukul Gandhi
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] String Replacement in XML usi, Senthilkumaravelan K | Thread | Re: [xsl] String Replacement in XML, Abel Braaksma |
[xsl] String Replacement in XML usi, Senthilkumaravelan K | Date | Re: [xsl] String Replacement in XML, Abel Braaksma |
Month |