Re: presenting sourcecode through XSL

Subject: Re: presenting sourcecode through XSL
From: Francis Norton <francis@xxxxxxxxxxx>
Date: Mon, 15 May 2000 20:11:24 +0100
Mattias Konradsson wrote:
> Anyway, I'm working on a XML-format for articles, course-litterature etc
> where you need to insert javascript code, html and
> xml source code into the document. Essentially I want an xsl stylesheets
> that takes a .js .html .xml or whatetever text
> format really and outputs html that displays it with exactly the same
> indents, whitespace and linebreaks. Anyone worked on
> something like this. I'm using MSXML.
Not as trivial as it sounds!

The task has two sub-problems. 

First, formatting. Actually this *is* simple, if inelegent. Just wrap
each document in an HTML <code> tag.

Second, getting the data in. One solution is just to use XML SYSTEM
entities to import the files as blocks of text. The only limitation on
this is that the text is imported as PCDATA (I think - or something with
the same effect). So any XML syntax in the imported document may break
your master document.

The solution to this is to write a little filter program to escape out
the text you are importing. In fact I happened to write a part solution
to this in java for the similar problem of importing directory listings,
so I have just extended it to escape "<"s as well as "&"s and posted it
(uncommented and untested, but with working demo data and batch file) to - unzip it all into one directory
and give it a try.


 XSL-List info and archive:

Current Thread