RE: [xsl] using boolean to compare id numbers

Subject: RE: [xsl] using boolean to compare id numbers
From: "Andrew Welch" <ajwelch@xxxxxxxxxxxxxxx>
Date: Thu, 20 Jan 2005 16:42:09 -0000
> > <xsl:template match="user">
> >  <xsl:if test="preceding-sibling::user/@uid=@uid">
> >   <xsl:message>oops</xsl:message>
> >  </xsl:if>

If the XML is large you could use a key:

<xsl:key name="uids" match="user" use="@uid"/>

And then count how many <user>s have the current <user>'s @uid:

<xsl:template match="user">
  <xsl:if test="count(key('uids', @uid) > 1))">
	<xsl:message>oops<xsl:message>


cheers
andrew

Current Thread