Write once layout everwhere (?)
![](https://secure.gravatar.com/avatar/e2e931c4616c1cfefed875388d493f2a.jpg?s=120&d=mm&r=g)
Hello, I have used ConTeXt in the past and I have been very pleased with it and the results obtained, much more than LaTeX. Now I am looking into a solution that would allow me to layout the content ConTeXt and in other formats that ConTeXt does not (Forgive my ignorance, if I am wrong) output, like HTML, Plain Text, or RTF (Those are the formats that I can think of that are interesting to me currently). Reading the Wiki one of those solutions would be XML, but I know very little about the subject, so this email is to ask about experiences in similar endeavors, other solutions for the same problem and how practical this is. I suppose that I would use this for general writing and for academic as well (Maths and engineering). Thanks, Pepe
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
On Sun, 10 Jun 2007, Pepe Barbe wrote:
Hello,
I have used ConTeXt in the past and I have been very pleased with it and the results obtained, much more than LaTeX.
Now I am looking into a solution that would allow me to layout the content ConTeXt and in other formats that ConTeXt does not (Forgive my ignorance, if I am wrong) output, like HTML, Plain Text, or RTF (Those are the formats that I can think of that are interesting to me currently).
Reading the Wiki one of those solutions would be XML, but I know very little about the subject, so this email is to ask about experiences in similar endeavors, other solutions for the same problem and how practical this is.
I have been exploring for something like this, but unfortunately have not found anything completely satisfactory. For "simple" documents, that is, only text, XML is the easiest. You have to determine a xml dtd, and then it is relatively easy to write context commands to parse it. It is also easy (but slightly cumbersome) to write a xsl stylesheet to parse xml into html. Most browsers do the xslt transformation on the fly. I found xml+css to be the easiest way to go, since you can do almost a one-to-one mapping of your ConTeXt commands. But most xml websites say that it is the "old" method and should not be used. To get plain text, you can do lynx -dump or something similar. I am sure there will be ways to convert xml to rtf, but I have not explored them. Some of the difficulties that I faced with simple documents was: 1. What is the xml equivalent of || 2. What is the xml equivalent of ~ ( ??) 3. What is the xml equivalent of \abbreviation {EECS} {Electrical Engineering and Computer Science} and then \EECS\ and \infull{EECS}. I did not have time to explore further, so I left my xml experiments there. For me the hardest part was to learn the xml way of thinking.
I suppose that I would use this for general writing and for academic as well (Maths and engineering).
For more complext documents (esp math), I do not like xml as an input format. Mathml is too verbose for me to write. Then there is the question of how useful is it to have a xml + mathml document. ConTeXt can parse it, and so can some of the browsers, but most browsers can not. Converting to html + images looks ugly, unless you put in a lot of effort. I have not tried converting xml+mathml to rtf or some office format. For complicated documents, I do not see the use of having an xml document. Most people are happy receiving a pdf. If someone wants to edit my files, and cannot edit tex file, he/she will not be able to edit xml files. If they use an office application to edit the file, I will need to backport the modifications manually. So he/she might as well use pdf annotation tools. If you do want to explore furhter, perhaps the easiest way is to use tex4ht, which does a decent job with most context documents and can convert to html, xml, and open office format. I do not like tex4ht because its html output is too verbose, and its documentation is a bit hard to follow. Aditya
![](https://secure.gravatar.com/avatar/386a116d129cdc597f2bb6210bbaff7a.jpg?s=120&d=mm&r=g)
On 6/11/07, Aditya Mahajan
Reading the Wiki one of those solutions would be XML,
try tbookdtd.sf.net myabe can help you. -- luigi ---------------------------------------------------------------- If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net
![](https://secure.gravatar.com/avatar/8b3c344f0adba6016612e05447039f44.jpg?s=120&d=mm&r=g)
On Sun, 10 Jun 2007, Pepe Barbe wrote:
Hello,
I have used ConTeXt in the past and I have been very pleased with it and the results obtained, much more than LaTeX.
Now I am looking into a solution that would allow me to layout the content ConTeXt and in other formats that ConTeXt does not (Forgive my ignorance, if I am wrong) output, like HTML, Plain Text, or RTF (Those are the formats that I can think of that are interesting to me currently).
I don't think it is possible to come up with an "universal elixir"
On Sunday 10 June 2007 23:49, Aditya Mahajan wrote: that does any format from source and is efficient to use. Plain text is the exchange medium I use. XML is too cumbersome to code by hand. Therefore I have solutions for specific situations. For example when a customer presents me with a non-fiction document already laid out in MSWord, I first save it as rtf. Then I run it through the program rtf2latex2e. This gives me an executable LaTeX file, with all the font changes etc. preserved. The I edit it in Gvim, using mass changes to convert LaTeX tags to an equivalent Context format. Some, like all the begin/end tags I just delete en masse. It is easy to go from the output of Context to plain text. There are plenty of pdf to ascii converters in GhostScript and PSUtils etc. The only big problem comes when there are columns involved. In that situation cut and paste from a pdf viewer window to an editor window can be helpful. -- John Culleton Able Indexing and Typesetting Precision typesetting (tm) at reasonable cost. Satisfaction guaranteed. http://wexfordpress.com
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
On Mon, 11 Jun 2007, John R. Culleton wrote:
On Sun, 10 Jun 2007, Pepe Barbe wrote:
Hello,
I have used ConTeXt in the past and I have been very pleased with it and the results obtained, much more than LaTeX.
Now I am looking into a solution that would allow me to layout the content ConTeXt and in other formats that ConTeXt does not (Forgive my ignorance, if I am wrong) output, like HTML, Plain Text, or RTF (Those are the formats that I can think of that are interesting to me currently).
I don't think it is possible to come up with an "universal elixir"
On Sunday 10 June 2007 23:49, Aditya Mahajan wrote: that does any format from source and is efficient to use. Plain text is the exchange medium I use. XML is too cumbersome to code by hand. Therefore I have solutions for specific situations. For example when a customer presents me with a non-fiction document already laid out in MSWord, I first save it as rtf. Then I run it through the program rtf2latex2e. This gives me an executable LaTeX file, with all the font changes etc. preserved. The I edit it in Gvim, using mass changes to convert LaTeX tags to an equivalent Context format. Some, like all the begin/end tags I just delete en masse.
This approach is fine if you have to convert only once. However, if you want to occassionally update the sources and get an updated html and pdf output, it can be too much work. For situations like this, I think that, at least for just text + graphics, xml is the most robust way. Of course, there are also plain text markup formats, like wiki markup, restructured text, textile, etc. If the document is really simple, they may be easier to use. There are many plain text markup to LaTeX convertor, but no plain text to ConTeXt convertor that I know of. I remember there was someone on the list who had written scripts to convert wiki markup into context and then to pdf. I do not know if these scripts are publically available. Aditya
![](https://secure.gravatar.com/avatar/d0e94fb08d4620cfbd2f8f59a7868637.jpg?s=120&d=mm&r=g)
On Jun 11, 2007, at 5:49 AM, Aditya Mahajan wrote:
Some of the difficulties that I faced with simple documents was:
1. What is the xml equivalent of || 2. What is the xml equivalent of ~ ( ??) 3. What is the xml equivalent of
\abbreviation {EECS} {Electrical Engineering and Computer Science} and then \EECS\ and \infull{EECS}.
Hi Aditya, I've just begun experimenting with xlm (because, as Duncan has pointed out, I'm sure that every line I write is for eternity...). Anyway, what I say here may be totally wrong, but here's how I treat this stuff: 1. For || or |-|, I have defined an entity in my DTD: <!ENTITY conthyph "-"> In my environment for processing the xml files, I have \defineXMLentity[conthyph]{|-|} so I can write context&conthyph;specific and get the output I expect. 2. Yes, I use with these definitions: <!ENTITY nbsp " "> \defineXMLentity[nbsp]{~} 3. Abbreviations: does xtag-ent.tex do what you want? Not sure if this is what you're looking for, but it does appear to work for me. All best Thomas
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
Hi Thomas, On Mon, 11 Jun 2007, Thomas A. Schmitz wrote:
On Jun 11, 2007, at 5:49 AM, Aditya Mahajan wrote:
Some of the difficulties that I faced with simple documents was:
1. What is the xml equivalent of || 2. What is the xml equivalent of ~ ( ??) 3. What is the xml equivalent of
\abbreviation {EECS} {Electrical Engineering and Computer Science} and then \EECS\ and \infull{EECS}.
Hi Aditya,
I've just begun experimenting with xlm (because, as Duncan has pointed out, I'm sure that every line I write is for eternity...). Anyway, what I say here may be totally wrong, but here's how I treat this stuff:
1. For || or |-|, I have defined an entity in my DTD:
<!ENTITY conthyph "-">
In my environment for processing the xml files, I have
\defineXMLentity[conthyph]{|-|}
so I can write context&conthyph;specific and get the output I expect.
2. Yes, I use with these definitions: <!ENTITY nbsp " "> \defineXMLentity[nbsp]{~}
Ah. Thanks. This was easy :)
3. Abbreviations: does xtag-ent.tex do what you want?
Not sure if this is what you're looking for, but it does appear to work for me.
Hmm... somehome I had missed xtag-ent.tex. I was looking at xml introductions, and did not look into ConTeXt sources. I will have a look and see how it goes. Thanks, Aditya
![](https://secure.gravatar.com/avatar/93131e1e6e2204bd13501390d768dbdc.jpg?s=120&d=mm&r=g)
2007/6/11, Aditya Mahajan
Hmm... somehome I had missed xtag-ent.tex. I was looking at xml introductions, and did not look into ConTeXt sources. I will have a look and see how it goes.
Thanks, Aditya
Hi Aditya, the XML-Document example.pdf is a little bit outdated (Hans changed a few commands). The important files for xml are xtag-ini and xtag-ext, you should take a look into the contml module. Wolfgang
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
Quoting Wolfgang Schuster
2007/6/11, Aditya Mahajan
: Hmm... somehome I had missed xtag-ent.tex. I was looking at xml introductions, and did not look into ConTeXt sources. I will have a look and see how it goes.
Thanks, Aditya
Hi Aditya,
the XML-Document example.pdf is a little bit outdated (Hans changed a few commands). The important files for xml are xtag-ini and xtag-ext, you should take a look into the contml module.
Thanks. I had not looked at them and some of the things about handling
at the ConTeXt end are more clear now. But I think that I did not
explain my question correctly.
What I do not understand how are abbreviations etc. handled by xslt for
conversion into html. For example, how do I write an xsl style sheet
that converts this xml input
![](https://secure.gravatar.com/avatar/4e9e1d8d1a9e48815e89a0c42439fd82.jpg?s=120&d=mm&r=g)
On Mon, 11 Jun 2007 11:42:23 -0400, Aditya Mahajan
Thanks. I had not looked at them and some of the things about handling at the ConTeXt end are more clear now. But I think that I did not explain my question correctly.
What I do not understand how are abbreviations etc. handled by xslt for conversion into html. For example, how do I write an xsl style sheet that converts this xml input
<p> I study <abbrev value="EECS"> which stands for
</p> into html as
<p> I study EECS which stands for Electrical Engineering and Computer Science </p>
I know that this is not the right list to ask this sort of questions, but I am hoping that there are xml users here and they will be able to point me to the right direction.
I haven't followed the thread, but attached an idea of doing what you want with XSLT. Note that your example is not valid at all (commas between attributes, missing ending '/' for empty elements). BTW, it's not a good idea to use the same attribute ("value") as an reference identifier, and for referencing to another element. Regards,
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
Quoting nico
On Mon, 11 Jun 2007 11:42:23 -0400, Aditya Mahajan
wrote: Thanks. I had not looked at them and some of the things about handling at the ConTeXt end are more clear now. But I think that I did not explain my question correctly.
What I do not understand how are abbreviations etc. handled by xslt for conversion into html. For example, how do I write an xsl style sheet that converts this xml input
<p> I study <abbrev value="EECS"> which stands for
</p> into html as
<p> I study EECS which stands for Electrical Engineering and Computer Science </p>
I know that this is not the right list to ask this sort of questions, but I am hoping that there are xml users here and they will be able to point me to the right direction.
I haven't followed the thread, but attached an idea of doing what you want with XSLT. Note that your example is not valid at all (commas between attributes, missing ending '/' for empty elements).
Thank you. This is exactly what I wanted. I will now go back to using xml for simple documents and see how things go.
BTW, it's not a good idea to use the same attribute ("value") as an reference identifier, and for referencing to another element.
Ok. I will keep this in mind. Thanks, Aditya
![](https://secure.gravatar.com/avatar/4e9e1d8d1a9e48815e89a0c42439fd82.jpg?s=120&d=mm&r=g)
Hello,
On Sun, 10 Jun 2007 17:31:45 -0500, Pepe Barbe
I have used ConTeXt in the past and I have been very pleased with it and the results obtained, much more than LaTeX.
Now I am looking into a solution that would allow me to layout the content ConTeXt and in other formats that ConTeXt does not (Forgive my ignorance, if I am wrong) output, like HTML, Plain Text, or RTF (Those are the formats that I can think of that are interesting to me currently).
Reading the Wiki one of those solutions would be XML, but I know very little about the subject, so this email is to ask about experiences in similar endeavors, other solutions for the same problem and how practical this is.
I suppose that I would use this for general writing and for academic as well (Maths and engineering).
XML is a good format if you need several output formats without losing information (XHTML, HTML, PDF, manpages, plain text). But I recommend some well established grammar (DITA, DocBook) to be able to use their official transformation tools, and to be able to use some XML WYSIWYG editor that supports them natively (like XXE). Strangely enough the PDF output is weakest point since most of the tools use FO and the related compilers (well known FOP, maybe xmlroff, maybe fotex) which can give very ugly output. The only good compiler I know is XEP, but it is not free (there's a full featured personnal edition that sticks its logo on every page). For docbook, you can try marginal tools to convert the XML to *tex formats (DocbookInContext, db2latex, dblatex). You can also directly use the native XML handling of context (method used by DocbookInContext) but IMHO it needs some context knowledge. Personnaly I use docbook, mostly because I have to produce PDF, HTML, and troff (manpages) outputs. It is even possible to convert some already existing manpages to docbook with doclifter. Regards, BG
participants (7)
-
Aditya Mahajan
-
John R. Culleton
-
luigi scarso
-
nico
-
Pepe Barbe
-
Thomas A. Schmitz
-
Wolfgang Schuster