Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Using a standard grouping technique, you need just two templates (no loops, no params):</p> <ul> <li>Use a <em>composite key</em> to collect <strong>CONTACT</strong> by <strong>FirstName</strong> and <strong>SecondName</strong>.</li> <li>Then apply the templates to one single <strong>CONTACT</strong> for each group.</li> <li>Finally, retrieve the <strong>Email</strong> nodes from the key.</li> </ul> <hr> <p>Your final transform:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:key name="k_Contacts" match="CONTACTS/CONTACT" use="concat(FirstName,LastName)"/&gt; &lt;xsl:template match="CONTACTS"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="CONTACT[generate-id()= generate-id(key('k_Contacts',concat(FirstName,LastName))[1])]"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="CONTACT"&gt; &lt;xsl:copy&gt; &lt;xsl:copy-of select="FirstName | LastName"/&gt; &lt;xsl:copy-of select="key('k_Contacts',concat(FirstName,LastName)) /Email"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <hr> <p>In XSLT 2.0 you can use <code>xsl:for-each-group</code>; just replace </p> <pre><code>&lt;xsl:apply-templates select="CONTACT[generate-id()= generate-id(key('k_Contacts',concat(FirstName,LastName))[1])]"/&gt; </code></pre> <p>with:</p> <pre><code> &lt;xsl:for-each-group select="CONTACT" group-by="concat(FirstName,LastName)"&gt; &lt;xsl:apply-templates select="current-group()[1]"/&gt; &lt;/xsl:for-each-group&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. 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