[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Transform xml to html


Subject: Re: [xsl] Transform xml to html
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 10 Mar 2006 12:29:22 -0500

Tracey,

At 11:46 AM 3/10/2006, you wrote:
I have an xml document that includes the whitespace character elements for indenting and line-feeds. It prints out neatly to the console. I would like to neatly display it on an html page, with all the tags and indenting. I can see the need to escape the various special characters and also insert <br /> at the appropriate places.

The simplest quick-and-dirty solution would be to wrap your console output in HTML <pre>. That will also look most like the console, by virtue of being in a monospace font.


If you want something nicer than that, how hard it is depends largely on how much nicer you want it. Simple techniques can be effective and get you some distance; but to get it much nicer, you're entering into a different realm and things can get considerably harder. This is mainly because XSLT 1.0 was designed to do neither heavy-duty string processing nor upconversion (for example, introducing implicit wrapper divs), both of which may be required. XSLT 2.0 will be much better at it, but it's quite new.

(Keep in mind that this isn't really an XML->HTML transform except formally, since the formatting information you want to capture isn't actually "in" the XML, but just happens to be stored that way.)

The bottom line, as always, is design your target first, and then develop the transform to get that result.

This sounds like a task that has been accomplished many times before. Is there an existing stylesheet that performs this easily? Can someone share or point me to a source? It would save me some valuable time.

While I hope you hear some suggestions, I actually think this isn't really a very generic task, largely because it depends on that how-nice-do-you-want-it question.


Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================


Current Thread
Keywords