Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>I. XSLT 1.0 Solution:</strong></p> <p><strong>This transformation</strong>:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output omit-xml-declaration="yes" indent="yes"/&gt; &lt;xsl:strip-space elements="*"/&gt; &lt;xsl:param name="pTargetStart" select="'[['"/&gt; &lt;xsl:param name="pTargetEnd" select="']]'"/&gt; &lt;xsl:param name="pReplacement" select="'F'"/&gt; &lt;xsl:template match="node()|@*"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="node()|@*"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="source/text()" name="replace"&gt; &lt;xsl:param name="pText" select="."/&gt; &lt;xsl:param name="pTargetStart" select="$pTargetStart"/&gt; &lt;xsl:param name="pTargetEnd" select="$pTargetEnd"/&gt; &lt;xsl:param name="pRep" select="$pReplacement"/&gt; &lt;xsl:choose&gt; &lt;xsl:when test= "not(contains($pText, $pTargetStart) and contains($pText, $pTargetEnd) ) or not(contains(substring-after($pText, $pTargetStart), $pTargetEnd ) ) "&gt; &lt;xsl:value-of select="$pText"/&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:value-of select="substring-before($pText, $pTargetStart)"/&gt; &lt;xsl:value-of select="$pRep"/&gt; &lt;xsl:variable name="vremText" select= "substring-after(substring-after($pText, $pTargetStart), $pTargetEnd )"/&gt; &lt;xsl:call-template name="replace"&gt; &lt;xsl:with-param name="pText" select="$vremText"/&gt; &lt;xsl:with-param name="pTargetStart" select="$pTargetStart"/&gt; &lt;xsl:with-param name="pTargetEnd" select="$pTargetEnd"/&gt; &lt;xsl:with-param name="pRep" select="$pRep"/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>when applied on the provided XML document</strong>:</p> <pre><code>&lt;xliff xmlns:xliff="urn:oasis:names:tc:xliff:document:1.1" version="1.1"&gt; &lt;file&gt; &lt;source&gt;abc [[field1]] def [[field2]] ghi&lt;/source&gt; &lt;/file&gt; &lt;/xliff&gt; </code></pre> <p><strong>produces the wanted, correct result</strong>:</p> <pre><code>&lt;xliff xmlns:xliff="urn:oasis:names:tc:xliff:document:1.1" version="1.1"&gt; &lt;file&gt; &lt;source&gt;abc F def F ghi&lt;/source&gt; &lt;/file&gt; &lt;/xliff&gt; </code></pre> <hr> <p><strong>II. XSLT 2.0 Solution</strong> (just for comparison):</p> <pre><code>&lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output omit-xml-declaration="yes" indent="yes"/&gt; &lt;xsl:template match="node()|@*"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="node()|@*"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="source/text()"&gt; &lt;xsl:sequence select="replace(., '\[\[(.*?)\]\]', 'F')"/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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