You currently have an xsl:if statement as a child of xsl:apply-templates which is not allowed in XSLT. If you only want to select Content elements with an Id value of "sam", you can put the condition in the select attribute of apply-templates, like so
<xsl:apply-templates select="BData/Content[Id='sam']" />
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="var" select="'sam'" />
<xsl:apply-templates select="BData/Content[Id=$var]" />
<xsl:value-of select="Id" />
EDIT: The expression within the square brackets does not have to be just equals, it can be any valid expression, for example, if you wanted only Content elements whose Id started with "sam" or "bob", you would do this:
<xsl:apply-templates select="BData/Content[starts-with(Id, 'sam') or starts-with(Id, 'bob')]" />
Thanks a lot. It helped. But it isn't about direct match. Can I add string methods like starts_with() and logical operators instead of just [Id= $var]. Basically anything that is passed to 'test' in a tag.
Well, if you want an answer to a question, first you must ask the question, and the question you asked was how to "get the value of content/id tag with value 'sam'".... Having said that, in reply to you comment, you can indeed use more complex expressions here. I've amended my answer to show an example.