fixes XMLResource foreign-replacement bug.