Deklarativ TEX-Code aus beliebigem XML erzeugen
XML nach TeX
Vorstellung xml2tex
Vergleich der Ansätze
MyProject/ |--main.tex |--main.cfg (xmltex-Config) |--doc.xml (XML-Input) |--tei.xmt (xmltex-Mapping)
\def\xmlfile{doc.xml} % XML-Datei
\input xmltex.tex % laden von XML-TeX
MyProject/ |--main.tex |--(…)
\NAMESPACE{http://www.tei-c.org/ns/1.0}{tei.xmt}
MyProject/ |--(…) |--main.cfg (xmltex-Config)
<?xml version="1.0" encoding="UTF-8"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader>
<fileDesc>
<titleStmt>
<title>Title</title>
</titleStmt>
<publicationStmt>
<p>Publication Information</p>
</publicationStmt>
<sourceDesc>
<p>Information about the source</p>
</sourceDesc>
</fileDesc>
</teiHeader>
<text>
<body>
<p>Some text here.</p>
</body>
</text>
</TEI>
\XMLelement{TEI} % Elementname (QName)
{} % Attribute
{\begin{document}} % Beginn des Elements
{\end{document}} % Ende des Elements
MyProject/ |--(…) |--tei.xmt (xmltex-Mapping)
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="sample">
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="sample">
<fo:flow flow-name="xsl-region-body">
<fo:block>Sample FO document</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
$ pandoc -s -t docbook input.xml -o output.tex
<?xml version="1.0" encoding="UTF-8"?>
<article xmlns="http://docbook.org/ns/docbook" version="5.0">
<title>my Title</title>
<sect1>
<title>Random Section Title</title>
<para>This is a para and this is
<emphasis role="bold">bold</emphasis>
</para>
</sect1>
</article>
\section{This is a title}
This is a para and this is \textbf{bold}
<xsl:output method="text"/>
<xsl:template match="element"/>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xpath-default-namespace="http://www.tei-c.org/ns/1.0"
version="3.0">
<xsl:output method="text"/>
<xsl:template match="TEI">
<xsl:text>\documentclass{article}
</xsl:text>
<xsl:text>\begin{document}
</xsl:text>
<xsl:apply-templates select="* except teiHeader"/>
<xsl:text>\end{document}</xsl:text>
</xsl:template>
<xsl:template match="p">
<xsl:apply-templates/>
<xsl:text>

</xsl:text>
</xsl:template>
</xsl:stylesheet>
\documentclass{article}
\begin{document}
Some text here.
\end{document}
<?xml version="1.0" encoding="UTF-8"?>
<article xmlns="http://docbook.org/ns/docbook" version="5.0">
<title>Example</title>
<equation>
<mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML">
<mml:mi>A</mml:mi>
<mml:mo>=</mml:mo>
<mml:mi>π</mml:mi>
<mml:msup>
<mml:mrow>
<mml:mi>r</mml:mi>
</mml:mrow>
<mml:mrow>
<mml:mn>2</mml:mn>
</mml:mrow>
</mml:msup>
</mml:math>
</equation>
</article>
<?xml version="1.0" encoding="UTF-8"?>
<article xmlns="http://docbook.org/ns/docbook" version="5.0">
<title>Example</title>
<equation>
<?mml2tex A=\pi r^{2}?>
</equation>
</article>
<ns/>
Namespaces deklarieren (superwichtig :D)<import/>
Import anderer xml2tex-configs<preamble/>
alles vor \begin{document}
<front/>
alles direkt nach \begin{document}
<back/>
alles direkt vor \end{document}
<template/>
XML-Matching-Patterns nach TeX<regex/>
reguläre Ausdrücke nach TeX<charmap/>
Mapping von Unicode nach TeX<template context="dbk:section">
<rule break-after="2" name="section" type="cmd">
<param/>
</rule>
</template>
@name
→ TeX-Name@type = "cmd"|"env"
→ Makro, Umgebung<param>
→ {Parameter}<option>
→ [Optionale Argumente]<text>
→ einfacher Text<regex regex="(\d{1,2})\.(\d{1,2})\.(\d{4})">
<rule name="mydate" type="cmd">
<param select="regex-group(1)"/>
<param select="regex-group(2)"/>
<param select="regex-group(3)"/>
</rule>
</regex>
Zuordnung von regulären Ausdrücken inkl. Gruppen
<charmap ignore-imported-charmaps="false">
<!--= Uppercase Gamma -->
<char character="Γ" string="${\Upgamma}$"/>
<char character="Γ" string="$\boldsymbol{\Upgamma}$"
context="*[@css:font-weight eq 'bold']"/>
<char character="Γ" string="${\Gamma}$"
context="*[@css:font-style eq 'italic']"/>
</charmap>
Zeichen in MathML werden vorher von mml2tex in Math-Mode umgewandelt
Feature | xmltex | PassiveTeX | Pandoc | XSLT | xml2tex |
---|---|---|---|---|---|
XML | ✓ | FO | DocBook, JATS | ✓ | ✓ |
MathML | ✓ (XMT) | ✓ (XMT) | ✗ | XSLT | ✓ (mml2tex) |
table-in | XMT | FO | CALS, HTML | XSLT | CALS, HTML |
table-out | XMT | tabular | longtable | XSLT | tabularx/htmltabs |
Config | ✓ | XSLT | ✗ | XSLT | ✓ |