I am generating an XML file dynamically from a Java program and I want the same to display to the browser with the help of XSL file. I want to select the XSL file dynamically. How can I do that?

Thijs Stalenhoef

In order for the browser (IE 5 is the only shipping browser at this time to support XML and XSL) to know which XSL you want it to use you have to have to header that looks something like this:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="yourstylesheet.xsl" ?>

in your XML. The second line defines which stylesheet will be used. Since you are generating your XML dynamically, changing this second line to point to another XSL file should be easy.