Combining rotation axes of two transforms

I have two transforms and I’d like to take the X and Z axes of transform1 and the Y axis of transform2 and combine them. I’ve tried to do this with Euler angles and keep getting gimbal lock problems, is there a way to do this with only Quaternions?

Something like this:

transform.rotation = 
    Quaternion.Euler(rot1X, 0, 0) *
    Quaternion.Euler(0, rot2Y, 0) *
    Quaternion.Euler(0, 0, rot1Z);

?

I assume that you meant the eulerAngles?:

transform.rotation = 
     Quaternion.Euler(transform1.eulerAngles.x, 0, 0) *
     Quaternion.Euler(0, transform2.eulerAngles.y, 0) *
     Quaternion.Euler(0, 0, transform1.eulerAngles.z);

Unfortunately I still experience what appears to be gimbal-lock when rotating on the X axis beyond the world up vector.