473,473 Members | 2,215 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

xslt: force a start character on every output line


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. 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?

Thanks
-Dan

Oct 18 '05 #1
3 1728
"danmc91" <sp**@mcmahill.net> writes:
3) ascii where every line must start with a '%' character (octave
online help). I've more or less got something working for #1 and #2. The .xsl file
for #3 is proving to be a real pain. I'm using <xsl:output
method="text"/>. Is there some way to force every line in the output
file to start with a %?
I had to do this recently, and decided to output text with one long
line per paragraph (or so), then use fmt[*] to properly reformat
something that had to be kept in the 80-column limit.
xsltproc foo.xsl bar.xml | lynx -dump - | awk '{printf("% %s\n",
$0)}' > bar.m


If your only problem is to prepend '% ' to all lines, you could use :

xsltproc ... | sed 's/^/% /'

-- Alain.
[*] : weel, not really fmt, but a self-maid tool whose only purpose
was to properly reformat some parts of the document.
Oct 18 '05 #2
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

Oct 18 '05 #3
ok. Thanks for the replies. I think what I'll do for #3 is to
generate html then

x3m -dump foo.html | awk '{print "% " $0}' > foo.m

That seems to work well, and as you point out nroff and html viewers
both fill the roll of formatting the data for viewing.

Now I just need to get more proficient in xslt programming. Seems like
there are many ways to get to the same answer but some may be much
cleaner than others. I have something working but boy do I feel like
there are a lot of details I don't quite understand.

-Dan

Oct 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Christian Roth | last post by:
Hello, when using this "identity" processing sheet: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="iso-8859-1" /> ...
1
by: Mark247 | last post by:
Hi, When transforming an XSLT to HTML I get a very annnoying white spac gap of about 2px under each image. This is particularly annoying as am creating a vertical navigation menu made up of images...
3
by: bjam | last post by:
Hi, I am hoping someone can help with this I am assuming it is pretty basic but I don't see anything that jumps out at me at how to do this. Is there a way to have all the items output from the...
3
by: Grant Harmeyer | last post by:
Ok: I have done small level Xml stuff and am just now starting to understand some of the plumbing involved. I've done a lot of .NET programming for SQL Server, but little for Xml data stores. ...
2
by: Lionel Fourquaux | last post by:
In .Net 1.1, System.Xml.Xsl.XslTransform cannot output directly a document in an encoding that cannot represent all the characters used (e.g. write in us-ascii for compatibility, and convert all...
3
by: crc128 | last post by:
Hi, I'm looking at using XML and XSLT with apache cocoon to automatically generate html files for a site. the problem I'm having is that I want one of the pages to display a google map, but the...
11
by: cmay | last post by:
I am having this problem... Lets say that your source XML is formatted like this: <somenode> Here is some text Here is some more text </somenode> When to a <xsl:value-of select="somenode" /I...
1
by: qbp90x5lb | last post by:
I'm using an XSLT transform to output the element value contents from a simple XML file into a new .TXT file. Everything works fine except for certain XML files, when calling msxsl with the .xslt, I...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.