2

I am just working on my graduating thesis, when I making a new latex style for typesetting legal XML documents. I have my new latex style, which is overworked [article] with new commands and source legal XML file. I use a xmltex.

When I mapping XML tags to my Latex commands I dont know, how should i mapped unpaired tags with multiple attributes.

Update:

I am sorry for my too generalized question.

This is part of my XML document:

<?xml version="1.0" encoding="utf-8"?>
<Api1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Base="http://www.zakonyprolidi.cz" Version="2.612x5">
<DocData>
<Head>
<DocId>2021107</DocId>
<DocType>Zakon</DocType>
<Collection>cs</Collection>
<Code>2000-121</Code>
<Year>2000</Year>
<Batch>36</Batch>
<Number>121</Number>
<Quote>121/2000 Sb.</Quote>
<Title>Zákon o právu autorském, o právech souvisejících s právem autorským a o změně některých zákonů (autorský zákon)</Title>
<Short>Autorský zákon</Short>
<DeclareDate>2000-04-07</DeclareDate>
<PublishDate>2000-05-12</PublishDate>
<EffectFrom>2000-12-01</EffectFrom>
<EffectTill xsi:nil="true"/>
<LastUpdate>2014-09-13T00:15:42.403</LastUpdate>
<Href>/cs/2000-121</Href>
<File>2000c036z0121</File>
</Head>

<Fragments>

<Frag Struct="Virtual_Prefix" FID="f2021108" FragId="2021108" Diff="0" Valid="1" Level="1"/>
<Frag Struct="Prefix1" FID="f2021109" FragId="2021109" Diff="0" Valid="1" Level="2" Content="121"/>
<Frag Struct="Prefix2" FID="f2021110" FragId="2021110" Diff="0" Valid="1" Level="2" Content="Zákon"/>
<Frag Struct="Prefix3" FID="f2021111" FragId="2021111" Diff="0" Valid="1" Level="2" Content="ze dne 7. dubna 2000"/>
<Frag Struct="Prefix4" FID="f2021112" FragId="2021112" Diff="0" Valid="1" Level="2" Content="o právu autorském, o právech souvisejících s právem autorským a o změně některých zákonů (autorský zákon)"/>

<Paragraphs>
<Frag Struct="Preambule" FID="f2021113" FragId="2021113" Diff="0" Valid="1" Level="2" Content="Parlament se usnesl na tomto zákoně České republiky:"/>
<Frag Anchor="body" Struct="Virtual_Body" FID="f2021114" FragId="2021114" Diff="0" Valid="1" Level="1"/>
<Frag Quote="Část 1" Number="1" Anchor="cast1" Struct="Cast" FID="f2021115" FragId="2021115" Diff="0" Valid="1" Level="2" Content="ČÁST PRVNÍ"/>
<Frag Struct="Nadpis_pod" FID="f2021116" FragId="2021116" Diff="0" Valid="1" Level="3" Content="PRÁVO AUTORSKÉ A PRÁVA S NÍM SOUVISEJÍCÍ"/>
<Frag Quote="§ 1" Number="1" Anchor="p1" Struct="Paragraf" FID="f2021117" FragId="2021117" Diff="0" Valid="1" Level="3" Content="§ 1"/>
<Frag Struct="Nadpis_pod" FID="f2021118" FragId="2021118" Diff="0" Valid="1" Level="4" Content="Předmět úpravy"/>
<Frag Quote="§ 1 odst. 1" Anchor="p1-1" Struct="Odstavec_Dc" FID="f2021119" FragId="10581026" Diff="0" Valid="1" Level="4" Content="Tento zákon zapracovává příslušné předpisy Evropské unie a upravuje:"/>
<Frag Quote="§ 1 písm. a)" Number="a" Anchor="p1-1-a" Struct="Pismeno_Lb" FID="f2021121" FragId="2021122" Diff="0" Valid="1" Level="5" Content="<var>a)</var> práva autora k jeho autorskému dílu," EffectFrom="2006-05-22"/>
<Frag Quote="§ 1 písm. b)" Number="b" Anchor="p1-1-b" Struct="Pismeno_Lb" FID="f2021123" FragId="2021123" Diff="0" Valid="1" Level="5" Content="<var>b)</var> práva související s právem autorským:"/>
<Frag Quote="§ 1 písm. b) bod 1." Number="1" Anchor="p1-1-b-1" Struct="Bod_Dd" FID="f2021124" FragId="2021124" Diff="0" Valid="1" Level="6" Content="<var>1.</var> práva výkonného umělce k jeho uměleckému výkonu,"/>
<Frag Quote="§ 1 písm. b) bod 2." Number="2" Anchor="p1-1-b-2" Struct="Bod_Dd" FID="f2021125" FragId="2021125" Diff="0" Valid="1" Level="6" Content="<var>2.</var> právo výrobce zvukového záznamu k jeho záznamu,"/>
<Frag Quote="§ 1 písm. b) bod 3." Number="3" Anchor="p1-1-b-3" Struct="Bod_Dd" FID="f2021126" FragId="2021126" Diff="0" Valid="1" Level="6" Content="<var>3.</var> právo výrobce zvukově obrazového záznamu k jeho záznamu,"/>
<Frag Quote="§ 1 písm. b) bod 4." Number="4" Anchor="p1-1-b-4" Struct="Bod_Dd" FID="f2021127" FragId="2021128" Diff="0" Valid="1" Level="6" Content="<var>4.</var> právo rozhlasového nebo televizního vysílatele k jeho vysílání," EffectFrom="2006-05-22"/>
<Frag Quote="§ 1 písm. b) bod 5." Number="5" Anchor="p1-1-b-5" Struct="Bod_Dd" FID="f2021129" FragId="2021129" Diff="0" Valid="1" Level="6" Content="<var>5.</var> právo zveřejnitele k dosud nezveřejněnému dílu, k němuž uplynula doba trvání majetkových práv,"/>
<Frag Quote="§ 1 písm. b) bod 6." Number="6" Anchor="p1-1-b-6" Struct="Bod_Dd" FID="f2021130" FragId="2021130" Diff="0" Valid="1" Level="6" Content="<var>6.</var> právo nakladatele na odměnu v souvislosti se zhotovením rozmnoženiny jím vydaného díla pro osobní potřebu,"/>
<Frag Quote="§ 1 písm. c)" Number="c" Anchor="p1-1-c" Struct="Pismeno_Lb" FID="f2021131" FragId="2021131" Diff="0" Valid="1" Level="5" Content="<var>c)</var> právo pořizovatele k jím pořízené databázi,"/>
<Frag Quote="§ 1 písm. d)" Number="d" Anchor="p1-1-d" Struct="Pismeno_Lb" FID="f2021132" FragId="2021132" Diff="0" Valid="1" Level="5" Content="<var>d)</var> ochranu práv podle tohoto zákona,"/>
<Frag Quote="§ 1 písm. e)" Number="e" Anchor="p1-1-e" Struct="Pismeno_Lb" FID="f2021133" FragId="2021133" Diff="0" Valid="1" Level="5" Content="<var>e)</var> kolektivní správu práv autorských a práv souvisejících s právem autorským."/>
</Paragraphs>


</Fragments>

</DocData>

</Api1>

And this my "new latex style in xmt":

   \XMLelement{Api1}{}
{
%
% test.tex for testing LaTeX macros for typesetting 
% Czech law documents 
%
\documentclass[12pt, a4paper, twoside]{article}
%
% standard LaTeX packages
%
\usepackage[czech]{babel}
\usepackage[utf8]{inputenc}
%\usepackage[colorinlistoftodos]{todonotes}
%
% page layout
%
\usepackage[hmargin=10mm,
            tmargin=2mm,
            bmargin=10mm,
            includeheadfoot,
            heightrounded,
           ]{geometry}

\usepackage{fancyhdr}
\usepackage{enumitem}

%
% font setting
%
\usepackage{cmap}         % character mapping in PDF
\usepackage[T1]{fontenc}  % 8bit font encoding for better hyphenation 
\usepackage{microtype}    % pdftex microtypography extensions
\usepackage{garamond}     % garamond z http://gael-varoquaux.info/computers/garamond/
%
% multicol setting
%
\usepackage{multicol}
\multicolovershoot 12pt   % default 0pt 
\multicolundershoot 12pt  % default 2pt
%
% other settings
%
\emergencystretch 3dd
\parskip 3dd plus 2dd minus 2dd
%
% new macros
%
\newenvironment{absolutelynopagebreak}
  {\par\nobreak%\vfil\penalty0\vfilneg
   \vtop\bgroup}
  {\par\xdef\tpd{\the\prevdepth}\egroup
   \prevdepth=\tpd}
\newcommand{\nobpar}{\nobreak\par\nobreak}

\newcommand{\preambule}[1]{{\normalsize##1}{}}
\newcommand{\cast}[1]{\vskip 0.2em plus .2em minus .2em 
    {\centering\textbf{{\normalsize##1}}
    \nobpar}}
\newcommand{\castpod}[1]{{\vskip 0.2em plus .2em minus .2em
    \centering\normalsize
    \textbf{##1}
    \nobpar}}
\newcommand{\hlava}[1]{{\vskip 0.2em plus .2em minus .2em 
    \normalsize\centering {##1}\nobpar}}
\newcommand{\hlavapod}[1]{{\vskip 0.2em plus .2em minus .2em
    \normalsize \centering {##1}\nobpar}}
\newcommand{\dil}[1]{{\vskip 0.2em plus .2em minus .2em
    \itshape \centering {##1}\nobpar}}
\newcommand{\dilpod}[1]{{\vskip 0.2em plus .2em minus .2em
    \itshape \centering {##1}\nobpar}}
\newcommand{\paragraf}[1]{{\vskip 0.2em plus .2em minus .2em
    \centering{##1}\nobpar}}
\newcommand{\paragrafpod}[1]{{\vskip 0.2em plus .2em minus .2em
    \bfseries \centering{##1}\nobpar}}


\renewenvironment{center}{\vskip 0em \centering}

%
% style patches
%
\makeatletter
% maketitle patch
\def\@type{}
\newcommand{\type}[1]{
  \def\@type{##1}
}
\def\@numero{}
\newcommand{\numero}[1]{
  \def\@numero{##1}
}

\renewcommand{\@maketitle}{
\newpage
 \null
 \list{}{\rightmargin 35mm \leftmargin 35mm \vspace{-2.5em}}%
                \item\relax 
\begin{center}%
  {{\normalsize \bfseries \sffamily \@numero }\par}%
\end{center}%
 \begin{center}%
  {{\normalsize \bfseries \vskip 0.3em \@type }\par}%
 \end{center}%
 \begin{center}%
  {\normalsize \@date \par}%
 \end{center}%
 \begin{center}%
  {\normalsize \bfseries \@title \par}%
 \end{center}%
  \endlist
 \vskip 1em%
 \par 
 }


\makeatother

%
%zahlavi/zapati
%
\fancyhead[LO,RE]{{Strana \thepage}}
\fancyhead[C]{Sbírka zákonů č. \cislo}
\fancyhead[RO,LE]{Částka \castka}
\fancyfoot{}
\pagestyle{fancy}
\setlength\headheight{17.27403pt}
\makeatletter
\let\ps@plain\ps@fancy 
\makeatother
\renewcommand{\headrulewidth}{1.2pt}

\newcommand{\cislo}{{\sffamily\textbf{121}} / 2000}
%\newcommand{\castka}{}
\newcommand{\castka}[1]{{\normalsize##1}{}}

%predefinovani vyctovych prostredi pro telo paragrafu
%


\newenvironment{reenumerate}{
\begin{enumerate}
  \setlength{\itemsep}{0pt}
  \setlength{\parskip}{0pt}
  \setlength{\parsep}{0pt}
  \setlist[enumerate]{leftmargin=*}
  \renewcommand{\labelenumi}{\alph{enumi})}
  \renewcommand{\labelenumii}{\arabic{enumii}.}
}{\end{enumerate}}

\newenvironment{reenumerated}{
\begin{enumerate}
  \setlength{\itemsep}{4pt}
  \setlength{\parskip}{0pt}
  \setlength{\parsep}{0pt}
  \setlist[enumerate]{leftmargin=*}
  \renewcommand{\labelenumi}{(\arabic{enumi})}

}{\end{enumerate}}

\garamond
\raggedcolumns
\flushcolumns
\hyphenation{re-pu-bli-ky}

\title{}

\date{}

\type{}

\numero{}


\begin{document}




}
{\end{document}}

\XMLelement{Frag}
    {\XMLattribute{Content}{\type}{}}
    {\type}
    {}

%\XMLelement{Batch}{}{\xmlgrab}{\castka#1}

%\XMLelement{Paragraphs}{}{\begin{multicols}{2}[\maketitle]}{\end{multicols}}
%\XMLelement{Fragments}{}{\begin{absolutelynopagebreak}}{\end{absolutelynopagebreak}}         



\XMLelement{Head}{}{\xmlgrab}{}

I wish mapped specific content of attributes "Content" to latex's commands type, numero, date etc.. by content of attributes Struct.

//EDIT:

Thanks for reply. I will try to specify.

I overworked latex style "article" when I defined new commands "numero" and "type" and redefined "date" and "title" in for the typesetting a \maketitle. These commands should be matched with tags in xml file as follows:

Frag Struct="Prefix1" Content="121"  as command "numero" in latex and he typeset "121"
Frag Struct="Prefix2" Content="Zákon" latex command "type" typeset "Zákon"
etc

in principle:

if attribute Struct=Prefix1 then executes (typeset) the command "numero" etc.

I used xmltex because It seemed easier :)

//EDIT 2:

My Latex code typeset correctly at meantime. Fancyheadr works correctly too. To me it's mostly about whether it is possible to meet my main requirement mapped elements with multiple attributes in xmltex, so I do not commands numero, type, date and title entered manually at each xml document.

  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – user31729 Nov 21 '14 at 20:26
  • 2
    I don't think it is possible to understand the question in this form. Please show a small input XML document (you can highlight with the mouse and use the {} to mark it as a code section) and describe what latex (or xmltex) you wish to generate. You can not have \newcommand\number ans \number is an existing tex command, you need another name (but also you have given no indication what you want those commands to do. – David Carlisle Nov 21 '14 at 20:41
  • Why are you using xmltex? (I wouldn't use it and I wrote xmltex:-) It is easier to process xml using XSLT to generate latex output to process with latex as usual. That said, it probably is possible to use xmltex, but your question is still very unclear. the element names in your question fragment dont match those in the code Frag (I guess?? you mean them to be the same) similarly the attribute names, by structure do you mean Struct? Even if I assume you do mean the same here I honestly can not guess what output you want from this xml or what connection it has to \newcommand \number? – David Carlisle Nov 22 '14 at 17:21
  • Welcome to TeX.SX! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. – Martin Schröder Nov 22 '14 at 19:38
  • No offence but your LaTeX code is a mess. (I don't know much about XML so it may be beautiful.) That is, it will fail to compile due to errors. For example, you cannot redefine the center environment like that. You have a random(?) curly bracket in your document and why is \end{document} in curly brackets? Extremely minor point but you ought not set page dimensions directly if using geometry because you will screw up its ability to calculate the layout appropriately. (And why would you want plain to use the style of fancy?) – cfr Nov 23 '14 at 0:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.