Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>I. XSLT 1.0. This transformation uses simple <a href="http://www.jenitennison.com/xslt/grouping/muenchian.xml" rel="nofollow">Muenchian grouping</a></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:key name="kChildByName" match="Query/*" use="name()"/&gt; &lt;xsl:template match= "Query/* [generate-id() = generate-id(key('kChildByName', name())[1]) ]"&gt; &lt;xsl:value-of select="name()"/&gt; &lt;xsl:text&gt;&amp;#xA;&lt;/xsl:text&gt; &lt;/xsl:template&gt; &lt;xsl:template match="text()"/&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>When applied on the provided XML document</strong>:</p> <pre><code>&lt;ShopArea&gt; &lt;Connection name="Connection1"&gt; &lt;Report date="25-09-2011"&gt; &lt;Query id="1"&gt; &lt;TABLE1&gt;1.1&lt;/TABLE1&gt; &lt;TABLE2&gt;1.2&lt;/TABLE2&gt; &lt;TABLE3&gt;1.3&lt;/TABLE3&gt; &lt;/Query&gt; &lt;Query id="2"&gt; &lt;TABLE21&gt;2.1&lt;/TABLE21&gt; &lt;TABLE22&gt;2.2&lt;/TABLE22&gt; &lt;TABLE23&gt;2.3&lt;/TABLE23&gt; &lt;/Query&gt; &lt;/Report&gt; &lt;Report date="26-09-2011"&gt; &lt;Query id="1"&gt; &lt;TABLE1&gt;26 1.1&lt;/TABLE1&gt; &lt;TABLE2&gt;26 1.2&lt;/TABLE2&gt; &lt;TABLE3&gt;26 1.3&lt;/TABLE3&gt; &lt;/Query&gt; &lt;Query id="2"&gt; &lt;TABLE21&gt;26 2.1&lt;/TABLE21&gt; &lt;TABLE22&gt;26 2.2&lt;/TABLE22&gt; &lt;TABLE23&gt;26 2.3&lt;/TABLE23&gt; &lt;/Query&gt; &lt;/Report&gt; &lt;/Connection&gt; &lt;/ShopArea&gt; </code></pre> <p><strong>the wanted, correct result (all different names of elements that are children of a <code>Query</code>) is produced</strong>:</p> <pre><code>TABLE1 TABLE2 TABLE3 TABLE21 TABLE22 TABLE23 </code></pre> <p><strong>II. XSLT 2.0: This transformation uses</strong> <code>&lt;xsl:for-each-group&gt;</code>:</p> <pre><code>&lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;xsl:output omit-xml-declaration="yes" indent="yes"/&gt; &lt;xsl:template match="/*/*"&gt; &lt;xsl:for-each-group select="Report/Query/*" group-by="name()"&gt; &lt;xsl:sequence select="current-grouping-key(), '&amp;#xA;'"/&gt; &lt;/xsl:for-each-group&gt; &lt;/xsl:template&gt; &lt;xsl:template match="text()"/&gt; &lt;/xsl:stylesheet&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. 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