Using XSLT 1.0, I want to process four node sets, in order, A, B, C, D. But I can’t specify each node set with a single (or at least not manageable) XPath expression.
I’d like to, right up front, sweep through and tag all the nodes I want to be A’s, all the nodes I want to be B’s, etc., and then later be able to select at will all A nodes, all B nodes, etc.
I also might want to add to the list later.
I can’t create attributes in the file I’m processing. (Right?) Variables go out of scope too soon. Maybe something using keys? A key for all A’s, all B’s? But can I add more nodes to a key table once the key has been created?
Or is there a way to save XPaths?
Is there a straightforward way to do this, or must I just create a nasty, awful, error-prone, terrible-to-maintain Xpath expression every time I want to select each of my node sets?
Solution: Use Global Variables, like this:
Then later:
repeated as often as needed, without needing to repeat the Xpath expressions.
(Michael, your comment “People often fail to realise that global variable definitions can reference the source document,” posted at dpawson.co.uk, got me looking in the right area.)