Passing of parameters to XSLT depends on the processor you're using - it's not necessarily the same even for two processors supporting the JAXP API. You don't say whether the code you show work or not, or if it doesn't, how it fails, and in your setParameter example you don't say what "doc" is - so you're not making it very easy for anyone to help you.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference