OpenRailRouting
When I visualised my upcoming holiday trip with Leaflet, a handy tool turned out to be OpenRailRouting. The GrassHoper fork is “a routing engine for railways.” It allows you to find a route between two or more points, and export it as a GPX file. However, this is not based on actual, real-life connections, but simply looks for a possible route on rail.
If the train connections were added to OpenStreetMap as a relation, I downloaded them via overpass turbo, and if that wasn’t the case, I used OpenRailRouting. This was quite simple: I added all stops from the itinerary, verified that the route was accurate, and downloaded the generated GPX file.
Since OpenRailRouting is Free Software, you can download the software and a run your own installation.