title: XSLT test expression to check how many levels deep the URL is
body: <p>Given the following URLs, how do I determine how many levels deep the path is? </p>
  
  <pre><code>https://example.com/{product}/
  https://example.com/(product}/{vendor}
  https://example.com/{product}/{vendor}/{location}
  </code></pre>
  
  <p>These are variable strings: <code>product</code>, <code>vendor</code>, <code>location</code></p>
  
  <p>I have this code that I use for paths with constant values:</p>
  
  <pre><code>&lt;xsl:variable name="itemURL"&gt;
    &lt;xsl:value-of select="sitemap:loc"/&gt;
  &lt;/xsl:variable&gt;
  
  &lt;td&gt;
    &lt;xsl:if test="contains($itemURL, '/Section/')"&gt;
      &lt;xsl:attribute  name="class"&gt;section&lt;/xsl:attribute&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:if test="contains($itemURL, '/Category/')"&gt;
      &lt;xsl:attribute  name="class"&gt;category&lt;/xsl:attribute&gt;
    &lt;/xsl:if&gt;
    &lt;xsl:if test="contains($itemURL, '/Product/')"&gt;
      &lt;xsl:attribute  name="class"&gt;product&lt;/xsl:attribute&gt;
    &lt;/xsl:if&gt;--&gt;
    &lt;a href="{$itemURL}"&gt;
      &lt;xsl:value-of select="sitemap:loc"/&gt;
    &lt;/a&gt;
  &lt;/td&gt;
  </code></pre>
  
  <p>CSS for those simple constants:</p>
  
  <pre><code>.section {
      font-weight: 600;    
  }
  
  .category {
      font-weight: 500;
      padding-left: 15px;
  }
  
  .product {
      padding-left: 30px;
      font-style: italic;
  }
  </code></pre>
  
  <p>What I want to do is indent or add a bullet or something with css later when the list of URLs go another level deep. Basically I want to nest it so that it's easier for humans to read. Do I have to use regex here or is there a better way that is pure XSLT?</p>