Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Use</strong>:</p> <pre><code>/*/*/Item [SerialNumber = following-sibling::Item/SerialNumber and not(SerialNumber = preceding-sibling::Item/SerialNumber) ] </code></pre> <p>This selects just one <code>Item</code> element for any group of <code>Item</code> elements that have a <code>SerialNumber</code> child with the same string value.</p> <p><strong>XSLT - based verification</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="/"&gt; &lt;xsl:copy-of select= "/*/*/Item [SerialNumber = following-sibling::Item/SerialNumber and not(SerialNumber = preceding-sibling::Item/SerialNumber) ]"/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>When this transformation is applied on this XML document</strong> (based on the provided one, but made more interesting):</p> <pre><code>&lt;Inventory&gt; &lt;Items&gt; &lt;Item&gt; &lt;SerialNumber&gt;1111&lt;/SerialNumber&gt; &lt;/Item&gt; &lt;Item&gt; &lt;SerialNumber&gt;2222&lt;/SerialNumber&gt; &lt;/Item&gt; &lt;Item&gt; &lt;SerialNumber&gt;2222&lt;/SerialNumber&gt; &lt;/Item&gt; &lt;Item&gt; &lt;SerialNumber&gt;2222&lt;/SerialNumber&gt; &lt;/Item&gt; &lt;Item&gt; &lt;SerialNumber&gt;1111&lt;/SerialNumber&gt; &lt;/Item&gt; &lt;Item&gt; &lt;SerialNumber&gt;1111&lt;/SerialNumber&gt; &lt;/Item&gt; &lt;Item&gt; &lt;SerialNumber&gt;3333&lt;/SerialNumber&gt; &lt;/Item&gt; &lt;/Items&gt; &lt;/Inventory&gt; </code></pre> <p><strong>the transformation evaluates the XPath expression and copies the selected nodes to the output:</strong></p> <pre><code>&lt;Item&gt; &lt;SerialNumber&gt;1111&lt;/SerialNumber&gt; &lt;/Item&gt; &lt;Item&gt; &lt;SerialNumber&gt;2222&lt;/SerialNumber&gt; &lt;/Item&gt; </code></pre> <p><strong>Finally, if you want to get just the <code>SerialNumber</code> duplicate values, use</strong>:</p> <pre><code> /*/*/Item [SerialNumber = following-sibling::Item/SerialNumber and not(SerialNumber = preceding-sibling::Item/SerialNumber) ] /SerialNumber/text() </code></pre>
    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. 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