Yes, the 3.0l Vulcan engine was pretty much the same from 1986 to 2008
It was used in Ranger from '91 to '08
Mazda B-series '94 to '07
Other Ford models used the 3.0l in a Front Wheel drive, transverse mounted engine setup, but the block and heads were the same as the truck engine, so those can be used as well.
There were small changes over the years, good read here on what they were: Ford Ranger II 3.0 liter Engines
But as far as swapping 3.0l's all your current accessories(Alt, P/S, A/C) will bolt to any other year 3.0l.
Transmission, of course, will match up.
Computer will be the same, Flex-Fuel and non-Flex-Fuel doesn't matter, as long as you keep your original intake(lower and upper), which you want to do anyway so all the wiring for sensors matches up.
Ford did move some sensors around, but as long as you use original intake all the wires will be correct.
You should get a new Cam Synchronizer and Cam sensor(CPS) and for '97 model year, these wear out, the reason you want '97 model year is that Ford switch from a 3 wire CPS to a 2 wire CPS in the late '90's, your computer needs what ever it has now, 2 or 3 wire.
Also put in a new rear main seal, and front main if you want, rear main does wear out and is very hard to change in the vehicle.