It's complaining that $packageCount isn't a node-set (and therefore, in XSLT 1.0, can't be filtered). So you need to look for the calling code that sets this parameter. Perhaps it doesn't set the parameter, in which case $packageCount will be a zero-length string.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference