Recursively scan through the whole document to collect attributes, if you're desperate enough to do such a thing.