A system and method for debugging programs such as Extensible Stylesheet
Language (XSL) programs. A processor may locate program element tags in
an XSL program code, may modify the XSL program code by inserting for
each located program element new code that, when executed, implements a
routine coded in a state-maintaining language and that generates a
debugging comment, and may execute the modified XSL program code.