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
Updated references to info-nts-05 to info-nts-12.
master
OLD_GRAPHICS_HANDLING
1 parent
e162959
commit
61c80548d8d5882d8c27cf5ca51c47c95c21a6dd
cedwards
authored
on 17 Mar 2004
Patch
Showing
3 changed files
html_calendar.xsl
oracle-docs.perl
xml2xslt.xsl
Ignore Space
Show notes
View
html_calendar.xsl
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" encoding="ISO-8859-1" media-type="text/html" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/> <xsl:param name="standalone">yes</xsl:param> <xsl:strip-space elements="*"/> <xsl:variable name="rows-per-week"> <xsl:value-of select="/calendar/@rows-per-week"/> <xsl:if test="not(/calendar/@rows-per-week)">2</xsl:if> </xsl:variable> <xsl:variable name="number-of-weeks"> <xsl:value-of select="/calendar/@number-of-weeks"/> <xsl:if test="not(/calendar/@number-of-weeks)">13</xsl:if> </xsl:variable> <!-- This is the number of columns in the output table. --> <xsl:variable name="number-of-columns">11</xsl:variable> <xsl:template match="/"> <xsl:choose> <xsl:when test="$standalone = 'yes'"> <html> <head> <title> <xsl:apply-templates select="calendar/paper"/> <xsl:text> Course Calendar, </xsl:text> <xsl:apply-templates select="calendar/period"/> <xsl:text> </xsl:text> <xsl:apply-templates select="calendar/year"/> </title> <link rel="Stylesheet" href="http://info-nts-12.otago.ac.nz/info321/db_styles.css" type="text/css"/> </head> <body> <xsl:apply-templates/> </body> </html> </xsl:when> <xsl:otherwise> <xsl:apply-templates/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="calendar"> <!-- Page heading. --> <table border="0" cellspacing="0" cellpadding="4" width="99%"> <tr><td class="blue-bb-left"> <font face="arial,helvetica" size="3"><strong> <xsl:apply-templates select="paper"/> <xsl:text> Course Calendar, </xsl:text> <xsl:apply-templates select="period"/> <xsl:text> </xsl:text> <xsl:apply-templates select="year"/> </strong></font> </td></tr> <tr><td> <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> </td></tr> </table> <!-- The calendar itself. --> <center> <table border="1" summary="Course Calendar with relevant links" cellspacing="0"> <!-- I was going to generate COL elements here, but they don't seem to be supported by all browsers. Damn. The same applies for THEAD/TFOOT/TBODY, but I may as well leave them in for the browsers that do support them. --> <thead> <xsl:apply-templates select="header"/> </thead> <tfoot> <xsl:apply-templates select="footer"/> </tfoot> <tbody> <xsl:apply-templates select="body"/> </tbody> </table> </center> </xsl:template> <!-- Header/footer rows for the calendar table. To get proper table headings/footings, use HEADING/FOOTING. For other text, use NOTE. --> <xsl:template match="header|footer"> <tr> <xsl:apply-templates/> </tr> </xsl:template> <!-- A table heading or footing, coloured appropriately, bolded, centered, etc. --> <xsl:template match="heading|footing"> <th> <xsl:if test="@columns"> <xsl:attribute name="colspan"> <xsl:value-of select="@columns"/> </xsl:attribute> </xsl:if> <div class="small"><xsl:apply-templates/></div> </th> </xsl:template> <!-- A miscellaneous piece of text to be inserted somewhere in the calendar table. --> <xsl:template match="note"> <td> <xsl:if test="@columns"> <xsl:attribute name="colspan"> <xsl:value-of select="@columns"/> </xsl:attribute> </xsl:if> <xsl:apply-templates/> </td> </xsl:template> <!-- A week in the calendar. Each week has an associated number (automatically generated) and a date range, and spans some defined number of rows (default 2). The week number and date range are only generated for the first of these rows. --> <xsl:template match="week"> <xsl:for-each select="row"> <tr> <!-- Output the week number and dates columns. --> <xsl:if test="position() = 1"> <!-- Week number, first row only. --> <td class="white-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="$rows-per-week"/> </xsl:attribute> <div class="small"> <xsl:number value="1 + count(preceding::week[not(@holiday)])"/> </div> </td> <!-- Date range, first row only. --> <td class="white-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="$rows-per-week"/> </xsl:attribute> <div class="small"> <xsl:apply-templates select="../dates"/> </div> </td> </xsl:if> <!-- Apply each of the sub-templates in the correct order. Missing elements don't matter. --> <xsl:apply-templates select="section"/> <xsl:apply-templates select="lecture"/> <xsl:apply-templates select="reading"/> <xsl:apply-templates select="laboratory"/> <xsl:apply-templates select="tutorial"/> <xsl:apply-templates select="assessment"/> </tr> </xsl:for-each> </xsl:template> <!-- Weeks that are holidays have no week number or date range, just a text description. --> <xsl:template match="week[@holiday]"> <tr> <td class="blue-ou-center"> <xsl:attribute name="colspan"> <xsl:value-of select="$number-of-columns"/> </xsl:attribute> <strong class="large"><em><xsl:apply-templates/></em></strong> </td> </tr> </xsl:template> <!-- Output the date range for a week. We need a separate template because it's likely to have embedded ENDASH elements. --> <xsl:template match="dates"> <div class="small"><xsl:apply-templates/></div> </xsl:template> <!-- Output a calendar entry for a lecture. Note that lectures are always assumed to span a single row. Lectures are automatically numbered. --> <xsl:template match="lecture[node() and not(@holiday)]"> <td class="ltgrey-center"> <div class="small"> <xsl:number value="1 + count(preceding::lecture[node()])"/> </div> </td> <td class="ltgrey-left" rowspan="1"> <div class="small"><xsl:apply-templates/></div> </td> </xsl:template> <!-- Output a calendar entry for a lecture that occurs on a holiday. These aren't numbered. --> <xsl:template match="lecture[@holiday]"> <td class="blue-ou-center" colspan="2"> <strong class="small"><em><xsl:apply-templates/></em></strong> </td> </xsl:template> <!-- Output an empty lecture cell. --> <xsl:template match="lecture[not(node())]"> <td class="medgrey-center" colspan="2"> <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> </td> </xsl:template> <!-- Output a calendar entry for a laboratory. Laboratories are automatically numbered. --> <xsl:template match="laboratory[node()]"> <xsl:variable name="num-rows"> <xsl:value-of select="@rows"/> <xsl:if test="not(@rows)"> <xsl:value-of select="$rows-per-week"/> </xsl:if> </xsl:variable> <td class="ltblue-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="$num-rows"/> </xsl:attribute> <div class="small"> <xsl:number value="1 + count(preceding::laboratory[node()])"/> </div> </td> <td class="ltblue-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="$num-rows"/> </xsl:attribute> <div class="small"><xsl:apply-templates/></div> </td> </xsl:template> <!-- Output an empty laboratory cell. --> <xsl:template match="laboratory[not(node())]"> <td class="medgrey-center" colspan="2"> <xsl:attribute name="rowspan"> <xsl:value-of select="@rows"/> <xsl:if test="not(@rows)"> <xsl:value-of select="$rows-per-week"/> </xsl:if> </xsl:attribute> <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> </td> </xsl:template> <!-- Output a calendar entry for a tutorial. Tutorials are automatically numbered. --> <xsl:template match="tutorial[node()]"> <xsl:variable name="num-rows"> <xsl:value-of select="@rows"/> <xsl:if test="not(@rows)"> <xsl:value-of select="$rows-per-week"/> </xsl:if> </xsl:variable> <td class="medgreen-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="$num-rows"/> </xsl:attribute> <div class="small"> <xsl:number value="1 + count(preceding::tutorial[node()])"/> </div> </td> <td class="medgreen-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="$num-rows"/> </xsl:attribute> <div class="small"><xsl:apply-templates/></div> </td> </xsl:template> <!-- Output an empty tutorial cell. --> <xsl:template match="tutorial[not(node())]"> <td class="medgrey-center" colspan="2"> <xsl:attribute name="rowspan"> <xsl:value-of select="@rows"/> <xsl:if test="not(@rows)"> <xsl:value-of select="$rows-per-week"/> </xsl:if> </xsl:attribute> <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> </td> </xsl:template> <!-- Output a calendar entry for a section or reading (both use the same formatting). --> <xsl:template match="section[node()]|reading[node()]"> <td class="white-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="@rows"/> <xsl:if test="not(@rows)"> <xsl:value-of select="$rows-per-week"/> </xsl:if> </xsl:attribute> <div class="small"><xsl:apply-templates/></div> </td> </xsl:template> <!-- Output an empty section or reading cell. --> <xsl:template match="section[not(node())]|reading[not(node())]"> <td class="medgrey-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="@rows"/> <xsl:if test="not(@rows)"> <xsl:value-of select="$rows-per-week"/> </xsl:if> </xsl:attribute> <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> </td> </xsl:template> <!-- Output a calendar entry for an assessment. --> <xsl:template match="assessment[node()]"> <td class="blue-bb-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="@rows"/> <xsl:if test="not(@rows)"> <xsl:value-of select="$rows-per-week"/> </xsl:if> </xsl:attribute> <div class="small"><xsl:apply-templates/></div> </td> </xsl:template> <!-- Output an empty assessment cell. --> <xsl:template match="assessment[not(node())]"> <td class="medgrey-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="@rows"/> <xsl:if test="not(@rows)"> <xsl:value-of select="$rows-per-week"/> </xsl:if> </xsl:attribute> <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> </td> </xsl:template> <!-- Generate a link. --> <xsl:template match="link"> <a> <xsl:attribute name="href"> <xsl:value-of select="@href"/> </xsl:attribute> <xsl:apply-templates/> </a> </xsl:template> <!-- Wrap quotes around a string. If the attribute SINGLE is set to "yes", use single quotes instead of double. Use numeric entity references because not all browsers support “, ”, ‘ and ’. --> <xsl:template match="quote"> <xsl:choose> <xsl:when test="@single = 'yes'"> <xsl:text disable-output-escaping="yes">&#8216;</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text disable-output-escaping="yes">&#8220;</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:apply-templates/> <xsl:choose> <xsl:when test="@single = 'yes'"> <xsl:text disable-output-escaping="yes">&#8217;</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text disable-output-escaping="yes">&#8221;</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- Output an ampersand entity (&). --> <xsl:template match="ampersand"> <xsl:text disable-output-escaping="yes">&amp;</xsl:text> </xsl:template> <!-- Output an en-dash entity (– because not all browsers support –). --> <xsl:template match="endash"> <xsl:text disable-output-escaping="yes">&#8211;</xsl:text> </xsl:template> <!-- Output a section symbol entity (§ because not all browsers support §). --> <xsl:template match="sect"> <xsl:text disable-output-escaping="yes">&#167;</xsl:text> </xsl:template> <!-- Output a hash character. --> <xsl:template match="hash"> <xsl:text>#</xsl:text> </xsl:template> <!-- Miscellaneous HTML elements to be mapped straight through. --> <xsl:template match="strong"> <strong><xsl:apply-templates/></strong> </xsl:template> <xsl:template match="em"> <em><xsl:apply-templates/></em> </xsl:template> <xsl:template match="b"> <b><xsl:apply-templates/></b> </xsl:template> <xsl:template match="i"> <i><xsl:apply-templates/></i> </xsl:template> <xsl:template match="br"> <br/> </xsl:template> </xsl:stylesheet>
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" encoding="ISO-8859-1" media-type="text/html" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/> <xsl:param name="standalone">yes</xsl:param> <xsl:strip-space elements="*"/> <xsl:variable name="rows-per-week"> <xsl:value-of select="/calendar/@rows-per-week"/> <xsl:if test="not(/calendar/@rows-per-week)">2</xsl:if> </xsl:variable> <xsl:variable name="number-of-weeks"> <xsl:value-of select="/calendar/@number-of-weeks"/> <xsl:if test="not(/calendar/@number-of-weeks)">13</xsl:if> </xsl:variable> <!-- This is the number of columns in the output table. --> <xsl:variable name="number-of-columns">11</xsl:variable> <xsl:template match="/"> <xsl:choose> <xsl:when test="$standalone = 'yes'"> <html> <head> <title> <xsl:apply-templates select="calendar/paper"/> <xsl:text> Course Calendar, </xsl:text> <xsl:apply-templates select="calendar/period"/> <xsl:text> </xsl:text> <xsl:apply-templates select="calendar/year"/> </title> <link rel="Stylesheet" href="http://info-nts-05.otago.ac.nz/info321/db_styles.css" type="text/css"/> </head> <body> <xsl:apply-templates/> </body> </html> </xsl:when> <xsl:otherwise> <xsl:apply-templates/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="calendar"> <!-- Page heading. --> <table border="0" cellspacing="0" cellpadding="4" width="99%"> <tr><td class="blue-bb-left"> <font face="arial,helvetica" size="3"><strong> <xsl:apply-templates select="paper"/> <xsl:text> Course Calendar, </xsl:text> <xsl:apply-templates select="period"/> <xsl:text> </xsl:text> <xsl:apply-templates select="year"/> </strong></font> </td></tr> <tr><td> <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> </td></tr> </table> <!-- The calendar itself. --> <center> <table border="1" summary="Course Calendar with relevant links" cellspacing="0"> <!-- I was going to generate COL elements here, but they don't seem to be supported by all browsers. Damn. The same applies for THEAD/TFOOT/TBODY, but I may as well leave them in for the browsers that do support them. --> <thead> <xsl:apply-templates select="header"/> </thead> <tfoot> <xsl:apply-templates select="footer"/> </tfoot> <tbody> <xsl:apply-templates select="body"/> </tbody> </table> </center> </xsl:template> <!-- Header/footer rows for the calendar table. To get proper table headings/footings, use HEADING/FOOTING. For other text, use NOTE. --> <xsl:template match="header|footer"> <tr> <xsl:apply-templates/> </tr> </xsl:template> <!-- A table heading or footing, coloured appropriately, bolded, centered, etc. --> <xsl:template match="heading|footing"> <th> <xsl:if test="@columns"> <xsl:attribute name="colspan"> <xsl:value-of select="@columns"/> </xsl:attribute> </xsl:if> <div class="small"><xsl:apply-templates/></div> </th> </xsl:template> <!-- A miscellaneous piece of text to be inserted somewhere in the calendar table. --> <xsl:template match="note"> <td> <xsl:if test="@columns"> <xsl:attribute name="colspan"> <xsl:value-of select="@columns"/> </xsl:attribute> </xsl:if> <xsl:apply-templates/> </td> </xsl:template> <!-- A week in the calendar. Each week has an associated number (automatically generated) and a date range, and spans some defined number of rows (default 2). The week number and date range are only generated for the first of these rows. --> <xsl:template match="week"> <xsl:for-each select="row"> <tr> <!-- Output the week number and dates columns. --> <xsl:if test="position() = 1"> <!-- Week number, first row only. --> <td class="white-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="$rows-per-week"/> </xsl:attribute> <div class="small"> <xsl:number value="1 + count(preceding::week[not(@holiday)])"/> </div> </td> <!-- Date range, first row only. --> <td class="white-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="$rows-per-week"/> </xsl:attribute> <div class="small"> <xsl:apply-templates select="../dates"/> </div> </td> </xsl:if> <!-- Apply each of the sub-templates in the correct order. Missing elements don't matter. --> <xsl:apply-templates select="section"/> <xsl:apply-templates select="lecture"/> <xsl:apply-templates select="reading"/> <xsl:apply-templates select="laboratory"/> <xsl:apply-templates select="tutorial"/> <xsl:apply-templates select="assessment"/> </tr> </xsl:for-each> </xsl:template> <!-- Weeks that are holidays have no week number or date range, just a text description. --> <xsl:template match="week[@holiday]"> <tr> <td class="blue-ou-center"> <xsl:attribute name="colspan"> <xsl:value-of select="$number-of-columns"/> </xsl:attribute> <strong class="large"><em><xsl:apply-templates/></em></strong> </td> </tr> </xsl:template> <!-- Output the date range for a week. We need a separate template because it's likely to have embedded ENDASH elements. --> <xsl:template match="dates"> <div class="small"><xsl:apply-templates/></div> </xsl:template> <!-- Output a calendar entry for a lecture. Note that lectures are always assumed to span a single row. Lectures are automatically numbered. --> <xsl:template match="lecture[node() and not(@holiday)]"> <td class="ltgrey-center"> <div class="small"> <xsl:number value="1 + count(preceding::lecture[node()])"/> </div> </td> <td class="ltgrey-left" rowspan="1"> <div class="small"><xsl:apply-templates/></div> </td> </xsl:template> <!-- Output a calendar entry for a lecture that occurs on a holiday. These aren't numbered. --> <xsl:template match="lecture[@holiday]"> <td class="blue-ou-center" colspan="2"> <strong class="small"><em><xsl:apply-templates/></em></strong> </td> </xsl:template> <!-- Output an empty lecture cell. --> <xsl:template match="lecture[not(node())]"> <td class="medgrey-center" colspan="2"> <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> </td> </xsl:template> <!-- Output a calendar entry for a laboratory. Laboratories are automatically numbered. --> <xsl:template match="laboratory[node()]"> <xsl:variable name="num-rows"> <xsl:value-of select="@rows"/> <xsl:if test="not(@rows)"> <xsl:value-of select="$rows-per-week"/> </xsl:if> </xsl:variable> <td class="ltblue-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="$num-rows"/> </xsl:attribute> <div class="small"> <xsl:number value="1 + count(preceding::laboratory[node()])"/> </div> </td> <td class="ltblue-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="$num-rows"/> </xsl:attribute> <div class="small"><xsl:apply-templates/></div> </td> </xsl:template> <!-- Output an empty laboratory cell. --> <xsl:template match="laboratory[not(node())]"> <td class="medgrey-center" colspan="2"> <xsl:attribute name="rowspan"> <xsl:value-of select="@rows"/> <xsl:if test="not(@rows)"> <xsl:value-of select="$rows-per-week"/> </xsl:if> </xsl:attribute> <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> </td> </xsl:template> <!-- Output a calendar entry for a tutorial. Tutorials are automatically numbered. --> <xsl:template match="tutorial[node()]"> <xsl:variable name="num-rows"> <xsl:value-of select="@rows"/> <xsl:if test="not(@rows)"> <xsl:value-of select="$rows-per-week"/> </xsl:if> </xsl:variable> <td class="medgreen-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="$num-rows"/> </xsl:attribute> <div class="small"> <xsl:number value="1 + count(preceding::tutorial[node()])"/> </div> </td> <td class="medgreen-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="$num-rows"/> </xsl:attribute> <div class="small"><xsl:apply-templates/></div> </td> </xsl:template> <!-- Output an empty tutorial cell. --> <xsl:template match="tutorial[not(node())]"> <td class="medgrey-center" colspan="2"> <xsl:attribute name="rowspan"> <xsl:value-of select="@rows"/> <xsl:if test="not(@rows)"> <xsl:value-of select="$rows-per-week"/> </xsl:if> </xsl:attribute> <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> </td> </xsl:template> <!-- Output a calendar entry for a section or reading (both use the same formatting). --> <xsl:template match="section[node()]|reading[node()]"> <td class="white-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="@rows"/> <xsl:if test="not(@rows)"> <xsl:value-of select="$rows-per-week"/> </xsl:if> </xsl:attribute> <div class="small"><xsl:apply-templates/></div> </td> </xsl:template> <!-- Output an empty section or reading cell. --> <xsl:template match="section[not(node())]|reading[not(node())]"> <td class="medgrey-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="@rows"/> <xsl:if test="not(@rows)"> <xsl:value-of select="$rows-per-week"/> </xsl:if> </xsl:attribute> <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> </td> </xsl:template> <!-- Output a calendar entry for an assessment. --> <xsl:template match="assessment[node()]"> <td class="blue-bb-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="@rows"/> <xsl:if test="not(@rows)"> <xsl:value-of select="$rows-per-week"/> </xsl:if> </xsl:attribute> <div class="small"><xsl:apply-templates/></div> </td> </xsl:template> <!-- Output an empty assessment cell. --> <xsl:template match="assessment[not(node())]"> <td class="medgrey-center"> <xsl:attribute name="rowspan"> <xsl:value-of select="@rows"/> <xsl:if test="not(@rows)"> <xsl:value-of select="$rows-per-week"/> </xsl:if> </xsl:attribute> <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> </td> </xsl:template> <!-- Generate a link. --> <xsl:template match="link"> <a> <xsl:attribute name="href"> <xsl:value-of select="@href"/> </xsl:attribute> <xsl:apply-templates/> </a> </xsl:template> <!-- Wrap quotes around a string. If the attribute SINGLE is set to "yes", use single quotes instead of double. Use numeric entity references because not all browsers support “, ”, ‘ and ’. --> <xsl:template match="quote"> <xsl:choose> <xsl:when test="@single = 'yes'"> <xsl:text disable-output-escaping="yes">&#8216;</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text disable-output-escaping="yes">&#8220;</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:apply-templates/> <xsl:choose> <xsl:when test="@single = 'yes'"> <xsl:text disable-output-escaping="yes">&#8217;</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text disable-output-escaping="yes">&#8221;</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- Output an ampersand entity (&). --> <xsl:template match="ampersand"> <xsl:text disable-output-escaping="yes">&amp;</xsl:text> </xsl:template> <!-- Output an en-dash entity (– because not all browsers support –). --> <xsl:template match="endash"> <xsl:text disable-output-escaping="yes">&#8211;</xsl:text> </xsl:template> <!-- Output a section symbol entity (§ because not all browsers support §). --> <xsl:template match="sect"> <xsl:text disable-output-escaping="yes">&#167;</xsl:text> </xsl:template> <!-- Output a hash character. --> <xsl:template match="hash"> <xsl:text>#</xsl:text> </xsl:template> <!-- Miscellaneous HTML elements to be mapped straight through. --> <xsl:template match="strong"> <strong><xsl:apply-templates/></strong> </xsl:template> <xsl:template match="em"> <em><xsl:apply-templates/></em> </xsl:template> <xsl:template match="b"> <b><xsl:apply-templates/></b> </xsl:template> <xsl:template match="i"> <i><xsl:apply-templates/></i> </xsl:template> <xsl:template match="br"> <br/> </xsl:template> </xsl:stylesheet>
Ignore Space
Show notes
View
oracle-docs.perl
#!/usr/bin/perl # # $Id$ # # Basic script for generating XML markup for the major sections of the Oracle Documentation, and XSLT templates (and meta-templates, for both output formats) for transforming it. # # To do: # * Maybe modify the script to work for any URL-based hyperlinks (e.g. <Blackboard/>, <OtagoUniversity/>). This would mean ditching the automatic "Ora" prefix, but wouldn't require much else to implement. # Here's the raw data (this used to be in an Excel spreadsheet, which now obviously shouldn't be used any more - might remove from CVS some time). # Each entry has a name (marked up as XML), a unique, short, space-less code name for it, and the actual URL. @references = ( # Name(0) Code(1) URL(2) "Database Administrator<apostrophe/>s Guide Admin http://info-nts-12.otago.ac.nz/docs/oracle9i/server.920/a96521/toc.htm", "Application Developer<apostrophe/>s Guide<emdash/>Object-Relational Features AppDevOR http://info-nts-12.otago.ac.nz/docs/oracle9i/appdev.920/a96594/toc.htm", "Database Concepts Concepts http://info-nts-12.otago.ac.nz/docs/oracle9i/server.920/a96524/toc.htm", "Data Warehousing DataWarehousing http://info-nts-12.otago.ac.nz/docs/oracle9i/server.920/a96520/toc.htm", "Database Error Messages Errors http://info-nts-12.otago.ac.nz/docs/oracle9i/server.920/a96525/toc.htm", "SQL Reference SQL http://info-nts-12.otago.ac.nz/docs/oracle9i/server.920/a96540/toc.htm", "Java Developer<apostrophe/>s Guide Java http://info-nts-12.otago.ac.nz/docs/oracle9i/java.920/a96656/toc.htm", "JDBC Developer<apostrophe/>s Guide and Reference JDBC http://info-nts-12.otago.ac.nz/docs/oracle9i/java.920/a96654/toc.htm", "Database Master Glossary Glossary http://info-nts-12.otago.ac.nz/docs/oracle9i/mix.920/a97290/toc.htm", "Database Performance Tuning Guide and Reference Tuning http://info-nts-12.otago.ac.nz/docs/oracle9i/server.920/a96533/toc.htm", "PL/SQL User<apostrophe/>s Guide and Reference PLSQL http://info-nts-12.otago.ac.nz/docs/oracle9i/appdev.920/a96624/toc.htm", "Database Master Index Index http://info-nts-12.otago.ac.nz/docs/oracle9i/mix.920/a96625/toc.htm", "Database Reference Reference http://info-nts-12.otago.ac.nz/docs/oracle9i/server.920/a96536/toc.htm" ); # Prefix to use in the generated template names: $oracle_prefix = "Ora"; if ($#ARGV != 1) { warn "usage: oracle-docs <section-code-regexp> (xml | xslt | xslt_html | xslt_latex | link | all)\n"; exit; } $section_code = $ARGV[0]; $output_type = $ARGV[1]; if ($output_type eq "xslt") { print "<?xml version=\"1.0\"?>\n" . "<!-- Do not edit! Automatically generated by oracle-docs.perl! -->\n" . "<stylesheet version=\"1.0\" xmlns:xsl-out=\"http://www.w3.org/1999/XSL/Transform\">\n"; } foreach $current_record (@references) { @fields = split(/[ ]+/, $current_record); # Only print the entries for the matching section: if (@fields[1] =~ /$section_code/) { # Print the requested stuff: if ($output_type eq "link") { print generate_doc_netlink(@fields[0], @fields[2]) . "\n"; } elsif ($output_type eq "xml") { print generate_xml(@fields[1]) . "\n"; } elsif ($output_type eq "xslt") { print generate_xsl_metatemplate(@fields[0], @fields[1], @fields[2]) . "\n"; } elsif ($output_type eq "xslt_html") { print generate_xsl_template_for_html(@fields[0], @fields[1], @fields[2]) . "\n"; } elsif ($output_type eq "xslt_latex") { print generate_xsl_template_for_latex(@fields[0], @fields[1], @fields[2]) . "\n"; } elsif ($output_type eq "all") { print generate_doc_netlink(@fields[0], @fields[2]) . "\n"; print generate_xsl_metatemplate(@fields[0], @fields[1], @fields[2]) . "\n"; print generate_xsl_template_for_html(@fields[0], @fields[1], @fields[2]) . "\n"; print generate_xsl_template_for_latex(@fields[0], @fields[1], @fields[2]) . "\n"; } else { warn "Sorry - I don't know anything about a \"$output_type\" format.\n"; exit; } } } if ($output_type eq "xslt") { print "</stylesheet>\n"; } # what we really need to produce is a template that calls the hyperlink template when matched. I think. # Markup for a hyperlink (as defined in format-master.xml) looks like this: # # <hyperlink url="http://wherever/">Some Web Site</hyperlink> # # However, this will only match elements with a url attribute; we therefore need a new internal hyperlink that's parameterised. Should be modal (but "call-templates" doesn't seem to like it when you give it a "mode" attribute). # The derived xml2html.xsl and xml2latex.xsl files will need to call this hyperlink-internal template directly: # # <xsl:call-template name="hyperlink-internal" mode="hyperlink-internal"> # <xsl:with-param name="url">http://wherever/</xsl:with-param> # <xsl:with-param name="label">Some Web Site</xsl:with-param> # </xsl:call-template> # Generate an XSLT meta-template for generating either an HTML or a LaTeX producing template. # Arguments: (<descriptive-label>, <entry-code>, <url>) sub generate_xsl_metatemplate { return "<xsl-out:template name=\"" . $oracle_prefix . $_[1] . "\" match=\"" . $oracle_prefix . $_[1] . "\">" . "<xsl-out:call-template name=\"hyperlink-internal\">" . # mode=\"hyperlink-internal\">" . "<xsl-out:with-param name=\"url\">" . $_[2] . "</xsl-out:with-param>" . "<xsl-out:with-param name=\"label\">" . "<xsl-out:call-template name=\"OracleServer\"/>" . " " . $_[0] . "</xsl-out:with-param>" . "</xsl-out:call-template>" . "</xsl-out:template>"; # Nope, wrong tree here: return "<xsl:template name=\"" . $oracle_prefix . $_[1] . "\" match=\"" . $oracle_prefix . $_[1] . "\">" . "<latex>" . "\\href{" . $_[2] . "}" . "{" . "<xsl:call-template name=\"OracleServer\"/>" . " " . $_[0] . "}" . "</latex>" . "<html>" . "<a href=\"" . $_[2]. "\">" . "<xsl:call-template name=\"OracleServer\"/>" . " " . $_[0] . "</a>" . "</html>" . "</xsl:template>"; } # Produce the actual XML markup to be used in authoring (just to provide a handy list of them all): # Arguments: (<entry-code>) sub generate_xml { return "<" . $oracle_prefix . $_[0]. "/>"; } # Produce XML markup for a link to a section of the documentation (deprecated): sub generate_doc_netlink { return "<netlink><label>" . $_[0] . "</label><target>" . $_[1] . "</target></netlink>"; } # Generate an XSLT template for HTML output (deprecated): sub generate_xsl_template_for_html { return "<xsl:template match=\"" . $_[0] . "\"><A><xsl:attribute name=\"HREF\">" . $_[1] . "</xsl:attribute>" . "<xsl:call-template name=\"OracleServer\"/> " . $_[2] . "</A></xsl:template>"; } # Generate an XSLT template for LaTeX output (deprecated): sub generate_xsl_template_for_latex { return "<xsl:template match=\"" . $_[0] . "\">\\href{" . $_[1] . "}{<xsl:call-template name=\"OracleServer\"/> " . $_[2] . "}</xsl:template>"; }
#!/usr/bin/perl # # $Id$ # # Basic script for generating XML markup for the major sections of the Oracle Documentation, and XSLT templates (and meta-templates, for both output formats) for transforming it. # # To do: # * Maybe modify the script to work for any URL-based hyperlinks (e.g. <Blackboard/>, <OtagoUniversity/>). This would mean ditching the automatic "Ora" prefix, but wouldn't require much else to implement. # Here's the raw data (this used to be in an Excel spreadsheet, which now obviously shouldn't be used any more - might remove from CVS some time). # Each entry has a name (marked up as XML), a unique, short, space-less code name for it, and the actual URL. @references = ( # Name(0) Code(1) URL(2) "Database Administrator<apostrophe/>s Guide Admin http://info-nts-05.otago.ac.nz/docs/oracle9i/server.920/a96521/toc.htm", "Application Developer<apostrophe/>s Guide<emdash/>Object-Relational Features AppDevOR http://info-nts-05.otago.ac.nz/docs/oracle9i/appdev.920/a96594/toc.htm", "Database Concepts Concepts http://info-nts-05.otago.ac.nz/docs/oracle9i/server.920/a96524/toc.htm", "Data Warehousing DataWarehousing http://info-nts-05.otago.ac.nz/docs/oracle9i/server.920/a96520/toc.htm", "Database Error Messages Errors http://info-nts-05.otago.ac.nz/docs/oracle9i/server.920/a96525/toc.htm", "SQL Reference SQL http://info-nts-05.otago.ac.nz/docs/oracle9i/server.920/a96540/toc.htm", "Java Developer<apostrophe/>s Guide Java http://info-nts-05.otago.ac.nz/docs/oracle9i/java.920/a96656/toc.htm", "JDBC Developer<apostrophe/>s Guide and Reference JDBC http://info-nts-05.otago.ac.nz/docs/oracle9i/java.920/a96654/toc.htm", "Database Master Glossary Glossary http://info-nts-05.otago.ac.nz/docs/oracle9i/mix.920/a97290/toc.htm", "Database Performance Tuning Guide and Reference Tuning http://info-nts-05.otago.ac.nz/docs/oracle9i/server.920/a96533/toc.htm", "PL/SQL User<apostrophe/>s Guide and Reference PLSQL http://info-nts-05.otago.ac.nz/docs/oracle9i/appdev.920/a96624/toc.htm", "Database Master Index Index http://info-nts-05.otago.ac.nz/docs/oracle9i/mix.920/a96625/toc.htm", "Database Reference Reference http://info-nts-05.otago.ac.nz/docs/oracle9i/server.920/a96536/toc.htm" ); # Prefix to use in the generated template names: $oracle_prefix = "Ora"; if ($#ARGV != 1) { warn "usage: oracle-docs <section-code-regexp> (xml | xslt | xslt_html | xslt_latex | link | all)\n"; exit; } $section_code = $ARGV[0]; $output_type = $ARGV[1]; if ($output_type eq "xslt") { print "<?xml version=\"1.0\"?>\n" . "<!-- Do not edit! Automatically generated by oracle-docs.perl! -->\n" . "<stylesheet version=\"1.0\" xmlns:xsl-out=\"http://www.w3.org/1999/XSL/Transform\">\n"; } foreach $current_record (@references) { @fields = split(/[ ]+/, $current_record); # Only print the entries for the matching section: if (@fields[1] =~ /$section_code/) { # Print the requested stuff: if ($output_type eq "link") { print generate_doc_netlink(@fields[0], @fields[2]) . "\n"; } elsif ($output_type eq "xml") { print generate_xml(@fields[1]) . "\n"; } elsif ($output_type eq "xslt") { print generate_xsl_metatemplate(@fields[0], @fields[1], @fields[2]) . "\n"; } elsif ($output_type eq "xslt_html") { print generate_xsl_template_for_html(@fields[0], @fields[1], @fields[2]) . "\n"; } elsif ($output_type eq "xslt_latex") { print generate_xsl_template_for_latex(@fields[0], @fields[1], @fields[2]) . "\n"; } elsif ($output_type eq "all") { print generate_doc_netlink(@fields[0], @fields[2]) . "\n"; print generate_xsl_metatemplate(@fields[0], @fields[1], @fields[2]) . "\n"; print generate_xsl_template_for_html(@fields[0], @fields[1], @fields[2]) . "\n"; print generate_xsl_template_for_latex(@fields[0], @fields[1], @fields[2]) . "\n"; } else { warn "Sorry - I don't know anything about a \"$output_type\" format.\n"; exit; } } } if ($output_type eq "xslt") { print "</stylesheet>\n"; } # what we really need to produce is a template that calls the hyperlink template when matched. I think. # Markup for a hyperlink (as defined in format-master.xml) looks like this: # # <hyperlink url="http://wherever/">Some Web Site</hyperlink> # # However, this will only match elements with a url attribute; we therefore need a new internal hyperlink that's parameterised. Should be modal (but "call-templates" doesn't seem to like it when you give it a "mode" attribute). # The derived xml2html.xsl and xml2latex.xsl files will need to call this hyperlink-internal template directly: # # <xsl:call-template name="hyperlink-internal" mode="hyperlink-internal"> # <xsl:with-param name="url">http://wherever/</xsl:with-param> # <xsl:with-param name="label">Some Web Site</xsl:with-param> # </xsl:call-template> # Generate an XSLT meta-template for generating either an HTML or a LaTeX producing template. # Arguments: (<descriptive-label>, <entry-code>, <url>) sub generate_xsl_metatemplate { return "<xsl-out:template name=\"" . $oracle_prefix . $_[1] . "\" match=\"" . $oracle_prefix . $_[1] . "\">" . "<xsl-out:call-template name=\"hyperlink-internal\">" . # mode=\"hyperlink-internal\">" . "<xsl-out:with-param name=\"url\">" . $_[2] . "</xsl-out:with-param>" . "<xsl-out:with-param name=\"label\">" . "<xsl-out:call-template name=\"OracleServer\"/>" . " " . $_[0] . "</xsl-out:with-param>" . "</xsl-out:call-template>" . "</xsl-out:template>"; # Nope, wrong tree here: return "<xsl:template name=\"" . $oracle_prefix . $_[1] . "\" match=\"" . $oracle_prefix . $_[1] . "\">" . "<latex>" . "\\href{" . $_[2] . "}" . "{" . "<xsl:call-template name=\"OracleServer\"/>" . " " . $_[0] . "}" . "</latex>" . "<html>" . "<a href=\"" . $_[2]. "\">" . "<xsl:call-template name=\"OracleServer\"/>" . " " . $_[0] . "</a>" . "</html>" . "</xsl:template>"; } # Produce the actual XML markup to be used in authoring (just to provide a handy list of them all): # Arguments: (<entry-code>) sub generate_xml { return "<" . $oracle_prefix . $_[0]. "/>"; } # Produce XML markup for a link to a section of the documentation (deprecated): sub generate_doc_netlink { return "<netlink><label>" . $_[0] . "</label><target>" . $_[1] . "</target></netlink>"; } # Generate an XSLT template for HTML output (deprecated): sub generate_xsl_template_for_html { return "<xsl:template match=\"" . $_[0] . "\"><A><xsl:attribute name=\"HREF\">" . $_[1] . "</xsl:attribute>" . "<xsl:call-template name=\"OracleServer\"/> " . $_[2] . "</A></xsl:template>"; } # Generate an XSLT template for LaTeX output (deprecated): sub generate_xsl_template_for_latex { return "<xsl:template match=\"" . $_[0] . "\">\\href{" . $_[1] . "}{<xsl:call-template name=\"OracleServer\"/> " . $_[2] . "}</xsl:template>"; }
Ignore Space
Show notes
View
xml2xslt.xsl
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsl-out="[irrelevant]" xmlns:exsl="http://exslt.org/common" > <!-- OK, this is my first bash at an XSLT transformation for a master XML document defining how to transform elements in the course handbook source into HTML and LaTeX. Hmm, meta-stylesheet?! --> <!-- <xsl:output method="text" encoding="ISO-8859-1" media-type="text/xml"/> --> <xsl:output method="xml" encoding="ISO-8859-1" cdata-section-elements="html"/> <!-- Produce HTML or LaTeX output? --> <!-- <xsl:param name="format" select="'html'"/> --> <xsl:param name="format">html</xsl:param> <!-- Define an alias for the xsl namespace to avoid confusion when generating xsl: elements in the output of this stylesheet. --> <xsl:namespace-alias stylesheet-prefix="xsl-out" result-prefix="xsl"/> <xsl:variable name="newline"> <xsl:text> </xsl:text> </xsl:variable> <xsl:variable name="space"><xsl:text> </xsl:text></xsl:variable> <xsl:template match="/"> <xsl-out:stylesheet version="1.0"> <xsl-out:strip-space elements="*"/> <!-- Would it be more accurate to call this 'subject' rather than 'department'? --> <xsl-out:param name="department">INFO</xsl-out:param> <xsl-out:param name="paper"/> <xsl-out:param name="subject-code">INFO</xsl-out:param> <xsl-out:param name="paper-number"/> <xsl-out:param name="showanswers" select="'no'"/> <!-- copy in the generated Oracle documentation code --> <xsl:copy-of select="document('oracle-docs.xsl')/stylesheet/*"/> <!-- <xsl:include href="oracle-docs.xsl" /> --> <!-- root-level documents should say what type/class of document they are (lecture, tutorial, generic, ...). Do we want to call this a class or a type? --> <!-- <xsl:variable name="doctype"><xsl:value-of select="/document/@type"/></xsl:variable> --> <xsl:choose> <xsl:when test="$format='html'"> <!-- *** HTML Output *** --> <!-- Old version: before using xsl:namespace-alias: --> <!-- <xsl-out:element name="xsl:output"> <xsl-out:attribute name="method">html</xsl-out:attribute> <xsl-out:attribute name="encoding">ISO-8859-1</xsl-out:attribute> <xsl-out:attribute name="media-type">text/html</xsl-out:attribute> <xsl-out:attribute name="doctype-public">-//W3C//DTD HTML 4.01 Transitional//EN</xsl-out:attribute> </xsl-out:element> --> <!-- New, simplified version: --> <xsl-out:output method="html" encoding="ISO-8859-1" media-type="text/html" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/> <!-- Nope, includes can only appear as a child of xsl:stylesheet. --> <!-- <xsl-out:include href="xml2html-root.xsl"/> --> <xsl-out:template match="/document"> <xsl-out:comment> THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! </xsl-out:comment> <HTML> <HEAD> <LINK REL="Stylesheet" HREF="http://info-nts-12.otago.ac.nz/info321/styles.css" TYPE="text/css"/> <TITLE> <xsl-out:apply-templates select="title" mode="preamble"/> </TITLE> </HEAD> <BODY> <xsl-out:apply-templates/> <!-- How best to approach this - certain elements that need special handling (e.g. title, author) shouldn't be passed through here as well. --> <!-- How about we just match certain elements that we know can be handled safely, e.g. sections, paragraphs, ...? (...and their aliases?) --> <!-- Are introductions just another section, or should there be an introduction element? --> <!-- The solution is to get cleverer with our templates, e.g., multiple templates for <title> that have different match patterns (document/title, section/title). --> <!-- We also need to define an empty template for the <document-metadata> element so that its contents get ignored. --> <!-- Once these are done, we can just go apply-templates and forget about it. --> <HR/> <!-- Since HTML doesn't support footnotes as such, we instead include them as endnotes at the end of the document. --> <xsl-out:if test="count(//footnote) > 0"> <H3>Notes</H3> <xsl-out:apply-templates select="//footnote" mode="list"/> <HR/> </xsl-out:if> <ADDRESS> <xsl-out:apply-templates select="copyright"/> <xsl-out:apply-templates select="/document/@cvs-id"/> </ADDRESS> </BODY> </HTML> </xsl-out:template> </xsl:when> <xsl:when test="$format='latex'"> <!-- <xsl-out:output method="text" encoding="UTF-8" media-type="text/plain"/> --> <xsl-out:output method="text" encoding="ISO-8859-1" media-type="text/plain"/> <!-- Set to pdf if using PDFLaTeX, otherwise eps. --> <xsl-out:param name="image-format">pdf</xsl-out:param> <!-- Set to no if you want this to be included inside another document. --> <xsl-out:param name="standalone">yes</xsl-out:param> <!-- *** LaTeX Source Output *** --> <!-- Should this produce a LaTeX source fragment or an entire valid source document? --> <xsl-out:template match="/document"> <xsl-out:choose> <!-- Could perhaps deal with loading LaTeX packages using a <latex-package> element? --> <xsl-out:when test="$standalone = 'yes'"> % THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! \documentclass[12pt,a4paper]{article} \usepackage[margin=1in]{geometry} \usepackage{mathpple} \usepackage{multirow} \usepackage{graphicx} <xsl-out:apply-templates select="document('environment.xml')/environment/latex-packages"/> \usepackage[pdftex]{hyperref} <xsl-out:apply-templates select="document('environment.xml')/environment/latex-commands"/> <xsl-out:apply-templates select="title" mode="preamble"/> <xsl-out:apply-templates select="author" mode="preamble"/> <xsl-out:apply-templates select="date" mode="preamble"/> \begin{document} \maketitle <xsl-out:apply-templates/> \vfill {\scriptsize \hfill \verb+<xsl-out:apply-templates select="/document/@cvs-id"/>+} \end{document} </xsl-out:when> <!-- Not standalone: --> <!-- Hmm, maybe this should go in format-master.xml... --> <xsl-out:when test="/document/@class = 'tutorial'"> \tutorial{<xsl-out:apply-templates select="/document/title" mode="chapter"/>} <!-- <xsl-out:apply-templates select="/tutorial/introduction"/> <xsl-out:for-each select="/tutorial/section"> --> <xsl-out:apply-templates select="*[not(self::title)]"/> <!-- </xsl-out:for-each> --> \vfill {\scriptsize \hfill \verb+<xsl-out:value-of select="/document/@cvs-id"/>+} </xsl-out:when> <xsl-out:when test="/document/@class = 'laboratory'"> \lab{<xsl-out:apply-templates select="/document/title" mode="chapter"/>} <!-- <xsl-out:apply-templates select="/laboratory/introduction"/> <xsl-out:for-each select="/tutorial/section"> --> <xsl-out:apply-templates select="*[not(self::title)]"/> <!-- </xsl-out:for-each> --> \vfill {\scriptsize \hfill \verb+<xsl-out:value-of select="/document/@cvs-id"/>+} </xsl-out:when> <xsl-out:otherwise> <!-- maybe we should assume that we're in a book documentclass and issue a \chapter here? --> \chapter{<xsl-out:apply-templates select="/document/title" mode="chapter"/>} </xsl-out:otherwise> </xsl-out:choose> </xsl-out:template> <!-- <xsl-out:element name="xsl:output"> <xsl-out:attribute name="method">text</xsl-out:attribute> <xsl-out:attribute name="encoding">ISO-8859-1</xsl-out:attribute> <xsl-out:attribute name="media-type">text/plain</xsl-out:attribute> </xsl-out:element> --> </xsl:when> <xsl:otherwise> <xsl:message terminate="yes"> <xsl:text>Sorry, unknown format: </xsl:text><xsl:value-of select="$format"/> </xsl:message> </xsl:otherwise> </xsl:choose> <xsl:apply-templates/> </xsl-out:stylesheet> </xsl:template> <!-- General-purpose template-producing template. --> <!--<xsl:template match="template"><![CDATA[<xsl-out:template name="]]><xsl-out:value-of select="name"/><![CDATA[" match="]]><xsl-out:value-of select="match"/><![CDATA[">]]><xsl-out:copy-of select="*[local-name(.)=$format]"/><![CDATA[</xsl-out:template>]]></xsl-out:template>--> <xsl:template match="template"> <xsl-out:template> <!-- Much easier to just copy all attributes across verbatim rather --> <!-- than copying specific named attributes, because we might want to use --> <!-- attributes that weren't originally anticipated. --> <!-- Might this be a problem in future? --> <xsl:copy-of select="@*"/> <!-- <xsl:if test="@name"> --> <!-- <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute> --> <!-- </xsl:if> --> <!-- <xsl:if test="@match"> --> <!-- <xsl:attribute name="match"><xsl:value-of select="@match"/></xsl:attribute> --> <!-- </xsl:if> --> <!-- Copy across code that is common to all formats. --> <xsl:copy-of select="common/node()"/> <!-- Copy across code that is specific to the current format. --> <xsl:copy-of select="*[name(.)=$format]/node()"/> <!-- <xsl:copy-of select="node()"/> --> <!-- <xsl:if test="$format='latex'"> <xsl:copy-of select="latex/*"/> </xsl:if> <xsl:if test="$format='html'"> <xsl:copy-of select="html/*"/> </xsl:if> --> </xsl-out:template> </xsl:template> <!-- This template produces a template that calls another template, i.e. it implements a template alias. --> <!-- The generated template probably doesn't need a name, but we'll put one in anyway. --> <xsl:template match="alias"> <xsl-out:template> <xsl:attribute name="name"><xsl:value-of select="@source"/></xsl:attribute> <xsl:attribute name="match"><xsl:value-of select="@source"/></xsl:attribute> <xsl-out:call-template> <xsl:attribute name="name"><xsl:value-of select="@target"/></xsl:attribute> </xsl-out:call-template> </xsl-out:template> </xsl:template> <!-- This template produces a template for processing style-oriented markup, such as empahsis, foreign terms, and quotations. --> <!-- <xsl:template match="d"> </xsl-out:template match> --> <!-- This template produces a template for processing an element that refers to a hyperlink. --> <xsl:template match="hyperlink"> </xsl:template> </xsl:stylesheet>
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsl-out="[irrelevant]" xmlns:exsl="http://exslt.org/common" > <!-- OK, this is my first bash at an XSLT transformation for a master XML document defining how to transform elements in the course handbook source into HTML and LaTeX. Hmm, meta-stylesheet?! --> <!-- <xsl:output method="text" encoding="ISO-8859-1" media-type="text/xml"/> --> <xsl:output method="xml" encoding="ISO-8859-1" cdata-section-elements="html"/> <!-- Produce HTML or LaTeX output? --> <!-- <xsl:param name="format" select="'html'"/> --> <xsl:param name="format">html</xsl:param> <!-- Define an alias for the xsl namespace to avoid confusion when generating xsl: elements in the output of this stylesheet. --> <xsl:namespace-alias stylesheet-prefix="xsl-out" result-prefix="xsl"/> <xsl:variable name="newline"> <xsl:text> </xsl:text> </xsl:variable> <xsl:variable name="space"><xsl:text> </xsl:text></xsl:variable> <xsl:template match="/"> <xsl-out:stylesheet version="1.0"> <xsl-out:strip-space elements="*"/> <!-- Would it be more accurate to call this 'subject' rather than 'department'? --> <xsl-out:param name="department">INFO</xsl-out:param> <xsl-out:param name="paper"/> <xsl-out:param name="subject-code">INFO</xsl-out:param> <xsl-out:param name="paper-number"/> <xsl-out:param name="showanswers" select="'no'"/> <!-- copy in the generated Oracle documentation code --> <xsl:copy-of select="document('oracle-docs.xsl')/stylesheet/*"/> <!-- <xsl:include href="oracle-docs.xsl" /> --> <!-- root-level documents should say what type/class of document they are (lecture, tutorial, generic, ...). Do we want to call this a class or a type? --> <!-- <xsl:variable name="doctype"><xsl:value-of select="/document/@type"/></xsl:variable> --> <xsl:choose> <xsl:when test="$format='html'"> <!-- *** HTML Output *** --> <!-- Old version: before using xsl:namespace-alias: --> <!-- <xsl-out:element name="xsl:output"> <xsl-out:attribute name="method">html</xsl-out:attribute> <xsl-out:attribute name="encoding">ISO-8859-1</xsl-out:attribute> <xsl-out:attribute name="media-type">text/html</xsl-out:attribute> <xsl-out:attribute name="doctype-public">-//W3C//DTD HTML 4.01 Transitional//EN</xsl-out:attribute> </xsl-out:element> --> <!-- New, simplified version: --> <xsl-out:output method="html" encoding="ISO-8859-1" media-type="text/html" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/> <!-- Nope, includes can only appear as a child of xsl:stylesheet. --> <!-- <xsl-out:include href="xml2html-root.xsl"/> --> <xsl-out:template match="/document"> <xsl-out:comment> THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! </xsl-out:comment> <HTML> <HEAD> <LINK REL="Stylesheet" HREF="http://info-nts-05.otago.ac.nz/info321/styles.css" TYPE="text/css"/> <TITLE> <xsl-out:apply-templates select="title" mode="preamble"/> </TITLE> </HEAD> <BODY> <xsl-out:apply-templates/> <!-- How best to approach this - certain elements that need special handling (e.g. title, author) shouldn't be passed through here as well. --> <!-- How about we just match certain elements that we know can be handled safely, e.g. sections, paragraphs, ...? (...and their aliases?) --> <!-- Are introductions just another section, or should there be an introduction element? --> <!-- The solution is to get cleverer with our templates, e.g., multiple templates for <title> that have different match patterns (document/title, section/title). --> <!-- We also need to define an empty template for the <document-metadata> element so that its contents get ignored. --> <!-- Once these are done, we can just go apply-templates and forget about it. --> <HR/> <!-- Since HTML doesn't support footnotes as such, we instead include them as endnotes at the end of the document. --> <xsl-out:if test="count(//footnote) > 0"> <H3>Notes</H3> <xsl-out:apply-templates select="//footnote" mode="list"/> <HR/> </xsl-out:if> <ADDRESS> <xsl-out:apply-templates select="copyright"/> <xsl-out:apply-templates select="/document/@cvs-id"/> </ADDRESS> </BODY> </HTML> </xsl-out:template> </xsl:when> <xsl:when test="$format='latex'"> <!-- <xsl-out:output method="text" encoding="UTF-8" media-type="text/plain"/> --> <xsl-out:output method="text" encoding="ISO-8859-1" media-type="text/plain"/> <!-- Set to pdf if using PDFLaTeX, otherwise eps. --> <xsl-out:param name="image-format">pdf</xsl-out:param> <!-- Set to no if you want this to be included inside another document. --> <xsl-out:param name="standalone">yes</xsl-out:param> <!-- *** LaTeX Source Output *** --> <!-- Should this produce a LaTeX source fragment or an entire valid source document? --> <xsl-out:template match="/document"> <xsl-out:choose> <!-- Could perhaps deal with loading LaTeX packages using a <latex-package> element? --> <xsl-out:when test="$standalone = 'yes'"> % THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! \documentclass[12pt,a4paper]{article} \usepackage[margin=1in]{geometry} \usepackage{mathpple} \usepackage{multirow} \usepackage{graphicx} <xsl-out:apply-templates select="document('environment.xml')/environment/latex-packages"/> \usepackage[pdftex]{hyperref} <xsl-out:apply-templates select="document('environment.xml')/environment/latex-commands"/> <xsl-out:apply-templates select="title" mode="preamble"/> <xsl-out:apply-templates select="author" mode="preamble"/> <xsl-out:apply-templates select="date" mode="preamble"/> \begin{document} \maketitle <xsl-out:apply-templates/> \vfill {\scriptsize \hfill \verb+<xsl-out:apply-templates select="/document/@cvs-id"/>+} \end{document} </xsl-out:when> <!-- Not standalone: --> <!-- Hmm, maybe this should go in format-master.xml... --> <xsl-out:when test="/document/@class = 'tutorial'"> \tutorial{<xsl-out:apply-templates select="/document/title" mode="chapter"/>} <!-- <xsl-out:apply-templates select="/tutorial/introduction"/> <xsl-out:for-each select="/tutorial/section"> --> <xsl-out:apply-templates select="*[not(self::title)]"/> <!-- </xsl-out:for-each> --> \vfill {\scriptsize \hfill \verb+<xsl-out:value-of select="/document/@cvs-id"/>+} </xsl-out:when> <xsl-out:when test="/document/@class = 'laboratory'"> \lab{<xsl-out:apply-templates select="/document/title" mode="chapter"/>} <!-- <xsl-out:apply-templates select="/laboratory/introduction"/> <xsl-out:for-each select="/tutorial/section"> --> <xsl-out:apply-templates select="*[not(self::title)]"/> <!-- </xsl-out:for-each> --> \vfill {\scriptsize \hfill \verb+<xsl-out:value-of select="/document/@cvs-id"/>+} </xsl-out:when> <xsl-out:otherwise> <!-- maybe we should assume that we're in a book documentclass and issue a \chapter here? --> \chapter{<xsl-out:apply-templates select="/document/title" mode="chapter"/>} </xsl-out:otherwise> </xsl-out:choose> </xsl-out:template> <!-- <xsl-out:element name="xsl:output"> <xsl-out:attribute name="method">text</xsl-out:attribute> <xsl-out:attribute name="encoding">ISO-8859-1</xsl-out:attribute> <xsl-out:attribute name="media-type">text/plain</xsl-out:attribute> </xsl-out:element> --> </xsl:when> <xsl:otherwise> <xsl:message terminate="yes"> <xsl:text>Sorry, unknown format: </xsl:text><xsl:value-of select="$format"/> </xsl:message> </xsl:otherwise> </xsl:choose> <xsl:apply-templates/> </xsl-out:stylesheet> </xsl:template> <!-- General-purpose template-producing template. --> <!--<xsl:template match="template"><![CDATA[<xsl-out:template name="]]><xsl-out:value-of select="name"/><![CDATA[" match="]]><xsl-out:value-of select="match"/><![CDATA[">]]><xsl-out:copy-of select="*[local-name(.)=$format]"/><![CDATA[</xsl-out:template>]]></xsl-out:template>--> <xsl:template match="template"> <xsl-out:template> <!-- Much easier to just copy all attributes across verbatim rather --> <!-- than copying specific named attributes, because we might want to use --> <!-- attributes that weren't originally anticipated. --> <!-- Might this be a problem in future? --> <xsl:copy-of select="@*"/> <!-- <xsl:if test="@name"> --> <!-- <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute> --> <!-- </xsl:if> --> <!-- <xsl:if test="@match"> --> <!-- <xsl:attribute name="match"><xsl:value-of select="@match"/></xsl:attribute> --> <!-- </xsl:if> --> <!-- Copy across code that is common to all formats. --> <xsl:copy-of select="common/node()"/> <!-- Copy across code that is specific to the current format. --> <xsl:copy-of select="*[name(.)=$format]/node()"/> <!-- <xsl:copy-of select="node()"/> --> <!-- <xsl:if test="$format='latex'"> <xsl:copy-of select="latex/*"/> </xsl:if> <xsl:if test="$format='html'"> <xsl:copy-of select="html/*"/> </xsl:if> --> </xsl-out:template> </xsl:template> <!-- This template produces a template that calls another template, i.e. it implements a template alias. --> <!-- The generated template probably doesn't need a name, but we'll put one in anyway. --> <xsl:template match="alias"> <xsl-out:template> <xsl:attribute name="name"><xsl:value-of select="@source"/></xsl:attribute> <xsl:attribute name="match"><xsl:value-of select="@source"/></xsl:attribute> <xsl-out:call-template> <xsl:attribute name="name"><xsl:value-of select="@target"/></xsl:attribute> </xsl-out:call-template> </xsl-out:template> </xsl:template> <!-- This template produces a template for processing style-oriented markup, such as empahsis, foreign terms, and quotations. --> <!-- <xsl:template match="d"> </xsl-out:template match> --> <!-- This template produces a template for processing an element that refers to a hyperlink. --> <xsl:template match="hyperlink"> </xsl:template> </xsl:stylesheet>
Show line notes below