This doesn't require a for-each
due to the way equals tests work when one side is a node set. Simply
<xsl:variable name="urlMatched"
select="siteMap/siteMapNode/siteMapNode/@url = $relativeUrl" />
will do what you need, as the expression is true if any of the nodes in the set on the left matches the value on the right, and false otherwise. You should be able to test this value later using <xsl:if test="$urlMatched">
.
As for using the value in other templates, remember that variables in XSLT are lexically scoped - you will need to pass a parameter if you want to use the value in another template
<xsl:template name="something">
<xsl:param name="urlMatched" />
<!-- template body here -->
</xsl:template>
...
<xsl:call-template name="something">
<xsl:with-param name="urlMatched"
select="siteMap/siteMapNode/siteMapNode/@url = $relativeUrl" />
</xsl:call-template>
Or just do the calculation in the called template rather than the caller, as call-template
doesn't change the context so the same select expression will work there too.