<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

  <xsl:output method="text"/>

  <xsl:template match="/">
\documentclass[letterpaper,11pt]{report}
\usepackage{faq}
\message{\the\textheight}
\begin{document}
    <xsl:apply-templates/>
\subsection{Revision history}\label{fullrev}
\begin{description}
    <xsl:for-each select="qandaset/blockinfo/revhistory/revision">
      <xsl:sort select="revnumber"/>
      <xsl:choose>
        <xsl:when test="position()=last()">
\par
        </xsl:when>
        <xsl:otherwise>
\item[<xsl:value-of select="revnumber"/>
              <xsl:text> (</xsl:text>
              <xsl:value-of select="date"/>
              <xsl:text>)</xsl:text>]
            <xsl:apply-templates select="revremark"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:for-each>
\end{description}
\end{document}
  </xsl:template>

  <xsl:template match="blockinfo">
\title{<xsl:value-of select="titleabbrev"/>}
\logo{<xsl:value-of 
 select="substring-before(substring-after(unparsed-entity-uri(graphic/@entityref),'file:'),'.')"/>}
\subtitle{<xsl:value-of select="title"/>}
\author{<xsl:apply-templates select="editor"/>}
\date{v<xsl:value-of select="//*[@id=edition/conref/@use]"/>***
    <xsl:text> (</xsl:text>
    <xsl:value-of select="//*[@id=edition/conref/@use]"/>
    <xsl:text>)</xsl:text>}
\maketitle
\tableofcontents
\renewcommand{\abstractname}{<xsl:value-of select="abstract/title"/>}
\begin{abstract}
    <xsl:apply-templates select="abstract"/>
\end{abstract}
    <xsl:apply-templates select="revhistory"/>
    <xsl:apply-templates select="legalnotice"/>
    <xsl:apply-templates select="authorblurb"/>
  </xsl:template>

  <!-- elements called from within the blockinfo header -->

  <xsl:template match="blockinfo/editor">
    <xsl:value-of select="firstname"/>
    <xsl:text> </xsl:text>
    <xsl:value-of select="surname"/>
    <xsl:text> (ed.)</xsl:text>
  </xsl:template>

  <xsl:template match="blockinfo/releaseinfo">
    <xsl:apply-templates/>
\par
  </xsl:template>

  <xsl:template match="blockinfo/abstract/title"/>

  <xsl:template match="blockinfo/legalnotice">
\subsection*{Legal stuff}\label{<xsl:value-of select="@id"/>}
\addcontentsline{toc}{subsection}{Legal stuff}
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="blockinfo/revhistory">
\subsection*{Current revision}\label{<xsl:value-of select="@id"/>}
\addcontentsline{toc}{subsection}{Current revision}
Earlier:
    <xsl:for-each select="revision">
      <xsl:sort select="revnumber"/>
      <xsl:choose>
        <xsl:when test="position()=last()">
(details on p.\pageref{fullrev}).
\subsubsection*{<xsl:value-of select="revnumber"/>
              <xsl:text> (</xsl:text>
              <xsl:value-of select="date"/>
              <xsl:text>)</xsl:text>}
            <xsl:apply-templates select="revremark"/>
\par
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="revnumber"/>
          <xsl:text> </xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="authorblurb">
\subsection*{Acknowledgements}\label{<xsl:value-of select="@id"/>}
\addcontentsline{toc}{subsection}{Acknowledgements}
    <xsl:apply-templates/>
\par
    <xsl:apply-templates select="../authorgroup"/>
    <xsl:text>.</xsl:text>
\par
  </xsl:template>

  <xsl:template match="othercredit">
    <xsl:value-of select="firstname"/>
    <xsl:text> </xsl:text>
    <xsl:value-of select="surname"/>
    <xsl:if test="count(following-sibling::othercredit)>0">
      <xsl:text>, </xsl:text>
    </xsl:if>
  </xsl:template>

  <!-- general structural -->

  <xsl:template match="para">
    <xsl:if test="@revisionflag">
      <xsl:choose>
        <xsl:when test="@revisionflag='changed'">
\leavevmode\llap{\S\ }%
        </xsl:when>
        <xsl:when test="@revisionflag='added'">
\leavevmode\llap{\P\ }%
        </xsl:when>
        <xsl:when test="@revisionflag='deleted'">
\leavevmode\llap{$\pm$\ }%
        </xsl:when>
        <xsl:otherwise>
          <xsl:text></xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:if>
    <xsl:if test="@id">
\label{<xsl:value-of select="@id"/>}
    </xsl:if>
    <xsl:apply-templates/>
\par
  </xsl:template>

  <xsl:template match="abstract/section/title">
\subsubsection*{<xsl:apply-templates/>}\label{<xsl:value-of select="../@id"/>}
  </xsl:template>

  <xsl:template match="para/itemizedlist | para/orderedlist">
\begin{inparaenum}[\itshape a\upshape)]
    <xsl:apply-templates/>
\end{inparaenum}
  </xsl:template>

  <xsl:template match="para/itemizedlist/listitem">
\item
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="listitem/para">
    <xsl:if test="@revisionflag">
      <xsl:choose>
        <xsl:when test="@revisionflag='changed'">\leavevmode\llap{\S\qquad}%
        </xsl:when>
        <xsl:when test="@revisionflag='added'">\leavevmode\llap{\P\qquad}%
        </xsl:when>
        <xsl:when test="@revisionflag='deleted'">\leavevmode\llap{$\pm$\qquad}%
        </xsl:when>
        <xsl:otherwise>
          <xsl:text></xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:if>
    <xsl:if test="@id">\label{<xsl:value-of select="@id"/>}
    </xsl:if>
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="filename">\verb`<xsl:value-of select="normalize-space(.)"/>`</xsl:template>

  <xsl:template match="variablelist">
\begin{description}
      <xsl:apply-templates/>
\end{description}
  </xsl:template>

  <xsl:template match="variablelist/varlistentry/term">
\item[<xsl:apply-templates/>]
  </xsl:template>

  <xsl:template match="variablelist/varlistentry/listitem">
      <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="orderedlist">
\begin{enumerate}
      <xsl:apply-templates/>
\end{enumerate}
  </xsl:template>

  <xsl:template match="itemizedlist">
\begin{itemize}
      <xsl:apply-templates/>
\end{itemize}
  </xsl:template>

  <xsl:template match="listitem">
\item
      <xsl:apply-templates/>
  </xsl:template>

  <!-- inline markup -->

  <xsl:template match="code">\url`<xsl:apply-templates/>`</xsl:template>

  <xsl:template match="ulink">
    <xsl:choose>
      <xsl:when test=".='' or .=@url">\url`<xsl:value-of select="@url"/>`</xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates/>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:if test=".!=''">\footnote{\url`<xsl:if test="@type='news'">
      <xsl:text>news:</xsl:text>
    </xsl:if>
    <xsl:value-of select="@url"/>`}</xsl:if>
  </xsl:template>

  <xsl:template match="link">
    <xsl:choose>
      <xsl:when test=".=''">
        <xsl:choose>
          <xsl:when test="//*[@id=current()/@linkend]//title">
\textit{<xsl:value-of select="//*[@id=current()/@linkend]//title"/>}
          </xsl:when>
          <xsl:otherwise>
            <xsl:text>the </xsl:text>
\texttt{<xsl:value-of select="name(//*[@id=current()/@linkend])"/>}
            <xsl:choose>
              <xsl:when test="preceding::*[@id=current()/@linkend]">
 above
              </xsl:when>
              <xsl:otherwise>
 below
              </xsl:otherwise>
            </xsl:choose>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates/>
      </xsl:otherwise>
    </xsl:choose><xsl:if test="@id">\label{<xsl:value-of select="@id"/>}</xsl:if> [<xsl:if test="//*[@id=current()/@linkend]/ancestor::qandadiv and count(ancestor::qandaentry | //*[@id=current()/@linkend]/ancestor::qandaentry)>1">\ref{<xsl:value-of select="@linkend"/>}, </xsl:if>p.\pageref{<xsl:value-of select="@linkend"/>}]</xsl:template>

  <xsl:template match="emphasis">\emph{<xsl:apply-templates/>}</xsl:template>

  <xsl:template match="quote">`<xsl:apply-templates/>'</xsl:template>

  <!-- elements used in questions -->

  <xsl:template match="qandadiv">
\clearpage
    <xsl:if test="count(preceding-sibling::qandadiv)=0">
\pagenumbering{arabic}
    </xsl:if>
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="qandadiv/title">
\section{<xsl:apply-templates/>}\label{<xsl:value-of select="../@id"/>}
  </xsl:template>

  <xsl:template match="qandaentry">
\subsection{<xsl:apply-templates select="question/formalpara/title"/>}%
\label{<xsl:value-of select="@id"/>}%
\marginpar{\scriptsize\sffamily\raggedright
  <xsl:apply-templates select="question/formalpara/para" mode="special"/>}
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="question/formalpara"/>

  <xsl:template match="question/formalpara/title">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="question/formalpara/para" mode="special">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="answer">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="simpara">
    <xsl:choose>
      <xsl:when test="@xreflabel">
\leavevmode\llap{<xsl:value-of select="@xreflabel"/>\ }%
      </xsl:when>
      <xsl:otherwise>
\leavevmode\llap{* }%
      </xsl:otherwise>
    </xsl:choose>
    <xsl:apply-templates/>
    <xsl:if test="count(following-sibling::simpara)>0">
\\
    </xsl:if>
  </xsl:template>

  <xsl:template match="note">
\begin{Sbox}\begin{minipage}{.8333\columnwidth}\small\sffamily\raggedright\setlength{\parindent}{1em}%
      <xsl:choose>
        <xsl:when test="not(simpara|title)">
          <xsl:if test="not(title)">
\subsubsection*{Note}
          </xsl:if>
          <xsl:if test="@id">\label{<xsl:value-of select="@id"/>}</xsl:if>
          <xsl:apply-templates/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:if test="@id">\label{<xsl:value-of select="@id"/>}</xsl:if>
          <xsl:apply-templates/>
\par
        </xsl:otherwise>
      </xsl:choose>
\end{minipage}\end{Sbox}
    <xsl:if test="descendant::ulink">
      <xsl:for-each select="descendant::ulink">
        <xsl:if test=".!=''">
\footnotetext{\url`<xsl:value-of select="@url"/>`}
        </xsl:if>
      </xsl:for-each>
    </xsl:if>
\begin{center}\setlength{\fboxsep}{1em}\colorbox{YellowSticky}{\TheSbox}\end{center}
  </xsl:template>

  <xsl:template match="warning">
\begin{Sbox}\begin{minipage}{.8333\columnwidth}\small\sffamily\raggedright\setlength{\parindent}{1em}%
      <xsl:if test="not(title)">
\subsubsection*{Warning}
      </xsl:if>
      <xsl:if test="@id">\label{<xsl:value-of select="@id"/>}</xsl:if>
      <xsl:apply-templates/>
\end{minipage}\end{Sbox}
    <xsl:if test="descendant::ulink">
      <xsl:for-each select="descendant::ulink">
        <xsl:if test=".!=''">
\footnotetext{\url`<xsl:value-of select="@url"/>`}
        </xsl:if>
      </xsl:for-each>
    </xsl:if>
\begin{center}\setlength{\fboxsep}{1em}\colorbox{PinkSticky}{\TheSbox}\end{center}
  </xsl:template>

  <xsl:template match="tip">
\begin{Sbox}\begin{minipage}{.8333\columnwidth}\small\sffamily\raggedright\setlength{\parindent}{1em}%
      <xsl:choose>
        <xsl:when test="@xreflabel">
\subsubsection*{<xsl:value-of select="@xreflabel"/>
            <xsl:text> writes:</xsl:text>}
        </xsl:when>
        <xsl:when test="not(title)">
\subsubsection*{Tip}
        </xsl:when>
      </xsl:choose>
      <xsl:if test="@id">\label{<xsl:value-of select="@id"/>}</xsl:if>
      <xsl:apply-templates/>
\end{minipage}\end{Sbox}
    <xsl:if test="descendant::ulink">
      <xsl:for-each select="descendant::ulink">
        <xsl:if test=".!=''">
\footnotetext{\url`<xsl:value-of select="@url"/>`}
        </xsl:if>
      </xsl:for-each>
    </xsl:if>
\begin{center}\setlength{\fboxsep}{1em}\colorbox{BlueSticky}{\TheSbox}\end{center}
  </xsl:template>

  <xsl:template match="warning/title | note/title | tip/title">
\subsubsection*{<xsl:apply-templates/>}
  </xsl:template>

  <xsl:template match="note//ulink | warning//ulink | tip//ulink">
    <xsl:choose>
      <xsl:when test=".='' or .=@url">\url`<xsl:value-of select="@url"/>`</xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates/>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:if test=".!=''">\footnotemark{}</xsl:if>
  </xsl:template>

  <xsl:template match="programlisting">
\begin{Sbox}\begin{minipage}{.8333\columnwidth}\footnotesize\bfseries\begin{Verbatim}
<xsl:value-of select="."/>
\end{Verbatim}
\end{minipage}\end{Sbox}\begin{center}\setlength{\fboxsep}{1em}\ovalbox{\TheSbox}\end{center}
  </xsl:template>

  <xsl:template match="para/programlisting">\verb`<xsl:value-of select="normalize-space(.)"/>`</xsl:template>

  <xsl:template match="sgmltag">\verb`<xsl:choose>
        <xsl:when test="@class='starttag'">
          <xsl:text>&lt;</xsl:text>
          <xsl:value-of select="."/>
          <xsl:text>&gt;</xsl:text>
        </xsl:when>
        <xsl:when test="@class='endtag'">
          <xsl:text>&lt;/</xsl:text>
          <xsl:value-of select="."/>
          <xsl:text>&gt;</xsl:text>
        </xsl:when>
        <xsl:when test="@class='emptytag'">
          <xsl:text>&lt;</xsl:text>
          <xsl:value-of select="."/>
          <xsl:text>/&gt;</xsl:text>
        </xsl:when>
        <xsl:when test="@class='genentity'">
          <xsl:text>&amp;</xsl:text>
          <xsl:value-of select="."/>
          <xsl:text>;</xsl:text>
        </xsl:when>
        <xsl:when test="@class='numcharref'">
          <xsl:text>&amp;#</xsl:text>
          <xsl:value-of select="."/>
          <xsl:text>;</xsl:text>
        </xsl:when>
        <xsl:when test="@class='attvalue'">
          <xsl:text>"</xsl:text>
          <xsl:value-of select="."/>
          <xsl:text>"</xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="."/>
        </xsl:otherwise>
      </xsl:choose>`</xsl:template>

  <xsl:template match="literal">
\verb`<xsl:value-of select="."/>`
  </xsl:template>

  <xsl:template match="biblioref"><xsl:if test="not(@role) or @role != 'footnote'">\emph{\citefield{title}{<xsl:value-of select="@linkend"/>}}</xsl:if>\footcite{<xsl:value-of select="@linkend"/>}</xsl:template>

  <xsl:template match="bibliolist">
\bibliographystyle{jurabib}
\bibliography{\jobname}
\begin{VerbatimOut}{\jobname.bib}
    <xsl:apply-templates/>
\end{VerbatimOut}
  </xsl:template>

  <xsl:template match="biblioentry">
    <xsl:text>@</xsl:text>
    <xsl:value-of select="@role"/>
    <xsl:text>{</xsl:text>
    <xsl:value-of select="@id"/>
    <xsl:text>,&#x000A;</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>  comment = {Written by XSLT}&#x000A;</xsl:text>
    <xsl:text>}&#x000A;</xsl:text>
  </xsl:template>

  <xsl:template match="authorgroup[ancestor::bibliolist]">
    <xsl:text>  author = {</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>},&#x000A;</xsl:text>
  </xsl:template>

  <xsl:template match="author[ancestor::biblioentry] | 
                       editor[ancestor::biblioentry]">
    <xsl:choose>
    <xsl:when test="parent::authorgroup">
      <xsl:if test="count(preceding-sibling::author|
                    preceding-sibling::editor) > 0">
        <xsl:text> and </xsl:text>
      </xsl:if>
    </xsl:when>
    <xsl:otherwise>
      <xsl:if test="@remap">
        <xsl:text>  jura</xsl:text>
        <xsl:value-of select="name()"/>
        <xsl:text> = {</xsl:text>
        <xsl:value-of select="@remap"/>
        <xsl:text>},&#x000A;</xsl:text>
        </xsl:if>
        <xsl:text>  </xsl:text>
        <xsl:value-of select="name()"/>
        <xsl:text> = {</xsl:text>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:if test="othername">
      <xsl:text>{</xsl:text>
      <xsl:value-of select="othername"/>
      <xsl:text>}</xsl:text>
    </xsl:if>
    <xsl:value-of select="firstname"/>
    <xsl:if test="firstname and surname">
      <xsl:text> </xsl:text>
    </xsl:if>
    <xsl:if test="surname[@remap='preserve']">
      <xsl:text>{</xsl:text>
    </xsl:if>
    <xsl:value-of select="surname"/>
    <xsl:if test="surname[@remap='preserve']">
      <xsl:text>}</xsl:text>
    </xsl:if>
    <xsl:if test="not(parent::authorgroup)">
      <xsl:text>},&#x000A;</xsl:text>
    </xsl:if>
  </xsl:template>

  <xsl:template match="surname"/>
  <xsl:template match="othername"/>
  <xsl:template match="firstname"/>

  <xsl:template match="biblioentry//title[1]">
    <xsl:text>  title = {{</xsl:text>
    <xsl:apply-templates/>
    <xsl:if test="following-sibling::subtitle">
      <xsl:text>: </xsl:text>
      <xsl:value-of select="following-sibling::subtitle"/>
    </xsl:if>
    <xsl:text>}},&#x000A;</xsl:text>
  </xsl:template>

  <xsl:template match="biblioentry//subtitle"/>

  <xsl:template match="biblioentry//title[2]">
    <xsl:choose>
      <xsl:when test="ancestor::biblioentry/@role='article'">
        <xsl:text>  journal = {</xsl:text>
      </xsl:when>
      <xsl:when test="ancestor::biblioentry/@role='inbook'">
        <xsl:text>  booktitle = {</xsl:text>
      </xsl:when>
      <xsl:when test="ancestor::biblioentry/@role='incollection'">
        <xsl:text>  booktitle = {</xsl:text>
      </xsl:when>
    </xsl:choose>
    <xsl:apply-templates/>
    <xsl:text>},&#x000A;</xsl:text>
  </xsl:template>

  <xsl:template match="titleabbrev">
    <xsl:text>  juratitle = {</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>},&#x000A;</xsl:text>
  </xsl:template>

  <xsl:template match="conftitle">
    <xsl:text>  booktitle = {</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>},&#x000A;</xsl:text>
  </xsl:template>

  <xsl:template match="confdates">
    <xsl:text>  year = {</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>},&#x000A;</xsl:text>
  </xsl:template>

  <xsl:template match="confgroup/address">
    <xsl:text>  address = {</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>},&#x000A;</xsl:text>
  </xsl:template>

  <xsl:template match="publishername">
    <xsl:text>  publisher = {</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>},&#x000A;</xsl:text>
  </xsl:template>

  <xsl:template match="pagenums">
    <xsl:text>  pages = {</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>},&#x000A;</xsl:text>
  </xsl:template>

  <xsl:template match="address | isbn | issn">
    <xsl:text>  </xsl:text>
    <xsl:value-of select="name()"/>
    <xsl:text> = {</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>},&#x000A;</xsl:text>
  </xsl:template>

  <xsl:template match="date">
    <xsl:text>  year = {</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>},&#x000A;</xsl:text>
  </xsl:template>

  <xsl:template match="releaseinfo">
    <xsl:text>  url = {</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>},&#x000A;</xsl:text>
  </xsl:template>

  <xsl:template match="biblioentry//artpagenums">
    <xsl:text>  pages = {</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>},&#x000A;</xsl:text>
  </xsl:template>

  <xsl:template match="biblioentry/orgname">
    <xsl:text>  organisation = {</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>},&#x000A;</xsl:text>
  </xsl:template>

  <xsl:template match="volumenum">
    <xsl:text>  volume = {</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>},&#x000A;</xsl:text>
  </xsl:template>

  <xsl:template match="edition">
    <xsl:text>  edition = {</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>},&#x000A;</xsl:text>
  </xsl:template>

  <xsl:template match="issuenum">
    <xsl:text>  number = {</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>},&#x000A;</xsl:text>
  </xsl:template>

  <xsl:template name="getsite">
    <xsl:param name="fqdn"/>
    <xsl:variable name="delim">
      <xsl:text>.</xsl:text>
    </xsl:variable>
    <!-- find the last token as domain -->
    <xsl:variable name="domain">
      <xsl:call-template name="getdomain">
        <xsl:with-param name="fqdn">
          <xsl:value-of select="$fqdn"/>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:variable>
    <!-- remove it from the fqdn, leaving the host -->
    <xsl:variable name="host">
      <xsl:value-of select="substring-before($fqdn,concat('.',$domain))"/>
    </xsl:variable>
    <!-- now repeat with the host to find the second-level domain -->
    <xsl:variable name="second">
      <xsl:call-template name="getdomain">
        <xsl:with-param name="fqdn">
          <xsl:value-of select="$host"/>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:variable>
    <xsl:choose>
      <!-- if the second-level domain was "co", repeat again -->
      <xsl:when test="$second='co'">
        <xsl:call-template name="getdomain">
          <xsl:with-param name="fqdn">
            <xsl:value-of 
              select="substring-before($host,concat('.',$second))"/>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:when>
      <!-- otherwise we've got it -->
      <xsl:otherwise>
        <xsl:value-of select="$second"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="getdomain">
    <xsl:param name="fqdn"/>
    <xsl:variable name="delim">
      <xsl:text>.</xsl:text>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="contains($fqdn,$delim)">
        <xsl:call-template name="getdomain">
          <xsl:with-param name="fqdn">
            <xsl:value-of select="substring-after($fqdn,$delim)"/>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$fqdn"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="processing-instruction('LaTeX')">
<xsl:value-of select="."/>
  </xsl:template>

</xsl:stylesheet>
