You want to define a parameter, not a variable: <xsl:param name="x"/> as a child of xsl:stylesheet.
Then when you invoke the transformation (e.g. from Javascript) you'll find the API offers a method such as setParameter() or addParameter() to supply an external value for the parameter.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference