How can I tell if an expression will match a node or a node-set?
Unless a predicate specifically targets a specific node or the expression matches an attribute, you can't tell whether your expression will match a node or a node-set. This is by design because it actually shouldn't matter whether you are matching a node or a node-set; each node matching the expression is supposed to be processed. You can download a tool called XPath Visualizer from http://www.topxml.com/
xpathvisualizer/default.asp. This tool can help you determine whether your expression is correct.
How can I tell whether an expression in a value-of command will yield a text value or a tree fragment?
You have no way of knowing whether you are getting a text value or a tree fragment unless you use the text() function.
I have a stylesheet that keeps outputting text that I didn't ask for. How can I get rid of this problem?
The default behavior of the stylesheet causes this problem. Check whether all nodes are being matched by a template. Also, check that your expression outputting values doesn't match a tree fragment.