1. A method for debugging Extensible Stylesheet Language (XSL) programs, comprising: automatically locating program elements within a first code of a first XSL program; for each located program element, automatically modifying the first code by inserting into the first code a second code for implementing a routine, the routine coded in a programming language that provides an element for maintaining a state information, and, when executed, generating a debugging comment based on the state information for a corresponding program element; and executing the modified first code.