As far as I know,¹ there are not rules allowing this, but there is good reason for a DM to do so.
There are a lot of character options that require one to pick a particular weapon for them to work with, or which are locked into one particular weapon as written. The vast majority of martial characters will miss out on substantial chunks of their character if they use a different weapon; in almost all cases, it simply isn’t a realistic option. Such characters are locked into one kind of weapon and cannot realistically justify using another given the option.
Moreover, since upgrading weapon enhancements is no difficulty, it’s fairly typical for a character to start with a masterwork weapon, that they just keep improving (or having improved). It’s very common for characters to have very specific needs from their weapon, so random found treasure is very difficult to use, so in my experience characters won’t more often than they will. This is relevant because choosing a masterwork greatsword over a masterwork longsword costs practically nothing at the start. Re-doing enhancements, on the other hand, costs a ton.
Finally, weapon choice—for all you get locked into something due to character options that make you pick a weapon—rarely matters that much.² A given character might need something that works with Weapon Finesse, or has reach, or whatever, but outside of the broad strokes, which one they pick often isn’t all that important. So very often, in the end, which compatible weapon is selected is often about aesthetic. It’s about the way the player imagines their character and backing that up with the choices they make. This is very important to a lot of players, and is something the DM should support—it promotes engagement, and in some cases can avoid bad feelings.
So for all these reasons, PCs tend to stick with one type of weapon, if not with exactly one weapon (or pair) total. This conflicts very heavily with your desire to use random treasure! Especially if someone’s specialized in the use of a rare weapon that may not appear in random weapon tables at all. What usually winds up happening in such cases is that weapons—really, most treasure—is just sold. It’s usually sold for 50% of its base value, but at the same time, you as DM are intended to keep the party members at roughly their “Wealth by Level” as indicated by Table 5–1: Character Wealth by Level on Dungeon Master’s Guide page 135—so if the PCs keep getting treasure and selling it for 50% of the value, you need to start padding their treasure with extra to make up that difference. At that point, selling this longsword, and then crafting a greatsword with the same enhancements, costs money that the PCs will eventually “get back,” and just wastes time (and if the cleric does it herself, XP, which can become a massive headache for you, as DM³). It’s a bunch of time and effort to achieve something that makes no difference in the end.
So skip all that. Let people use the weapons they want or need to use. Whether that’s a “transfer enhancement” ritual, or a ritual to change the underlying longsword into a greatsword, is up to you, but one of those options or both is very appropriate in this situation. I strongly recommend you allow it.
D&D 3.5e is vast, and while I’m an expert in the edition, there’s just so much in it that I can’t guarantee a negative, particularly if you start including more obscure supplements or Dragon or Dungeon magazines.
Except when it does, which usually means that character options have been invested in things that only work with a particular weapon—a cleric or champion of Corellon Larethian might be obligated to use his favored longsword, a finesse tripper might really not have any compatible alternative to spiked chain, etc.
When the cleric spends XP on crafting, it means she won’t level-up at the same time as other PCs. Split-level parties are extremely difficult to DM for, and worse the difference in level means you have to calculate XP separately for each of the PCs (since she is lower level, she is supposed to get more XP from the same challenge). All these kinds of things are why Pathfinder just ditched the XP costs of crafting items.