
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:saxon="http://icl.com/saxon"  
                extension-element-prefixes="saxon"
                version="1.0">

<xsl:import href="9573common.xsl"/>

<xsl:output method="text"/>
<xsl:template match="document">
\documentclass[a4paper]{article}
\pagestyle{myheadings}
\markboth{ISO/IEC DTR 9573-13 2nd Ed.}{ISO/IEC DTR 9573-13 2nd Ed.}

\addtolength\textheight{4\baselineskip}
\addtolength\topmargin{-3\baselineskip}

\newcounter{note}

\usepackage{longtable,array,graphicx,pslatex,hyperref,url}
\extrarowheight1pt
\LTleft=-1in plus 3in
\LTright=-1in plus 3in
\hypersetup{colorlinks,pdftitle={9573},
  pdfsubject={9573},
  pdfauthor={David Carlisle},
  pdfkeywords={ISO entities XML MathML},
  bookmarks=true,
  pdfpagemode=UseOutlines,
  }

\hypersetup{
  linkcolor=black,
  anchorcolor=black,
  }


\let\amp&amp;
\begin{document}
%\small

\title{<xsl:apply-templates mode="doc" select="head/title/node()"/>\\
<xsl:apply-templates mode="doc" select="head/subtitle/node()"/>}

\author{<xsl:for-each select="head/author">
<xsl:apply-templates mode="doc" select="node()"/>
<xsl:if test="position()&lt;last()">\and </xsl:if>
</xsl:for-each>}

\date{<xsl:apply-templates mode="doc" select="head/date/node()"/>}

\maketitle

{\def\addvspace#1{}\tableofcontents}
\clearpage

{
\catcode`\#=12
\catcode`\&amp;=12
\catcode`\%=12



<xsl:apply-templates  mode="doc"/>

}
\end{document}
</xsl:template>



<xsl:template match="document" mode="doc">
<xsl:apply-templates mode="doc"/>
</xsl:template>

<xsl:template match="head" mode="doc"/>

<xsl:template match="section" mode="doc">
<xsl:if test="@break='yes'">
\clearpage
</xsl:if>
<xsl:apply-templates mode="doc"/>
</xsl:template>

<xsl:template match="section/head" mode="doc">

\section{<xsl:apply-templates mode="doc"/>}
</xsl:template>

<xsl:template match="section/section/head" mode="doc" priority="2">

\subsection{<xsl:apply-templates mode="doc"/>}
</xsl:template>

<xsl:template match="p" mode="doc">
<xsl:text>&#10;&#10;</xsl:text>
<xsl:apply-templates mode="doc"/>
<xsl:text>&#10;&#10;</xsl:text>
</xsl:template>


<xsl:template match="note" mode="doc">
\begin{quote}
\refstepcounter{note}\itshape Note \thenote:
<xsl:apply-templates mode="doc"/>
\end{quote}
</xsl:template>

<xsl:template match="pre" mode="doc">
{\small

\begin{verbatim}
<xsl:apply-templates mode="doc"/>
\end{verbatim}

}
</xsl:template>

<xsl:template match="code" mode="doc">
<xsl:text/>\texttt{<xsl:apply-templates mode="doc"/>}<xsl:text/>
</xsl:template>

<xsl:template match="br" mode="doc">
<xsl:text>\newline </xsl:text>
</xsl:template>

<xsl:template match="ul" mode="doc">
\begin{itemize}
<xsl:apply-templates mode="doc"/>
\end{itemize}
</xsl:template>


<xsl:template match="li" mode="doc">
\item
<xsl:apply-templates mode="doc"/>
<xsl:text>&#10;</xsl:text>
</xsl:template>

<xsl:template match="uri" mode="doc">
<xsl:text/>\url{<xsl:apply-templates mode="doc"/>}<xsl:text/>
</xsl:template>

<xsl:template match="quote" mode="doc">
<xsl:text/>``<xsl:apply-templates mode="doc"/>''<xsl:text/>
</xsl:template>

<xsl:template match="i" mode="doc">
<xsl:text/>\textit{<xsl:apply-templates mode="doc"/>}<xsl:text/>
</xsl:template>





<xsl:template match="charactertables" mode="doc">
<xsl:variable name="sub">
<xsl:for-each select="ancestor::section"
  >sub</xsl:for-each>
</xsl:variable>

<xsl:for-each select="$u">

<xsl:for-each select="$sets">
<xsl:sort select="@name"/>
<xsl:variable name="n" select="substring(@name,11)"/>
\clearpage
\<xsl:value-of select="$sub"/>section{<xsl:value-of select="$n"/>}

{\small
\begin{longtable}{|l|l|c|>\footnotesize m{.6\textwidth}|}
\caption*{<xsl:value-of select="$n"/>}\\
\bfseries Entity Name\amp
\bfseries Unicode/10646\amp
\bfseries Glyph image\amp
\bfseries Character Description\newline ISO Unicode/10646 Name\\
\hline\endhead
<xsl:for-each select="key('set',@name)">
<xsl:sort select="@id"/>
<xsl:value-of select="@id"/>\amp
<xsl:value-of select="substring-after(../@id,'U')"/>\amp
\raisebox{-3pt}{\includegraphics[scale=.5]{../glyphs/<xsl:choose>
<xsl:when test="../@image='none'">none</xsl:when>
<xsl:otherwise>
 <xsl:value-of select="substring(../@id,2,3)"/>/<xsl:value-of
 select="translate(../@id,'x','')"/>
 </xsl:otherwise>
 </xsl:choose>.png}}\amp
<xsl:value-of select="desc"/>\newline
<xsl:value-of select="../description"/>\\
</xsl:for-each>
\end{longtable}
}
</xsl:for-each>

</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
