- Maxime Gaudin
Exporting xml files to latex' arrays can be very boring, time consuming and a pretty common task (especially if your teachers are old school nomenclature's lover). That's why I designed a little tool that export automatic ally your xml to a latex-friendly form.
Another pretty cool feature is the automatic preamble generation, see the Usage below.
usage: python xml2latex.py [args] [option]
List of arguments :
--input (-i) : Specifies the input file.
List of options :
--output (-o) : Specifies the output file. (Default : stdout)
--print-preambule (-p) : Generate preambule. (Default : True)
--print-code (-c) : Generate code. (Default : True)
--help (-h) : Print this text.
Author : Maxime Gaudin (2011)
** DO NOT FORGET TO LOOK AT THE BETTER EXAMPLE SECTION BELOW **
Let's say you have to export this file :
<annuaire>
<somebody>
<lastName>GAUDIN</lastName>
<surname>Maxime</surname>
<email>[email protected]</email>
</somebody>
<somebody>
<lastName>ST-GEORGES</lastName>
<surname>Julie</surname>
<email>[email protected]</email>
</somebody>
</annuaire>
Just call my script with : python xml2latex -c -i yourFile.xml, and then it produces (automatically):
\begin{annuaire}
\begin{somebody}
\lastName{GAUDIN}
\surname{Maxime}
\email{[email protected]}
\end{somebody}
\begin{somebody}
\lastName{ST-GEORGES}
\surname{Julie}
\email{[email protected]}
\end{somebody}
\end{annuaire}
Nothing complicated but so useful !
As you can see, the previous exemple works perfectly but is no so latex friendly (if you scheduled to use it in an array for instance). In fact, you have 2 use cases :
- You have to convert xml file not written for that purpose : Then get prepared to hack latex
- You have to write a xml file espacially for being converted to latex : Yeah, it will be cake walk !
Indeed, xml2latex handles attributes and the last xml will be better if written like :
<annuaire>
<somebody lastName="GAUDIN" surname="Maxime" email="[email protected]"/>
<somebody lastName="ST-GEORGES" surname="Julie" email="[email protected]"/>
</annuaire>
That's better, let's see the result :
\begin{annuaire}
\somebody{GAUDIN}{Maxime}{[email protected]}
\somebody{ST-GEORGES}{Julie}{[email protected]}
\end{annuaire}
BTW, it also handles empty markups like :
<jumpline/>
use them to format your document !
Obviously, it handles syntax like :
<annuaire>
<somebody lastName="GAUDIN" surname="Maxime">[email protected]</somebody>
<somebody lastName="ST-GEORGES" surname="Julie">[email protected]</somebody>
</annuaire>
and produces :
\begin{annuaire}
\somebody{GAUDIN}{Maxime}{[email protected]}
\somebody{ST-GEORGES}{Julie}{[email protected]}
\end{annuaire}
- Use LaTex
- Contribute
- Mail me :D