Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <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 method="text"/&gt; &lt;xsl:strip-space elements="*"/&gt; &lt;xsl:template match="/*"&gt; "&lt;xsl:apply-templates select="seg/text()"/&gt;" &lt;/xsl:template&gt; &lt;xsl:template match="seg/text()"&gt; &lt;xsl:value-of select= "translate(normalize-space(translate(.,'&amp;#xA;;', ';:')), ';', ' ' ) "/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>when applied on this XML document</strong> (combination of your case 1 ad case2):</p> <pre><code>&lt;tuv xml:lang="zh-cn" changedate="20110216T070945Z"&gt; &lt;seg&gt; &lt;ut&gt;# 302 &lt;/ut&gt;The gradient of the; objective function cannot be &lt;ph x="2" type="inldel"&gt;! &lt;/ph&gt;computed at the starting point &lt;/seg&gt; &lt;/tuv&gt; </code></pre> <p><strong>produces the wanted, correct result:</strong></p> <pre><code> "The gradient of the: objective function cannot be computed at the starting point " </code></pre> <p><strong>Explanation</strong>:</p> <ol> <li><p>In the innermost translate, in every text-node child of <code>seg</code> any ';' is replaced with ':' and any NL character is replaced with a ';'.</p></li> <li><p>1normalize-space()<code>is issued on the result of the innermost</code>translate()` and this strips off the leading and trailing white space, however the ';' characters are not touched -- this is the only reason we replaced the NL characters with ';' in step 1.</p></li> <li><p>Finally, a <code>translate()</code> replaces any ';' with a space.</p></li> </ol>
    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.
 

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