GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
1
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
nigel.stanger
/
XML
Browse code
- Completely revamped section and title processing.
master
OLD_GRAPHICS_HANDLING
1 parent
075b405
commit
914e165ede86d556339c8a820ba2aec568bb6f28
nstanger
authored
on 11 Dec 2003
Patch
Showing
1 changed file
format-master.xml
Ignore Space
Show notes
View
format-master.xml
<?xml version="1.0"?> <!-- This will mostly be a list of element names to match, along with the corresponding HTML and LaTeX handling XSLT code. --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <hyperlink> <element>OraAdmin</element> <url>http://info-nts-05.otago.ac.nz/docs/oracle9i/server.920/a96521/toc.htm</url> <label>test<!--<xsl:call-template name="OracleServer"/> Database Administrator<xsl:call-template name="apostrophe"/>s Guide--></label> </hyperlink> <template name="PaperCode" match="PaperCode"> <latex><xsl:text>{\PaperCode}</xsl:text></latex> <html>INFO 321</html> </template> <template name="OracleServer" match="OracleServer"> <latex><xsl:text>{\OracleServer}</xsl:text></latex> <html>Oracle9<I>i</I></html></template> <template name="paragraph" match="paragraph"> <latex><xsl:text> </xsl:text><xsl:apply-templates/><xsl:text> </xsl:text></latex> <!-- HTML is weird about what things you cannot include inside paragraphs (e.g. lists of any kind). However, the end P tag is optional, so one option might simply be not to output it. --> <html><P><xsl:apply-templates/></P></html> </template> <alias source="para" target="paragraph"/> <alias source="p" target="paragraph"/> <!-- Special characters (should maybe all be named, in case they need to be called explicitly with xsl:call-template) --> <!-- I'd like to use the Unicode names for these; will look them up some time! --> <template name="newline" match="newline"><latex> </latex><html><BR/></html></template> <template name="non-breaking-space" match="non-breaking-space"><latex>~</latex><html> </html></template> <alias source="nbsp" target="non-breaking-space"/> <template name="ellipsis-sign" match="ellipsis-sign"> <latex><xsl:text>{\ldots}</xsl:text></latex> <html><xsl:text>…</xsl:text></html></template> <alias source="etc" target="ellipsis-sign"/> <alias source="ellipsis" target="ellipsis-sign"/> <!-- Misc typographic symbols --> <template name="endash" match="endash"> <latex><xsl:text>--</xsl:text></latex> <html><xsl:text>–</xsl:text></html></template> <alias source="en-dash" target="endash"/> <template name="emdash" match="emdash"> <latex><xsl:text>---</xsl:text></latex> <html><xsl:text>—</xsl:text></html></template> <alias source="em-dash" target="emdash"/> <template name="apostrophe" match="apostrophe"> <latex><xsl:text>'</xsl:text></latex> <html><xsl:text>’</xsl:text></html></template> <template name="dollar" match="dollar"> <latex><xsl:text>\$</xsl:text></latex> <html><xsl:text>$</xsl:text></html></template> <template name="percent-sign" match="percent-sign"> <latex><xsl:text>\%</xsl:text></latex> <html><xsl:text>%</xsl:text></html></template> <template name="ampersand" match="ampersand"> <latex><xsl:text>\&</xsl:text></latex> <html><xsl:text>&</xsl:text></html></template> <template name="trademark-sign" match="trademark-sign"> <latex><xsl:text>(TM)</xsl:text></latex> <html><xsl:text>™</xsl:text></html></template> <alias source="trademark" target="trademark-sign"/> <template name="copyright-sign" match="copyright-sign"> <latex><xsl:text>\copyright</xsl:text></latex> <html><xsl:text>©</xsl:text></html></template> <!-- <alias source="copyright" target="copyright-sign"/> --> <template name="degree-sign" match="degree-sign"> <latex><xsl:text>deg</xsl:text></latex> <html><xsl:text>°</xsl:text></html></template> <template name="section-sign" match="section-sign"> <latex><xsl:text>{\S}</xsl:text></latex> <html><xsl:text>§</xsl:text></html></template> <template name="paragraph-sign" match="paragraph-sign"> <latex><xsl:text>{\P}</xsl:text></latex> <html><xsl:text>¶</xsl:text></html></template> <template name="pi" match="pi"> <latex><xsl:text>{\pi}</xsl:text></latex> <html><xsl:text>π</xsl:text></html></template> <template name="LaTeX" match="LaTeX"> <latex><xsl:text>{\latex}</xsl:text></latex> <html><xsl:text>LaTeX</xsl:text></html></template> <alias source="latex" target="LaTeX"/> <!-- Special styles --> <template name="emph" match="emph"><latex><xsl:text>\emph{</xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></latex><html><EM><xsl:apply-templates/></EM></html></template> <template name="italic" match="italic"><latex><xsl:text>\textit{</xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></latex><html><I><xsl:apply-templates/></I></html></template> <template name="quote" match="quote"><latex><xsl:text>``{</xsl:text><xsl:apply-templates/><xsl:text>}''</xsl:text></latex><html><xsl:text>“</xsl:text><xsl:apply-templates/><xsl:text>”</xsl:text></html></template> <template name="term" match="term"><latex>\term<xsl:apply-templates/>}</latex><html><I CLASS="term"><xsl:apply-templates/></I></html></template> <template name="foreign" match="foreign"><latex><xsl:text>\foreign{</xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></latex><html><I CLASS="foreign"><xsl:apply-templates/></I></html></template> <template name="code" match="code"> <latex><xsl:text>\code{</xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></latex> <html><CODE><xsl:apply-templates/></CODE></html> </template> <template name="code-block" match="code-block"> <latex> <xsl:text>\begin{verbatim}</xsl:text> <xsl:apply-templates/> <xsl:text>\end{verbatim}</xsl:text> </latex> <html> <PRE CLASS="code"><xsl:apply-templates/></PRE> </html> </template> <!-- Environments (in the LaTeX terminology): enumerated, ordered, and numbered lists. --> <!-- Unordered lists --> <template name="itemised-list" match="itemised-list"> <latex> \begin{itemize} <xsl:apply-templates/> \end{itemize} </latex> <html> <UL> <xsl:apply-templates/> </UL> </html> </template> <alias source="itemize" target="itemised-list"/> <alias source="unordered-list" target="itemised-list"/> <alias source="bulleted-list" target="itemised-list"/> <alias source="bullet-list" target="itemised-list"/> <alias source="bullet-points" target="itemised-list"/> <!-- Ordered lists --> <template name="enumerated-list" match="enumerated-list"> <latex><xsl:text> \begin{enumerate} <xsl:apply-templates/> \end{enumerate} </xsl:text></latex> <html> <OL> <xsl:apply-templates/> </OL> </html> </template> <alias source="enumerate" target="enumerated-list"/> <alias source="ordered-list" target="enumerated-list"/> <alias source="numbered-list" target="enumerated-list"/> <!-- List elements --> <template name="item" match="item"> <latex><xsl:text>\item </xsl:text><xsl:apply-templates/></latex> <html><LI><xsl:apply-templates/></LI></html> </template> <!-- Sections, subsections, subsubsections, ... --> <template name="section" match="section"> <latex> <xsl:apply-templates/> </latex> <html> <xsl:apply-templates/> </html> </template> <!-- Generate some number of "sub" so we can produce, e.g., "subsubsection" for LaTeX. Parameter: $depth Meaning: the number of repetitions (normally <= 2) --> <template name="generate-subs"> <latex> <xsl:param name="depth">0</xsl:param> <xsl:if test="$depth > 0"> <xsl:text>sub</xsl:text> <xsl:call-template select="generate-subs"> <xsl:with-param><xsl:value-of select="$depth - 1"/></xsl:with-param> </xsl:call-template> </xsl:if> </latex> </template> <template name="window-title" match="document/title" mode="window-title"> <html> <xsl:apply-templates/> </html> </template> <template name="document-title" match="document/title"> <!-- Need to do something sensible for LaTeX here. --> <!-- <latex><xsl:apply-templates/></latex> --> <html> <H1><xsl:apply-templates/></H1> </html> </template> <template name="section-title" match="section/title"> <latex> <xsl:text>\</xsl:text> <!-- Depth calculation for LaTeX hasn't been tested! --> <xsl:call-template name="generate-subs"> <xsl:with-param name="depth"> <xsl:number value="count(ancestor::section)"/> <xsl:if test="count(ancestor::section) > 2">2</xsl:if> </xsl:with-param> </xsl:call-template> <xsl:text>section</xsl:text> <xsl:apply-templates/><xsl:text>} </xsl:text></latex> <html> <xsl:variable name="depth"> <xsl:number value="1 + count(ancestor::section)"/> <xsl:if test="1 + count(ancestor::section) > 6">6</xsl:if> </xsl:variable> <xsl:text disable-output-escaping="yes"><H</xsl:text><xsl:number value="$depth"/><xsl:text disable-output-escaping="yes">></xsl:text> <xsl:number count="section" level="multiple" format="1.1.1.1.1.1"/> <xsl:text> </xsl:text> <xsl:apply-templates/> <xsl:text disable-output-escaping="yes"></H</xsl:text><xsl:number value="$depth"/><xsl:text disable-output-escaping="yes">></xsl:text> </html> </template> <!-- A quotation. --> <template name="quotation" match="quotation"> <latex>\begin{flushright}\itshape <xsl:apply-templates/>\end{flushright}</latex> <html> <P align="right"><I><xsl:apply-templates/></I></P> </html> </template> <!-- Anything inside an ID element is ignored completely. (More accurately, we pick bits out of it manually as required; it's only ignored by apply-templates.) --> <template name="id" match="id"/> </stylesheet>
<?xml version="1.0"?> <!-- This will mostly be a list of element names to match, along with the corresponding HTML and LaTeX handling XSLT code. --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <hyperlink> <element>OraAdmin</element> <url>http://info-nts-05.otago.ac.nz/docs/oracle9i/server.920/a96521/toc.htm</url> <label>test<!--<xsl:call-template name="OracleServer"/> Database Administrator<xsl:call-template name="apostrophe"/>s Guide--></label> </hyperlink> <template name="PaperCode" match="PaperCode"> <latex><xsl:text>{\PaperCode}</xsl:text></latex> <html>INFO 321</html> </template> <template name="OracleServer" match="OracleServer"> <latex><xsl:text>{\OracleServer}</xsl:text></latex> <html>Oracle9<I>i</I></html></template> <template name="paragraph" match="paragraph"> <latex><xsl:text> </xsl:text><xsl:apply-templates/><xsl:text> </xsl:text></latex> <!-- HTML is weird about what things you cannot include inside paragraphs (e.g. lists of any kind). However, the end P tag is optional, so one option might simply be not to output it. --> <html><P><xsl:apply-templates/></P></html> </template> <alias source="para" target="paragraph"/> <alias source="p" target="paragraph"/> <!-- Special characters (should maybe all be named, in case they need to be called explicitly with xsl:call-template) --> <!-- I'd like to use the Unicode names for these; will look them up some time! --> <template name="newline" match="newline"><latex> </latex><html><BR/></html></template> <template name="non-breaking-space" match="non-breaking-space"><latex>~</latex><html> </html></template> <alias source="nbsp" target="non-breaking-space"/> <template name="ellipsis-sign" match="ellipsis-sign"> <latex><xsl:text>{\ldots}</xsl:text></latex> <html><xsl:text>…</xsl:text></html></template> <alias source="etc" target="ellipsis-sign"/> <alias source="ellipsis" target="ellipsis-sign"/> <!-- Misc typographic symbols --> <template name="endash" match="endash"> <latex><xsl:text>--</xsl:text></latex> <html><xsl:text>–</xsl:text></html></template> <alias source="en-dash" target="endash"/> <template name="emdash" match="emdash"> <latex><xsl:text>---</xsl:text></latex> <html><xsl:text>—</xsl:text></html></template> <alias source="em-dash" target="emdash"/> <template name="apostrophe" match="apostrophe"> <latex><xsl:text>'</xsl:text></latex> <html><xsl:text>’</xsl:text></html></template> <template name="dollar" match="dollar"> <latex><xsl:text>\$</xsl:text></latex> <html><xsl:text>$</xsl:text></html></template> <template name="percent-sign" match="percent-sign"> <latex><xsl:text>\%</xsl:text></latex> <html><xsl:text>%</xsl:text></html></template> <template name="ampersand" match="ampersand"> <latex><xsl:text>\&</xsl:text></latex> <html><xsl:text>&</xsl:text></html></template> <template name="trademark-sign" match="trademark-sign"> <latex><xsl:text>(TM)</xsl:text></latex> <html><xsl:text>™</xsl:text></html></template> <alias source="trademark" target="trademark-sign"/> <template name="copyright-sign" match="copyright-sign"> <latex><xsl:text>\copyright</xsl:text></latex> <html><xsl:text>©</xsl:text></html></template> <!-- <alias source="copyright" target="copyright-sign"/> --> <template name="degree-sign" match="degree-sign"> <latex><xsl:text>deg</xsl:text></latex> <html><xsl:text>°</xsl:text></html></template> <template name="section-sign" match="section-sign"> <latex><xsl:text>{\S}</xsl:text></latex> <html><xsl:text>§</xsl:text></html></template> <template name="paragraph-sign" match="paragraph-sign"> <latex><xsl:text>{\P}</xsl:text></latex> <html><xsl:text>¶</xsl:text></html></template> <template name="pi" match="pi"> <latex><xsl:text>{\pi}</xsl:text></latex> <html><xsl:text>π</xsl:text></html></template> <template name="LaTeX" match="LaTeX"> <latex><xsl:text>{\latex}</xsl:text></latex> <html><xsl:text>LaTeX</xsl:text></html></template> <alias source="latex" target="LaTeX"/> <!-- Special styles --> <template name="emph" match="emph"><latex><xsl:text>\emph{</xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></latex><html><EM><xsl:apply-templates/></EM></html></template> <template name="italic" match="italic"><latex><xsl:text>\textit{</xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></latex><html><I><xsl:apply-templates/></I></html></template> <template name="quote" match="quote"><latex><xsl:text>``{</xsl:text><xsl:apply-templates/><xsl:text>}''</xsl:text></latex><html><xsl:text>“</xsl:text><xsl:apply-templates/><xsl:text>”</xsl:text></html></template> <template name="term" match="term"><latex>\term<xsl:apply-templates/>}</latex><html><I CLASS="term"><xsl:apply-templates/></I></html></template> <template name="foreign" match="foreign"><latex><xsl:text>\foreign{</xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></latex><html><I CLASS="foreign"><xsl:apply-templates/></I></html></template> <template name="code" match="code"> <latex><xsl:text>\code{</xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></latex> <html><CODE><xsl:apply-templates/></CODE></html> </template> <template name="code-block" match="code-block"> <latex> <xsl:text>\begin{verbatim}</xsl:text> <xsl:apply-templates/> <xsl:text>\end{verbatim}</xsl:text> </latex> <html> <PRE CLASS="code"><xsl:apply-templates/></PRE> </html> </template> <!-- Environments (in the LaTeX terminology): enumerated, ordered, and numbered lists. --> <!-- Unordered lists --> <template name="itemised-list" match="itemised-list"> <latex> \begin{itemize} <xsl:apply-templates/> \end{itemize} </latex> <html> <UL> <xsl:apply-templates/> </UL> </html> </template> <alias source="itemize" target="itemised-list"/> <alias source="unordered-list" target="itemised-list"/> <alias source="bulleted-list" target="itemised-list"/> <alias source="bullet-list" target="itemised-list"/> <alias source="bullet-points" target="itemised-list"/> <!-- Ordered lists --> <template name="enumerated-list" match="enumerated-list"> <latex><xsl:text> \begin{enumerate} <xsl:apply-templates/> \end{enumerate} </xsl:text></latex> <html> <OL> <xsl:apply-templates/> </OL> </html> </template> <alias source="enumerate" target="enumerated-list"/> <alias source="ordered-list" target="enumerated-list"/> <alias source="numbered-list" target="enumerated-list"/> <!-- List elements --> <template name="item" match="item"> <latex><xsl:text>\item </xsl:text><xsl:apply-templates/></latex> <html><LI><xsl:apply-templates/></LI></html> </template> <!-- Sections, subsections, subsubsections, ... --> <template name="section" match="section"> <latex> <xsl:text>\</xsl:text> <!-- Depth calculation for LaTeX hasn't been tested! --> <xsl:call-template name="generate-subs"> <xsl:with-param name="depth"> <xsl:number value="count(ancestor::section)"/> <xsl:if test="count(ancestor::section) > 2">2</xsl:if> </xsl:with-param> </xsl:call-template> <xsl:text>section</xsl:text> <xsl:apply-templates select="title"/><xsl:text>} </xsl:text><xsl:apply-templates select="section|paragraph|figure|itemised-list|enumerated-list"/></latex> <html> <xsl:variable name="depth"> <xsl:number value="1 + count(ancestor::section)"/> <xsl:if test="1 + count(ancestor::section) > 6">6</xsl:if> </xsl:variable> <xsl:text disable-output-escaping="yes"><H</xsl:text><xsl:number value="$depth"/><xsl:text disable-output-escaping="yes">></xsl:text> <xsl:apply-templates select="title"/> <xsl:text disable-output-escaping="yes"></H</xsl:text><xsl:number value="$depth"/><xsl:text disable-output-escaping="yes">></xsl:text> <xsl:apply-templates select="section|paragraph|figure|itemised-list|enumerated-list"/></html> </template> <template name="generate-subs"> <latex> <xsl:param name="depth">0</xsl:param> <xsl:if test="$depth > 0"> <xsl:text>sub</xsl:text> <xsl:call-template select="generate-subs"> <xsl:with-param><xsl:value-of select="$depth - 1"/></xsl:with-param> </xsl:call-template> </xsl:if> </latex> </template> <template name="title" match="title"> <latex><xsl:apply-templates/></latex> <html> <xsl:number count="section" level="multiple" format="1.1.1.1.1.1"/> <xsl:text> </xsl:text> <xsl:apply-templates/> </html> </template> <!-- A quotation. --> <template name="quotation" match="quotation"> <latex>\begin{flushright}\itshape <xsl:apply-templates/>\end{flushright}</latex> <html> <P align="right"><I><xsl:apply-templates/></I></P> </html> </template> </stylesheet>
Show line notes below