Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Updated to reflect OP new requests</strong></p> <p>This is a recursive template which does an <strong>HTML-compliant</strong> nested list as deinfed in the W3C specs.</p> <pre><code>&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt; &lt;xsl:output indent="yes"/&gt; &lt;xsl:template match="/root"&gt; &lt;ul id="someid" class="menu"&gt; &lt;xsl:apply-templates select="row[not(@ParentId)]"/&gt; &lt;/ul&gt; &lt;/xsl:template&gt; &lt;xsl:template match="row"&gt; &lt;li rel="{@Id}"&gt; &lt;xsl:value-of select="@Name"/&gt; &lt;xsl:if test="count(../row[@ParentId=current()/@Id])&gt;0"&gt; &lt;ul&gt; &lt;xsl:apply-templates select="../row[@ParentId=current()/@Id]"/&gt; &lt;/ul&gt; &lt;/xsl:if&gt; &lt;/li&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>Applied on this input:</p> <pre><code>&lt;root&gt; &lt;row Id="1" Name="data" /&gt; &lt;row Id="2" Name="data" /&gt; &lt;row Id="3" Name="people" /&gt; &lt;row Id="4" Name="person" ParentId="3" /&gt; &lt;row Id="6" Name="folder" ParentId="2" /&gt; &lt;row Id="7" Name="thing" ParentId="3" /&gt; &lt;row Id="8" Name="web" /&gt; &lt;row Id="9" Name="link" ParentId="8" /&gt; &lt;row Id="10" Name="anotherone" ParentId="9" /&gt; &lt;row Id="11" Name="anotherone" ParentId="9" /&gt; &lt;row Id="12" Name="anotherone" ParentId="9" /&gt; &lt;row Id="13" Name="anotherone" ParentId="3" /&gt; &lt;/root&gt; </code></pre> <p>Produces:</p> <pre><code>&lt;ul id="someid" class="menu"&gt; &lt;li rel="1"&gt;data&lt;/li&gt; &lt;li rel="2"&gt;data&lt;ul&gt; &lt;li rel="6"&gt;folder&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li rel="3"&gt;people&lt;ul&gt; &lt;li rel="4"&gt;person&lt;/li&gt; &lt;li rel="7"&gt;thing&lt;/li&gt; &lt;li rel="13"&gt;anotherone&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li rel="8"&gt;web&lt;ul&gt; &lt;li rel="9"&gt;link&lt;ul&gt; &lt;li rel="10"&gt;anotherone&lt;/li&gt; &lt;li rel="11"&gt;anotherone&lt;/li&gt; &lt;li rel="12"&gt;anotherone&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>If you are in trouble about how list should be created, try them at <a href="http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_lists2" rel="nofollow">W3School</a>.</p>
    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.
    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