This is a common problem on the XT brakes, I have stated before these are a pain in the ass to bleed. Every other brake system I have had have always been a doddle to bleed.
I had the same issue for the first few times, I would bleed from the caliper end till no more bubbles were seen. Everything would be ok then all of a sudden the lever would return to the bar and a few sudden pumps would harden it up again.
I found if you leave the res cap on and the lever pulled back (isolating the caliper) attach a syringe full of mineral oil to the caliper and crack the bleed nut, then create a vaccum by pulling on the syringe you should be able to remove the trapped air in the caliper.