• Rewrote Oracle documentation and Blackboard elements to use the hyperlink template rather than hyperlink-internal.
• Removed no longer necessary inclusion of EXSLT namespace (closes #5).
• Removed obsolete hyperlink-internal and empty-hyperlink-url-internal templates.
• Refactored oracle-docs.perl:
    - Rewrote with better Perl idiom (hash instead of tab-delimited strings for configuration).
    - Removed deprecated and obsolete code.
1 parent c8e302b commit b5b8eddc2a5bb94eb541b14c7d1c990223d0a97f
Nigel Stanger authored on 12 Feb 2016
Showing 5 changed files
View
1
■■■■
extract_svg_layers.xsl
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape">
 
 
View
18
modules/global-elements.xml
A link to Blackboard.
-->
<template name="Blackboard" match="Blackboard">
<common>
<xsl:call-template name="hyperlink-internal">
<xsl:with-param name="url">https://blackboard.otago.ac.nz/</xsl:with-param>
<xsl:with-param name="label">Blackboard</xsl:with-param>
</xsl:call-template>
<xsl:variable name="BlackboardLink">
<xsl:element name="hyperlink">
<xsl:attribute name="url">
<xsl:text>https://blackboard.otago.ac.nz/</xsl:text>
</xsl:attribute>
<xsl:text>Blackboard</xsl:text>
</xsl:element>
</xsl:variable>
<xsl:apply-templates select="$BlackboardLink" />
</common>
</template>
 
<template name="Blackboard-strip" match="Blackboard" mode="strip">
View
36
modules/hyperlinks.xml
<!--
Sometimes the hyperlink content may be explicitly split across multiple lines, separated by <br> elements. This isn't a problem in (X)HTML, but it breaks (Xe)LaTeX, because you can't include a \\ inside most macros. The solution is to explicitly process the sub-elements, and wrap appropriate hyperref macros around them, /except/ for any embedded <br> elements. This does lead to some slightly
odd output when you embed markup in the hyperlink text; in particular, spaces won't be included in
the hyperlink.
We can't just call hyperlink-internal, because we still want to process the <br> elements.
-->
<xsl:for-each select="node()">
<xsl:if test="not( self::br )">
<xsl:text>\href{</xsl:text>
</xsl:otherwise>
</xsl:choose>
</common>
<common formats="/html/xhtml/">
<!-- We can't just call hyperlink-internal, because there may be an @target attribute. -->
<a href="{$fullURL}">
<xsl:if test="@target">
<xsl:attribute name="target">
<xsl:value-of select="@target" />
</common>
</template>
<!-- Internal parameterised hyperlink templates to be called by the likes of the empty Oracle documentation elements. -->
<template name="hyperlink-internal" match="hyperlink" mode="hyperlink-internal">
<common>
<xsl:param name="url" />
<xsl:param name="label" />
</common>
<common formats="/latex/xelatex/">
<xsl:text>\href{</xsl:text>
<xsl:value-of select="$url" />
<xsl:text>}{</xsl:text>
<xsl:apply-templates select="exsl:node-set($label)" />
<xsl:text>}</xsl:text>
</common>
<common formats="/html/xhtml/">
<a href="{$url}"><xsl:apply-templates select="exsl:node-set($label)" /></a>
</common>
</template>
 
<template name="empty-hyperlink-url-internal" match="hyperlink" mode="empty-hyperlink-internal">
<common>
<xsl:param name="url" />
</common>
<common formats="/latex/xelatex/">
<xsl:text>\url{</xsl:text>
<xsl:value-of select="$url" />
<xsl:text>}</xsl:text>
</common>
<common formats="/html/xhtml/">
<a href="{$url}"><code><xsl:value-of select="$url" /></code></a>
</common>
</template>
<!-- A plain URL (i.e., not necessarily a hyperlink). -->
<template name="url" match="url|uri|email|e-mail|email-address|e-mail-address">
<!--
\url in Hyperref will give us an active linke, so use \nolinkurl instead.
View
236
oracle-docs.perl
 
# Here's the raw data.
# Each entry has a name (marked up as XML), a unique, short, space-less code name for it, and the actual URL.
# It's probably sensible to have the full URL here, rather than prefixing the Oracle document root, because it's easier to copy the entire URL from the Web browser when updating.
@references =
%references =
(
# Name(0) Code(1) URL(2)
"Database Documentation Library Docs ${oracle_documentation_root}",
"Database Administrator<apostrophe />s Guide Admin ${oracle_documentation_root}server.111/b28310/toc.htm",
"Database 2 Day Developer<apostrophe />s Guide AppDev2Day ${oracle_documentation_root}appdev.111/b28843/toc.htm",
"Database Advanced Application Developer<apostrophe />s Guide AppDevAdv ${oracle_documentation_root}appdev.111/b28424/toc.htm",
"Object-Relational Developer<apostrophe />s Guide AppDevOR ${oracle_documentation_root}appdev.111/b28371/toc.htm",
"Database Concepts Concepts ${oracle_documentation_root}server.111/b28318/toc.htm",
"Database Data Warehousing Guide DataWarehousing ${oracle_documentation_root}server.111/b28313/toc.htm",
"Database Error Messages Errors ${oracle_documentation_root}server.111/b28278/toc.htm",
"Database SQL Language Reference SQL ${oracle_documentation_root}server.111/b28286/toc.htm",
"Database Java Developer<apostrophe />s Guide Java ${oracle_documentation_root}java.111/b31225/toc.htm",
"Database JDBC Developer<apostrophe />s Guide and Reference JDBC ${oracle_documentation_root}java.111/b31224/toc.htm",
"Database Master Glossary Glossary ${oracle_documentation_root}mix.111/b14388/toc.htm",
"Database Performance Tuning Guide Tuning ${oracle_documentation_root}server.111/b28274/toc.htm",
"Database PL/SQL Language Reference PLSQL ${oracle_documentation_root}appdev.111/b28370/toc.htm",
"Database PL/SQL Packages and Types Reference PLSQLPkgTyp ${oracle_documentation_root}appdev.111/b28419/toc.htm",
"Database Master Index Index ${oracle_documentation_root}mix.111/b14387/toc.htm",
"Database Reference Reference ${oracle_documentation_root}server.111/b28320/toc.htm"
Docs => { name => 'Database Documentation Library',
url => $oracle_documentation_root },
Admin => { name => 'Database Administrator<apostrophe />s Guide',
url => $oracle_documentation_root . 'server.111/b28310/toc.htm' },
AppDev2Day => { name => 'Database 2 Day Developer<apostrophe />s Guide',
url => $oracle_documentation_root . 'appdev.111/b28843/toc.htm' },
AppDevAdv => { name => 'Database Advanced Application Developer<apostrophe />s Guide',
url => $oracle_documentation_root . 'appdev.111/b28424/toc.htm' },
AppDevOR => { name => 'Object-Relational Developer<apostrophe />s Guide',
url => $oracle_documentation_root . 'appdev.111/b28371/toc.htm' },
Concepts => { name => 'Database Concepts',
url => $oracle_documentation_root . 'server.111/b28318/toc.htm' },
DataWarehousing => { name => 'Database Data Warehousing Guide',
url => $oracle_documentation_root . 'server.111/b28313/toc.htm' },
Errors => { name => 'Database Error Messages',
url => $oracle_documentation_root . 'server.111/b28278/toc.htm' },
SQL => { name => 'Database SQL Language Reference',
url => $oracle_documentation_root . 'server.111/b28286/toc.htm' },
Java => { name => 'Database Java Developer<apostrophe />s Guide',
url => $oracle_documentation_root . 'java.111/b31225/toc.htm' },
JDBC => { name => 'Database JDBC Developer<apostrophe />s Guide and Reference',
url => $oracle_documentation_root . 'java.111/b31224/toc.htm' },
Glossary => { name => 'Database Master Glossary',
url => $oracle_documentation_root . 'mix.111/b14388/toc.htm' },
Tuning => { name => 'Database Performance Tuning Guide',
url => $oracle_documentation_root . 'server.111/b28274/toc.htm' },
PLSQL => { name => 'Database PL/SQL Language Reference',
url => $oracle_documentation_root . 'appdev.111/b28370/toc.htm' },
PLSQLPkgTyp => { name => 'Database PL/SQL Packages and Types Reference',
url => $oracle_documentation_root . 'appdev.111/b28419/toc.htm' },
Index => { name => 'Database Master Index',
url => $oracle_documentation_root . 'mix.111/b14387/toc.htm' },
Reference => { name => 'Database Reference',
url => $oracle_documentation_root . 'server.111/b28320/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;
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 <<END_OF_HEADER
print <<END_OF_HEADER
<?xml version="1.0"?>
<!-- Do not edit! Automatically generated by oracle-docs.perl! -->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
;
}
 
# One-off hard-coded template for a link to the root of the documentation set, using the URL as the anchor text.
# This is used in several places in the INFO 212 course book and updating them is more of a pain than implementing this!
# This is used in several places in the course book and updating them is more of a pain than implementing this!
if ($output_type eq "xslt") {
print <<END_OF_TEMPLATE
<xsl:template name="OraDocsURL" match="OraDocsURL">
<xsl:call-template name="empty-hyperlink-url-internal">
<xsl:with-param name="url">${oracle_documentation_root}</xsl:with-param>
</xsl:call-template>
</xsl:template>
print <<END_OF_TEMPLATE
<xsl:template name="OraDocsURL" match="OraDocsURL">
<xsl:variable name="OracleURL">
<xsl:element name="hyperlink">
<xsl:attribute name="url">
<xsl:text>${oracle_documentation_root}</xsl:text>
</xsl:attribute>
</xsl:element>
</xsl:variable>
<xsl:apply-templates select="\$OracleURL" />
</xsl:template>
 
END_OF_TEMPLATE
;
# print "<xsl:template name=\"OraDocsURL\" match=\"OraDocsURL\"><xsl:apply-templates><xsl:element name=\"hyperlink\"><xsl:attribute name=\"url\">" . $oracle_documentation_root . "</xsl:attribute></xsl:element></xsl:apply-templates></xsl:template>\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;
}
}
foreach $doccode (keys %references) {
$docname = $references{$doccode}{'name'};
$docurl = $references{$doccode}{'url'};
if ($doccode =~ /$section_code/) {
# Print the requested stuff:
if ($output_type eq "xml") {
print generate_xml($doccode) . "\n";
} elsif ($output_type eq "xslt") {
print generate_xsl_template($docname, $doccode, $docurl) . "\n";
} elsif ($output_type eq "all") {
print generate_xsl_template($docname, $doccode, $docurl) . "\n";
} else {
warn "Sorry - I don't know anything about a \"$output_type\" format.\n";
exit;
}
}
}
 
if ($output_type eq "xslt") {
print "</xsl:stylesheet>\n";
print "</xsl: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.
# Generate an XSLT template for generating a hyperlink to the specified Oracle document.
# Arguments: (<descriptive-label>, <entry-code>, <url>)
sub generate_xsl_metatemplate {
return <<END_OF_TEMPLATE
<xsl:template name="${oracle_prefix}${_[1]}" match="${oracle_prefix}${_[1]}">
<xsl:call-template name="hyperlink-internal">
<xsl:with-param name="url">${_[2]}</xsl:with-param>
<xsl:with-param name="label">
<xsl:call-template name="OracleServer" /> ${_[0]}
</xsl:with-param>
</xsl:call-template>
</xsl:template>
sub generate_xsl_template {
return <<END_OF_TEMPLATE
<xsl:template name="${oracle_prefix}${_[1]}" match="${oracle_prefix}${_[1]}">
<xsl:variable name="OracleURL">
<xsl:element name="hyperlink">
<xsl:attribute name="url">
<xsl:text>${_[2]}</xsl:text>
</xsl:attribute>
<xsl:call-template name="OracleServer" />
<xsl:text> </xsl:text>
${_[0]}
</xsl:element>
</xsl:variable>
<xsl:apply-templates select="\$OracleURL" />
</xsl:template>
END_OF_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]. " />";
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>";
}
 
View
3
■■
xml2xslt.xsl
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsl-out="[irrelevant]"
xmlns:exsl="http://exslt.org/common"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:infosci="http://info-nts-12.otago.ac.nz/infosci">
 
<!--
 
<xsl:template match="/">
<xsl-out:stylesheet version="2.0" exclude-result-prefixes="exsl">
<xsl-out:stylesheet version="2.0">
<xsl-out:strip-space elements="*" />
 
<xsl-out:param name="subject-code"><xsl:text>INFO</xsl:text></xsl-out:param>