Note that there are some explanatory texts on larger screens.

plurals
  1. POFind and Replace with Unique
    text
    copied!<p>I am performing a find and replace on the line feed character (<code>&amp;#10;</code>) and replacing it with the paragraph close and paragraph open tags using the following code:</p> <pre><code>&lt;xsl:template match="/STORIES/STORY"&gt; &lt;component&gt; &lt;xsl:if test="boolean(ARTICLEBODY)"&gt; &lt;p&gt; &lt;xsl:call-template name="replace-text"&gt; &lt;xsl:with-param name="text" select="ARTICLEBODY" /&gt; &lt;xsl:with-param name="replace" select="'&amp;#10;'" /&gt; &lt;xsl:with-param name="by" select="'&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;'" /&gt; &lt;/xsl:call-template&gt; &lt;/p&gt; &lt;/xsl:if&gt; &lt;/component&gt; &lt;/xsl:template&gt; &lt;xsl:template name="replace-text"&gt; &lt;xsl:param name="text"/&gt; &lt;xsl:param name="replace" /&gt; &lt;xsl:param name="by" /&gt; &lt;xsl:choose&gt; &lt;xsl:when test="contains($text, $replace)"&gt; &lt;xsl:value-of select="substring-before($text, $replace)"/&gt; &lt;xsl:value-of select="$by" disable-output-escaping="yes"/&gt; &lt;xsl:call-template name="replace-text"&gt; &lt;xsl:with-param name="text" select="substring-after($text, $replace)"/&gt; &lt;xsl:with-param name="replace" select="$replace" /&gt; &lt;xsl:with-param name="by" select="$by" /&gt; &lt;/xsl:call-template&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:value-of select="$text"/&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:template&gt; </code></pre> <p>This almost works perfectly, except that I really need it to de-dup the line feeds as the paragraphs tend to be separated by 2 or more resulting in <code>&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;</code>. </p> <p>Is it possible to get it so that it will only ever replace this once per paragraph?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload