Question about XSLT and for loops

Hi! I am trying to make a for loop that iterates over a list of elements and does something only if that element is different from all the previous ones. My code looks like this but I get an error telling me that what I’m using is not an expression:

<xsl:template match="entity">
  <xsl:for-each select="subentity!=preceding::subentity">
    <!-- the template goes here -->