I have a following XML file:
Rather than using variables, you could just include an element in your XSLT sheet in it's own namespace, and refer to that, like this:
David Perry
Jim Kim
The book template matches those that do NOT have a corresponding my:name element for their author, and outputs nothing. The identity template outputs everything else, including the book elements you DO care about. The key's a bit of a hack, it essentially matches the whole document where the name exists, rather than matching the my:name element that matches. Since you only care about it's existence, this shouldn't be a problem.
Alternatively, if you'd rather be able to pass in a list of authors, you can use this:
The variable's used in an rather than in the template match, but it does the same job. This particular code needs the list of authors specified as a comma separated list, but it should be easy enough to adapt it if you'd rather use a different format.