[xsl] recursive xsl replace

Subject: [xsl] recursive xsl replace
From: Joelle Tegwen <tegwe002@xxxxxxx>
Date: Tue, 08 May 2007 10:06:03 -0500
I've been struggling with this for hours and I'm not getting anywhere
and I'm behind on an already delayed deadline. Any help would be most
appreciated.

I've got a text string like this:

<p>In Iowa, effective transition is monitored in the following ways:</p>

<ul>
 <li>File Review Process for Part C and Part B, including specific transition
items;</li>
 <li>Regional Data Profiles using transition file review data;</li>

 <li>Regional Corrective Action Plans (CAPs); and/or</li>
 <li>Quality Services Reviews</li>
</ul>

<p>More information on Iowas monitoring system can be found at <a
href="http://www.iowaccess.org/educate/";>www.iowaccess.org/educate/</a></p><ul
class="pagetopage_nav ptop_botm">


And I want it to look like this:


<p>In Iowa, effective transition is monitored in the following ways:</p>

<ul>
 <li><em class="contentterm">File Review Process</em> for Part C and Part B,
including specific transition items;</li>
 <li><em class="contentterm">
Regional Data Profiles/em>
using transition file review data;</li>

 <li><em class="contentterm">
Regional Corrective Action Plans/em>
(CAPs); and/or</li>
 <li>Quality Services Reviews</li>
</ul>

<p>More information on Iowas monitoring system can be found at <a
href="http://www.iowaccess.org/educate/";>www.iowaccess.org/educate/</a></p><ul
class="pagetopage_nav ptop_botm">


Where the highlighted terms are chosen from a xml nodes that looks like this: <glossary id="22"><word><![CDATA[File Review Process]]></word> <definition><![CDATA[Iowa conducts file reviews using a web-based monitoring system called I-STAR (Iowa&rsquo;s System for Achieving Results). File reviews are conducted yearly on approximately 10% of all IFSP files. This information is used to cite Regions for noncompliance. ]]></definition></glossary> <glossary id="23"><word><![CDATA[Regional Data Profiles]]></word> <definition><![CDATA[From the transition questions in I-STAR and the Exit Code data collected from the Information and Management System (IMS), Iowa creates regional data profiles. Examples are found on slides 31 and 34. This information is used to cite Regions for noncompliance. ]]></definition></glossary> <glossary id="24"><word><![CDATA[Regional Corrective Action Plans]]></word> <definition><![CDATA[Based on noncompliance and regional drill down data, each Region is required to develop and submit a Corrective Action Plan with specific steps and timelines to correct the noncompliance within one year. The Department reviews and approves the Corrective Action Plans.]]></definition></glossary>

My XSL looks like this:

<xsl:template name="replaceglossary">
<xsl:param name="text"/>
<xsl:param name="glossary"/>
<xsl:param name="ordinal" select="1"/>


<xsl:variable name="temp"> <xsl:choose> <xsl:when test="$ordinal = count($glossary)"> <xsl:value-of select="$text"/> </xsl:when> <xsl:otherwise> <xsl:call-template name="replaceglossary"> <xsl:with-param name="text" select="$text"/> <xsl:with-param name="glossary" select="$glossary"/> <xsl:with-param name="ordinal" select="$ordinal+1"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:variable>

<xsl:variable name="word" select="$glossary[$ordinal]/word"/>

<xsl:value-of disable-output-escaping="yes"
select="substring-before($temp, $word)"/>
<xsl:element name="em">
<xsl:attribute name="class">
<xsl:text>contentterm</xsl:text>
</xsl:attribute>
<xsl:value-of disable-output-escaping="yes" select="$word"/>
</xsl:element>
<xsl:value-of disable-output-escaping="yes"
select="substring-after($temp, $word)"/>


</xsl:template>


But it doesn't work. It only replaces the first term.

What am I doing wrong?

PS I'm using the PHP xsl transformer which apparently does not support
fn:replace() :P

Thanks in advance for any hints that could point me in the right direction.

Joelle

Current Thread