I suspect that you are overlooking the fact that a path expression starting with "/" or "//" always selects from the root of the document, so <xsl:if test="//x"/> tests if there is an <x> anywhere.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference