Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>This transformation</strong>:</p> <pre><code>&lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output omit-xml-declaration="yes" indent="yes"/&gt; &lt;xsl:template match="/*"&gt; &lt;t&gt; &lt;xsl:for-each-group select="*" group-starting-with="parent[@class='header-gray']"&gt; &lt;div class="header-gray"&gt; &lt;xsl:apply-templates select="current-group()[position() ne 1]"/&gt; &lt;/div&gt; &lt;/xsl:for-each-group&gt; &lt;/t&gt; &lt;/xsl:template&gt; &lt;xsl:template match="parent"&gt; &lt;span class="{@class}"/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>when applied on the following XML document</strong> (the provided fragment, wrapped into a single top element so that it becomes a well-formed XML document):</p> <pre><code>&lt;t&gt; &lt;parent class="header-gray"&gt;&lt;/parent&gt; &lt;parent class="header-lightgray"&gt;&lt;/parent&gt; &lt;parent class="header-lightgray"&gt;&lt;/parent&gt; &lt;parent class="header-lightgray"&gt;&lt;/parent&gt; &lt;parent class="header-gray"&gt;&lt;/parent&gt; &lt;parent class="header-lightgray"&gt;&lt;/parent&gt; &lt;parent class="header-lightgray"&gt;&lt;/parent&gt; &lt;parent class="header-lightgray"&gt;&lt;/parent&gt; &lt;parent class="header-gray"&gt;&lt;/parent&gt; &lt;/t&gt; </code></pre> <p><strong>produces the wanted, correct result:</strong></p> <pre><code>&lt;t&gt; &lt;div class="header-gray"&gt; &lt;span class="header-lightgray"/&gt; &lt;span class="header-lightgray"/&gt; &lt;span class="header-lightgray"/&gt; &lt;/div&gt; &lt;div class="header-gray"&gt; &lt;span class="header-lightgray"/&gt; &lt;span class="header-lightgray"/&gt; &lt;span class="header-lightgray"/&gt; &lt;/div&gt; &lt;div class="header-gray"/&gt; &lt;/t&gt; </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. 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