Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Ok, so I've been using Lyx for about a year now. I haven't really dug too deep in to the LaTex/Tex side of things. I've a little more experience with XML + XSLT. It has a nice seperation of Data from Presentation. (you could even say of Model from View).

Lets say I have some information relating to a Timeline. In XML I would write:

<timeline title="Australian History>
    <timepoint year="60000BC" event="Aboriginal Migration">Aboriginal Australians are believed to have first arrived on the Australian mainland by boat from the Indonesian archipelago.</timepoint> 
    <timepoint year="1606" event="First European Landing"> The first uncontested landing in Australia by Europeans was by Dutch navigator Willem Janszoon </timepoint> 
    <timepoint year="1770" event="British Claim"> James Cook charted the East Coast of Australia[1] for Britain and returned with accounts favouring colonisation at Botany Bay (now in Sydney). </timepoint> 
    <timepoint year="1788" event="First Fleet Arrival"> A First Fleet of British ships arrived at Botany Bay in January, to establish a penal colony. </timepoint> 
    <timepoint year="1901" event="Federation"> The Commonwealth of Australia came into being when the Federal Constitution was proclaimed by the Governor General, Lord Hopetoun, on the 1st of January.</timepoint> 
</timeline>

(Datasource for above example).

And then I would write a XSL transformation to make this into some nice human readable form. Perhaps a petty SVG diagram, or a website with suitable formatting.

Is there a similar notion of seperating content from formatting in Latex? (that i could then embeed into Lyx). I thought one of the LaTex motto's was "Sort out the content, let the system take care of the formatting." (or something to that effect).

I've envisioning if nothing else then a XSLT could be written to transform the XML into Tex, and then that Tex could be Included. (and this exectution of the XSLT could be done each time the Lyx/Tex is exported). But that is ugly. The must be a nicer way of using some form of Extensiable Markup in Tex.

share|improve this question
add comment

4 Answers

up vote 10 down vote accepted

LaTeX already separates content from formatting. E.g. the look of \section{ABC} can be different depending on packages and classes. It is also easy to translate your XML-example in something more LaTeX-like e.g.

\begin{timeline}{title=Australian History}
     \timepoint{year=60000BC,event=Aboriginal Migration,text=Aboriginal ...}
     \timepoint{...}
\end{timeline}

Now you only need to write sensible definitions to get a suitable formatting.

The main difference between the markup from LaTeX and XML is that the first is less strict – and so better suited for normal, more or less messy human documents, where not everything can be pressed in the XML-model.

share|improve this answer
    
+1: yes! this is the way to do "data driven" documents in LaTeX. –  Juan A. Navarro Mar 8 '12 at 14:43
    
Thinking about it, there is a pretty straightforward way to map XML documents into a more LaTeXish syntax like that.. tags with nested content become environments, attributes become optional keyvalue arguments, while tags with just plain or text content become regular macros. –  Juan A. Navarro Mar 8 '12 at 14:47
    
What is this called so i can look it up in a Latex Book? –  Oxinabox Apr 16 '12 at 10:00
add comment

You certainly can use XSLT to generate TeX from XML for typesetting. That is how the PDF version of the MathML spec is produced for example. however the details depend greatly on the XML vocabulary used for input (and of course on the typesetting requirements for output).

If you don't want to literally use XML syntax in the input document, then many of the keyval interfaces to packages allow a syntax more natural for attribute-property declaration input. For thoughts on how LaTeX3 aims to improve the separation between layers, see Frank's answer in LaTeX3 versus pure Lua

share|improve this answer
add comment

There is the datatool package which lets you create a database and provides tools for manipulating and accessing the data.

share|improve this answer
add comment

One option that may or may not be suitable is yst. This is a tool that allows you to create TeX files from yaml files and string templates. (You can also write to markdown, html, and a bunch of other formats). I use this to keep a TeX and HTML version of my CV in sync. (Or rather, I will do, when I get around to rolling out the new version of my CV…)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.