Pokémon Diamond Version, Pearl Version, and Platinum Version - Switching Upon Fainting
A Pokémon is not changed to a different one immediately after it faints, but rather at the very end of the turn, after all end-of-turn effects. This behavior is new starting with Pokémon Diamond Version and Pokémon Pearl Version. Some exceptions are mentioned in the move list using wording like "The new Pokémon enters the battle immediately."
In Single Battles as well as Double Battles, if a Pokémon faints during its attack segment, the other Pokémon can still take their attack segment if they haven’t done so already.