That's impossible with the current modding API, and it's going to stay impossible for the foreseeable future. Trains wouldn't be able to pathfind into and out of factory buildings.
build two station with same name for a factory building, one for inside, and other for outside.
any train must stop the station while in/out the building. so the pathfind will division.