Share this page 

Nicely display WEB.XML informationsTag(s): Servlet/JSP XML Jaguar/EAServer

A web.xml file contains informations about a web application hosted by a application server. While it's possible to consult the data using a regular text editor, it maybe easier to use a special stylesheet to nicely format the data for easy browsing.

I found a nice generic stylesheet on the Web and adapted it a little bit for that purpose. Here the modified xsl file, the css file, a sample web.xml.

See the sample output if your browser supports XML/XSL transformation.

Attach the xsl to the xml by adding this line to the xml file :

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="tree-view.xsl"?>
or do the transformation in Java, for a hint see this How-to.
Here an ASP page (yeah I know...) which accepts as a parameter an XML filename and transforms the passed filename using the XSL. As an added bonus, the original XML filename is displayed (you will need this XSL).
<META http-equiv="Content-Type" content="text/html; charset=ISO8859-1">
<%@ LANGUAGE="JScript" %>
 Response.buffer = true;
 var xmlfile;
 var oXML;
 var oXSL;
 var oXSLTemplate;
 var oXSLProcessor;
 var SrcXSL;
 var SrcXML;

 // get the PARAM=??? (assumes you have used GET request method!)...
 //   assume something like http://.../docxml.asp?xmlfile=myxml.xml
 xmlfile = '' + Request.QueryString('xmlfile');

 // get the source file (XML and XSL) paths
 SrcXML = Server.MapPath(xmlfile);
 SrcXSL = Server.MapPath('xmldoc/tree-view2.xsl');

 // create documents for the XML and XSL...
 oXML = Server.CreateObject('Msxml2.DOMDocument');
 oXSL = Server.CreateObject('Msxml2.FreeThreadedDOMDocument');

 // load the XML and XSL into your documents...
 //   we don't want to waste time validating the file
 oXML.validateOnParse = false ;
 oXML.async = false ;
 oXML.resolveExternals = false ;


 // create the XSL template and processor...
 oXSLTemplate = Server.CreateObject('Msxml2.XSLTemplate');
 oXSLTemplate.stylesheet = oXSL;
 oXSLProcessor = oXSLTemplate.createProcessor;

 // place the ?xmlfile=xxx value into the XSL processor...

 // tell the XSL processor of the XML you want to have transformed...
 oXSLProcessor.input = oXML;

 try {
   oXSLProcessor.transform ;
 catch (e) {
    ('The file ' +e.url + ' is not valid. Reason: ' + e.reason );