danmc91 wrote:
Hi,
I'm just getting going with xml and xslt. I'm trying to write what are
essentially man pages and I need 3 output formats.
1) nroff -man format for real man pages
2) html for an online help browser
3) ascii where every line must start with a '%' character (octave
online help).
So, I made a simple DTD, a simple man page in xml format and hacked up
some .xsl files.
I've more or less got something working for #1 and #2. The .xsl file
for #3 is proving to be a real pain.
The assumption in most projects like this is that the output from
XML-->XSLT will be postprocessed by a formatter. This is true in
(1) nroff and (2) browser, but false for (3) because (my understanding
is that) Octave requires preformatted text -- in other words something
else has to do the formatting.
I'm using <xsl:output
method="text"/>. Is there some way to force every line in the output
file to start with a %? Or maybe I'm doing this the wrong way.
Perhaps I should output html and use something like
xsltproc foo.xsl bar.xml | lynx -dump - | awk '{printf("% %s\n",
$0)}' > bar.m
Any comments? Is this the sort of thing that xml and xslt are meant
for or am I really using the Wrong Tool?
You are absolutely right to be using XML to store the document, and to
use XSLT to output it to other formats for (1) and (2). Your solution
to (3) is one good way to do it. Alain posted another.
I suspect you *could* do it in XSLT, by buffering the output and slicing
it at (eg) 65 characters, but it would be a pain to code.
If you wanted to make a better shot at smoothing out the ragged right
margin caused by Octave using a proportional font to display text which
Lynx had formatted on the basis of a monospace font, I guess you could
output LaTeX and dvi2tty, but that has severe problems with anything
other than the 95 printable characters of ASCII.
///Peter