Attach source element hint to generated <selection> nodes

Gives better error messages by giving the location of the
<implementation> that created it.
Use system object to get environment variables

Makes unit-testing easier.