In mel you only ever get strings, floats or integers to work with - they are the names of objects in the scene, but not wrappers or handles to the objects themselves.
In your specific example, you'd want this:
string $joints[]=`ls -type "joint"`;
int $jnt_count = size($joints);
for ($i = 0; $i <= $jnt_count; $i++)
{
float $attr1 = `getAttr ($joints[$i] + ".rotateX")`;
// etc. See how this is done by adding the strings to
// create the string "youJointHere.rotateX", periods and all...
// the parens make sure string is composed before the command is called
setAttr ($joints[$i] + ".jointOrientX") $attr1;
// etc. Same trick
}
If you're new to this, you can save yourself a world of hurt and jumping straight to maya Python -- it's a lot more powerful than mel. The optional Pymel makes it even easier - the original code you posted is more or less what Pymel lets you do.
EDIT: forgot the $ variable identifier and parens in the first version.