I use a set up like this that doesnt use any mechanisms and hasnt cost me a dwarf yet. Build a 6x6, build ropes on one side, your caged goblins, ratmen or other hostile creatures have there cages built on the other, Set your military on duty in the middle, find a trapper with animal training or animal care (Idont know which) and have them do no labour but the trapping stuff (trapping, animal care, Not hunting) then assign the goblin to a rope, the trapper will get a cage, take the goblin from its cage, put it in the new cage and take it to the rope, the trapper will them tie the goblin to the rope and your military will swamp them and hack them to small bits (build your killing room near the chasm or I use a pile just for corpses and bodyparts to rot them down for bones.)
The goblin can escape when 1. the cage is picked up from the pile (not likely, but I use hallways for animal stockpiles, 3 dwarvish civies can usually take down a goblin footslogger.
2. when the goblin is transfered to the cage and
3. during assigning to the rope 2+3 dont matter because the room is packed with armed dwarves. Dont do this with animals, any dwarf will have a go and they get scared and run off. only trappers seem to work with hostile creatures and ropes.
Hostile creatures dont seem to get away that often and with 10 or so military in the room heads fly fast so any that do get away dont last long. A stone fall trap just as a crippler on the door is also fun (I have about a dozen novice wrestlers from my relese the kiddie snatcher and then have whoever happens to be around out on their angry pants and do a bit of kicking program, my house Ber tore off a snatchers ear then choked the little bugger to death)
+++++
C++++
++++R
C+++R
C = Cage, R = Rope, + = floor, assign military by the dozen for training and the joy of slaughter.
Trying this with missile foes is a bad idea,
Trying it with Bowlords is suicidal.