xsl-list
[Top] [All Lists]

Re: [xsl] String Replacement in XML using XSLT

2006-09-25 11:22:19
I would prefer this to be really an xml/xslt problem and solution.

For this purpose, I'd rather have :

     <content name="subject"> Hello <BUYERS_NAME/></content>

instead of:

<content name="subject"> Hello [[BUYERS_NAME]]</content>

and the same for any other replacement targets.

Then I'd provide the replacement text simply in the template matching
the target:

<xsl:template match="BUYERS_NAME">
 <xsl:value-of select="/*/BUYERS_NAME">
</xsl:template>

Or I could make all replacements using a single template only:

     <content name="subject"> Hello <insert>BUYERS_NAME</insert></content>

<xsl:template match="insert">
 <xsl:value-of select="/*/*[name() = current()]">
</xsl:template>


--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
--------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play


On 9/25/06, Senthilkumaravelan Krishnanatham <senthil(_at_)apple(_dot_)com> 
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--