[XML-SIG] xsl transforms for displaying XML in a browser

Lloyd Kvam pythonTutor at venix.com
Mon Oct 4 04:00:13 CEST 2004

Thanks Dave.

What I wound up doing was generating a boilerplate xsl file by modifying
your generateDS.py program.  Rather than generating Python classes I
modified the generate function to call code to write xsl transformations
for each element.  This resulted in about 1400 lines of code.  I deleted
most of it (where the default to <xsl:apply-templates /> would be
adequate) and then fixed the remaining 400 lines to produce useful XHTML
and tacked on a style sheet.  I decided to work from the schema because
my generated XML omits many elements that were unnecessary for my
purposes.  This way the transform should work with any XML files that
conform to this schema.

Since the code inserted into generateDS makes little sense on its own, I
am enclosing a small script that generates a set of transforms for a
given XML file.

For me, the benefits of generating the xsl file were:
	correctly spelled element names
	complete layout of the structure to be transformed
	most of the coding now becomes the addition of markup elements

On Fri, 2004-10-01 at 20:19, Dave Kuhlman wrote:
> On Fri, Oct 01, 2004 at 05:12:49PM -0400, Lloyd Kvam wrote:
> > I did try the lazy route.  The default XML display is just not good
> > enough.  Pretty printed XML is too cluttered and a simple text extract
> > just runs on.  Essentially I need to add some labels, blocking, and
> > breaks into the text stream.  I'll simply write it out.
> > 
> > Thanks.
> > 
> > On Fri, 2004-10-01 at 16:52, Thomas B. Passin wrote:
> > > Lloyd Kvam wrote:
> > > > I have a rather complicated (100 tags) XML file that needs to get 
> > > > displayed sensibly in a browser.  I've started writing the XSL to 
> > > > transform the document to html.  (CSS is too simple and the XML file 
> > > > needs to be readable for people without requiring special software.)
> > > > 
> > > > Is there a smart way to do this?  I am thinking of writing a python 
> > > > script to simply generate an XSL file with explicit templates for
> > > > every tag.  I would then modify this collection of boiler-plate code
> > > > to get a reasonable layout.
> > > 
> > > Well, both Mozilla/Firefox and Internet Explorer already will display
> > > pretty good pretty-printed versions.  Maybe you don't need to do 
> > > anything special.
> Lloyd -
> This isn't XSLT, but ...
> Have you looked at SciTE.  It's a text editor that can export to
> HTML and PDF and several others.  I just tried it on an XML file
> and the resulting HTML and PDF look reasonable.
> It looks like the exported output is slightly custom-izable.
> The generated HTML uses CSS, which it embeds in the HTML output
> file.  So you might be able to customize that a bit also.
> See:
>     http://scintilla.sourceforge.net/SciTE.html
> For a little information on customization, see the documentation
> and search for ("export.html" and export.pdf") at:
>     http://scintilla.sourceforge.net/SciTEDoc.html
> Dave
Lloyd Kvam
Venix Corp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xml2xsl.py
Type: text/x-python
Size: 1121 bytes
Desc: not available
Url : http://mail.python.org/pipermail/xml-sig/attachments/20041003/1af35bc0/xml2xsl.py

More information about the XML-SIG mailing list