Re: Stylesheet to view XML code in browser

Subject: Re: Stylesheet to view XML code in browser
From: "John E. Simpson" <simpson@xxxxxxxxxxx>
Date: Thu, 04 Nov 1999 10:06:34 -0500
At 01:08 PM 11/4/1999 +0000, Dylan Walsh wrote:
Does anyone know of any examples stylesheets which take any XML code and
render it as HTML to view in a browser?
For example, it might output the code indented and highlighted to make
it easy to read.

Probably not the answer you want, but Microsoft's IE5 browser uses a default stylesheet for rendering XML documents on-screen as an expandable/collapsible tree of elements. In theory you could put that default stylesheet on a back-end server, with an XSL processor (maybe a servlet, server-side JavaScript, CGI or what-have-you) to do the conversion to HTML on the fly. The trouble with (or advantage of, depending on your perspective :) the MSIE5 default stylesheet is that it runs in the client -- and MSIE5 is (surprise!) the only client that can run it.


Ken Holman, a frequent contributor to this list, has come up with a generic stylesheet called SHOWTREE that will do what you want. It's at:
http://www.cranesoftwrights.com/resources/showtree/index.htm
From the description at that page:
"The stylesheet will report the node structure and content of an input document, noting the ordinal positions in the hierarchy of each component of the ancestry. The stylesheet exposes root, element, attribute, text, comment, and pi nodes. This stylesheet does not expose the namespace axis due to limitations acknowledged in the current implementation of XT."


There are versions of it to support different XSL processors -- at least MSIE and XT.

As Ken mentions on the above page, there's another generic tool written by Mike Brown, called the Fancy XML Tree Viewer, at:
http://www.skew.org/xml/
It's more graphically-oriented than Ken's; drawback is that it isn't as up-to-date with the spec.


In either case -- unless you're using IE5 -- to "see" the generated tree you'll have to feed the XML/XSL combination into a pre-processor like XT or LotusXSL, rather than directly to the browser.
=============================================================
John E. Simpson
simpson@xxxxxxxxxxx
++++++++++++++++++++
"Why is the alphabet in that order? Is it because of
that song?" (Stephen Wright)



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread