Since version 1.5, this hasn't been much of an issue, as that release introduced a rule in the mobs' AI to avoid rails unless they are chasing after the player. Although I have still found Zombie Pigmen appearing on the tracks, this is now not as much of an issue as it was in previous versions.
Zombie Pigmen are able to spawn on rail tracks, so removing the walking path on the side will do nothing. But as has been mentioned, adding blocks above your tracks will prevent them from spawning and help keep them from walking onto your tracks 100% of the time. This is a common "fix", and has been around for quite a while, and it doesn't seem like the developers have any plans to stop this fix from being possible.
The following blocks can safely be placed above the tracks, and will not suffocate you:
- Glass panes (I would really recommend this one, since they are "cheaper" than glass blocks, works with stained glass panes as well)
- Glass blocks (works with stained glass as well)
- Glowstone blocks
- Leaf blocks
- Iron bars
- Fences (of all materials)
- Half-slabs (of all materials, note that they must be single, NOT double slabs)
- Stairs (of all materials)
- Trap doors
- Pistons (both extended and retracted)
There are other blocks that would work, such as Beds, Chests, TNT, or Enchantment Tables, but I have excluded them from the list due to being impractical.
Mobs definitely do spawn on soul sand, the solid block requirement is for the block graphically, and soul sand graphically is a solid block (no transparency).
I did test it with a glass enclosed room with a soul sand floor and zombie pigmen did spawn inside.
Best Answer
Make a large box as a cage. At one end of the box, in the last row of blocks, make a pit.
Then, make a one-block slot on the end of the wall just behind the pit, and then make a small section and fill it will snow golems. They will automatically attack pigmen, aggravating them (and since pigmen have bad AI compared to most mobs) the pigmen will run towards the snow golems, and fall into the pit.
You can either make the pit far enough to kill the pigmen and have hoppers pick up the drops, or you can make it one-block before killing them, and make a small window that looks onto their feet so you can hit them to also get the exp.