When a page is being created, we need to know what metadata to get from the server. This is done by looking through the format statments and xsl files.
TransformingReceptionist:configure() calls TransformingReceptionist:getRequiredMetadataNamesFromXSLFiles() - this looks through all the xsl files it can find in the interfaces folder, the site folder (for the current site) and the collect folder (for the current site). It scans these files looking for gsf:metadata elements, and adds their names to a list. They are stored in a map of full-file-path → list of names. This also looks at all the files included by the current file and adds their metadata names in too.
When a request comes in, the TransformingReceptionist:preProcessRequest() method checks the action and subaction to work out which xsl file is the main one. eg classifier.xsl Then it gets a list of all the stylesheets of this name (collection, site, interface, base interface) and creates a list of metadata that these stylesheets might use (from the map generated above). Puts this into <extraMetadataList> and adds it to the request.
The action, eg GS2BrowseAction, gets the format statement for the classifier (checks classifier specific, default classifier, global formats) and extracts metadata names from the format statement using Action:getRequiredMetadataNames(). This looks for gsf:metadata, gsf:foreach-metadata, gsf:link and gsf:image items.
<gsf:metadata name="title" select="parent"> gets turned into 'parent_title'. The handling of parent_, root_, sibling_ etc is done at the service end.