EDIT: I also have access to ESXLT functions.
I have two node sets of string tokens. One set contains values like these:
/Geography/N
I guess I couldn't make the XPath above work. I started with the following XML doc to initialize the two nodesets:
/Geography/North America/California/San Francisco
/Geography/Asia/Japan/Tokyo/Shinjuku
/Geography/North America/
/Geography/Asia/Japan/
I think this stylesheet ought to implement Robert's solution, but I only get a count of '1':
I did write a stylesheet that uses a recursive template and does produce the correct count of '2' with the given input doc, but it's far less elegant than Robert's answer. If only I could get the XPath to work--always wanting to learn.