You will have an issue with the brake booster setup, you can probably swap it over to the 525. Take a look at that. The transmission will fit no issue however the drive shaft will not bolt up. You can use the 540 drive shaft but you will need to swap the rear end over. The 540 and M series have the larger differential carrier and for a swap to happen painlessly you want to bring that into the 525.
Do not remove the 525 badge.
95 E34 530I V2.37
===========
Those who make peaceful revolution impossible will make violent revolution inevitable.
John F. Kennedy