Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>UPDATE</strong>: As the original problem was changed adding the requirement to recognize the word "Spain" not only in all possible capitalizations but also including accented characters, I have updated the solution below so that now "Spain" with <strong>âÂ</strong> and/or <strong>ïÏ</strong> is correctly recognized.</p> <p><strong>Here is a more generic solution than that of @Alejandro</strong>:</p> <p>If we want to select all elements, whose <code>name</code> attribute contains the word "Spain" in any capitalization and if the possible word delimiters are all non-alphabetic characters, then</p> <p><strong>This XPath expression</strong>:</p> <pre><code>/*/*[contains( concat(' ', translate(translate(@name, translate(@name, $vAlpha, ''), ' '), $vUpper, $vLower), ' ' ), ' spain ' ) ] </code></pre> <p><strong>when applied on this XML document</strong>:</p> <pre><code>&lt;elements&gt; &lt;element id="1" name="france" /&gt; &lt;element id="2" name="usa" /&gt; &lt;element id="3" name="Spaïn" /&gt; &lt;element id="4" name="france with spâin and africa" /&gt; &lt;element id="5" name="-Spain!" /&gt; &lt;element id="6" name="spain and africa" /&gt; &lt;element id="7" name="italie and Spain." /&gt; &lt;/elements&gt; </code></pre> <p><strong>selects the following elements</strong>:</p> <pre><code>&lt;element id="3" name="Spaïn"/&gt; &lt;element id="4" name="france with spâin and africa"/&gt; &lt;element id="5" name="-Spain!"/&gt; &lt;element id="6" name="spain and africa"/&gt; &lt;element id="7" name="italie and Spain."/&gt; </code></pre> <p>In the above XPath expression <code>$vLower</code>, <code>$vUpper</code> must be substituted with (respectively):</p> <pre><code>'aaabcdefghiiijklmnopqrstuvwxyz' </code></pre> <p>and</p> <pre><code>'âÂABCDEFGHïÏIJKLMNOPQRSTUVWXYZ' </code></pre> <p><code>$vAlpha</code> must be substituted by the concatenation of <code>$vLower</code> and <code>$vUpper</code> .</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