xsl-list
[Top] [All Lists]

[xsl] Recursive Replacement of the Escapes

2006-11-14 10:27:24

Hi All,
I have difficulty in recursive replacement of escapes.


Input content
<?xml version="1.0" encoding="UTF-8"?>
<broadcast>
  <content_vars>
<content name="subject"><html>Hello [[BUYERS_NAME]] <p>REF Order [WEB_ORDER_NUMBER]</p></html></ content>
  </content_vars>

        <ORDER_FEED>
<ORDER>
<ORDER_HEADER>
<BUYERS_NAME>Senthil</BUYERS_NAME>
<WEB_ORDER_NUMBER>W12345<WEB_ORDER_NUMBER>
</ORDER_HEADER>
<!--Line Items-->
</ORDER>
</ORDER_FEED>
</broadcast>

Desired output
<?xml version="1.0" encoding="UTF-8"?>
<content name="subject">Hello Senthil<p> REF Order W12345 </p></ html></ content>


I tried the below mentioed XSL and it is not producing the output I wanted.
It replaces the first escape not the subsequent ones.

Please help me to resolve the same.

<?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="/broadcast">
<html>
   <xsl:apply-templates select="content_vars/content" />
</html>
</xsl:template>

<xsl:template match="content">
<xsl:variable name="temp1" select="translate(., '[]', '')" />
<xsl:variable name="temp2" select="//*[not(*)][contains($temp1,
local-name())]" />
<xsl:variable name="temp3"
select="local-name(//*[not(*)][contains($temp1, local-name())])" />
<p>
  <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>

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>