Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Yet another solution :)</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: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="Number[not(.*.+1)]"/&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>when this transformation is applied on the following XML document</strong>:</p> <pre><code>&lt;t&gt; &lt;Number&gt;111111&lt;/Number&gt; &lt;Number&gt;123123+&lt;/Number&gt; &lt;Number&gt;222222&lt;/Number&gt; &lt;Number&gt;222222+&lt;/Number&gt; &lt;/t&gt; </code></pre> <p><strong>the wanted, correct result is produced</strong>:</p> <pre><code>&lt;t&gt; &lt;Number&gt;111111&lt;/Number&gt; &lt;Number&gt;222222&lt;/Number&gt; &lt;/t&gt; </code></pre> <p><strong>Explanation</strong>: All <code>Number</code> elements for wich the expression:</p> <pre><code>not(.*.+1) </code></pre> <p>is <code>true()</code> are filtered out by the simple template rule:</p> <pre><code> &lt;xsl:template match="Number[not(.*.+1)]"/&gt; </code></pre> <p>This is possible only if the string value of the <code>Number</code> element cannot be converted to a number. In this case <code>.*.+1</code> evaluates to <code>NaN</code> and <code>boolean(NaN)</code> is <code>false()</code> by definition.</p> <p>If the string value of the <code>Number</code> element can be converted to a number $num, then the above expression is equivalent to:</p> <pre><code>not($num*$num+1) </code></pre> <p>and <code>$num*$num+1 &gt;= 1</code> for any number <code>$num</code>, so, <code>boolean(.*.+1)</code> in this case is always <code>true()</code>.</p>
    singulars
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    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