My 2004 XTR suffered from something similar, for quite a while.
There where no problems when i travelled, but using it mainly in Lima City traffic, i died on me.
Well, 1rst thought was on the battery so i bought a new one.
For about 2 weeks everything went well, `til it died again in mid trafic.
OK, can`t be the battery, so i checked the rectifier, ending up changing it. (fortunately i have a ton of spares for the bike)
Recharged the (new) battery again and off we went. Nevertheless, i had to charge the battery every once in a while (2 weeks) and i thought the problem may just be to be stucked in traffic while the engine revs at idle and head-, breaklights where on.
Finaly i checked the generator resistance.
Voil�! Coil resistance supposed to be anywhere arround 2.2 - 3.3 ohms at 20C. It turned out to sit between 8 - 10 ohms, depending on which coil i checked.
So finaly i ripped the generator from my spare engine, checked (~3 ohms) and replaced the faulty one.
RESULT!
It never came into my mind, that the generator might be faulty, neither ever heard of a similar problem.
I even tried the "old" battery and it works just fine again.
Indicators or differences between faulty and good generator that i realized, are:
*coil resistance (should be ~2.2 - 3.3 ohm)
*yellowish headlight (now bright again)
*engine has to crank a couple of times before it starts (now starts again on first turn)
*low battery capacity (after 2 - 3 failed start attempts the battery is down)
*engine performs "funny"
Hope this may be helpfull to anybody in a similar situation.
Had to buy a new multi tester to realize the tiny difference in coil resistance.