[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Hi Senthil,
What actually is the problem? Can you give the XSLT that is not working? XSLT 1 or 2?
Here's a snippet in xslt 2, to be placed in the context of "content_vars":
<!-- replaces subject value -->
<xsl:value-of select="replace(content[@name='subject'], '(\[\[BUYERS_NAME\]\])', ../BUYERS_NAME)" />
<!-- replaces ordernr value -->
<xsl:value-of select="replace(content[@name='text'], '(\[ORDER_NUMBER\])', ../ORDER_NUMBER)" />
If you rather want the text to be matched based on the name inside the brackets, make sure to distinguish between double square brackets and single square brackets. A regex to help you with that is:
replace(xxxx, '.*\[\[?([^\[]+)\]\]?.*', '$1')
which effectively leaves the place inside the square brackets, be there one or two brackets (not really readable is it? That's why not everybody likes regular expressions.. ;-) . You can place the result in a variable and compare other names using local-name() with this. Something like that, but it all really depends on your requirements and on what you already have.
With XSLT 1, your best luck is to work out some recursive templates to do about the same.
HTH,
Senthilkumaravelan Krishnanatham wrote:
Re: [xsl] String Replacement in XML using XSLT
Subject: Re: [xsl] String Replacement in XML using XSLT From: Abel Braaksma <abel.online@xxxxxxxxx> Date: Mon, 25 Sep 2006 19:57:24 +0200 |
Hi Senthil,
What actually is the problem? Can you give the XSLT that is not working? XSLT 1 or 2?
Here's a snippet in xslt 2, to be placed in the context of "content_vars":
<!-- replaces subject value -->
<xsl:value-of select="replace(content[@name='subject'], '(\[\[BUYERS_NAME\]\])', ../BUYERS_NAME)" />
<!-- replaces ordernr value -->
<xsl:value-of select="replace(content[@name='text'], '(\[ORDER_NUMBER\])', ../ORDER_NUMBER)" />
If you rather want the text to be matched based on the name inside the brackets, make sure to distinguish between double square brackets and single square brackets. A regex to help you with that is:
replace(xxxx, '.*\[\[?([^\[]+)\]\]?.*', '$1')
which effectively leaves the place inside the square brackets, be there one or two brackets (not really readable is it? That's why not everybody likes regular expressions.. ;-) . You can place the result in a variable and compare other names using local-name() with this. Something like that, but it all really depends on your requirements and on what you already have.
With XSLT 1, your best luck is to work out some recursive templates to do about the same.
HTH,
Abel Braaksma http://abelleba.metacarpus.com
Senthilkumaravelan Krishnanatham 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 >
</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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] String Replacement in XML, Mukul Gandhi | Thread | Re: [xsl] String Replacement in XML, Abel Braaksma |
Re: [xsl] String Replacement in XML, Mukul Gandhi | Date | Re: [xsl] String Replacement in XML, Abel Braaksma |
Month |