- Moved question and answer text processing to a separate module.
- Moved LaTeX logo into miscellaneous symbols module.
1 parent 32b2b85 commit 693d980f60a403111a252ce16f9d2929cc56a2a0
nstanger authored on 6 Oct 2011
Showing 3 changed files
View
145
format-master.xml
 
<!-- Relational algebra operators. -->
<include href="modules/relational-algebra.xml" />
 
<template name="LaTeX" match="LaTeX|latex">
<common formats="/latex/xelatex/">{\LaTeX}</common>
<common formats="/html/xhtml/">L<sup>A</sup>T<sub>E</sub>X</common>
</template>
 
<template name="LaTeX-strip" match="LaTeX|latex" mode="strip">
<common formats="/html/xhtml/">LaTeX</common>
</template>
 
<!-- In-text "menus", e.g., for displaying things like Windows Start Menu items. -->
<include href="modules/menus.xml" />
 
<!-- Basic text formatting (emphasis, bold, etc.). -->
 
<!-- Obsolete items (in order to provide informative error messages). -->
<include href="modules/obsolete.xml" />
 
<!--
Question text. This only exists so that we can ensure that appropriate
<p> tags are correctly inserted. If this template didn't exist, showing
the answers would generate invalid HTML. The answers are enclosed in a
<div class="answer">...</div>. Without this template, the answer markup
ends up embedded inside <p>...</p>, which is invalid.
-->
<template name="question" match="question">
<common formats="/latex/xelatex/"><xsl:apply-templates /></common>
<common formats="/html/xhtml/">
<xsl:choose>
<!--
Check whether there are actual paragraphs inside the
question. If so, let them worry about inserting the
<p> tags.
-->
<xsl:when test="count(paragraph|para|p|question|answer|code-block) != 0">
<xsl:apply-templates />
</xsl:when>
<!--
Otherwise, insert <p> tags surrounding the question content.
-->
<xsl:otherwise>
<p><xsl:apply-templates /></p>
</xsl:otherwise>
</xsl:choose>
</common>
</template>
 
<!--
Sample answers, which may optionally be excluded from the
output. This can be done globally for all answers by setting the
style sheet parameter $showanswers to "no", or it can be done
locally on a question-by-question basis by setting the @hide
attribute of the element to "yes".
@hide: If "yes", don't include this answer in the output stream.
The default is to include the answer.
-->
<template name="answer" match="answer">
<common formats="/latex/xelatex/">
<!--
It's nice to weed out the sample answer markup at the XSLT processing stage to make LaTeX run faster.
Note that \showanswers still needs to be called so that LaTeX can format chapter headings like "Answers for ..."
-->
<xsl:if test="$showanswers='yes'">
\begin{answer}
<xsl:apply-templates />
\end{answer}
 
</xsl:if>
</common>
<common formats="/html/xhtml/">
<xsl:if test="$showanswers='yes'">
<div class="answer">
<xsl:apply-templates />
</div>
</xsl:if>
</common>
</template>
<!--
Match hidden answers and do nothing.
-->
<template name="hidden-answer" match="answer[@hide='yes']" />
 
<!-- Text of questions and sample answers. -->
<include href="modules/q-and-a.xml" />
<!-- Footnotes. -->
<include href="modules/footnotes.xml" />
View
31
modules/miscellaneous-symbols.xml
<?xml version="1.0" encoding="utf-8"?>
 
<!--
Miscellaneous typographic symbols, including punctuation marks.
Miscellaneous typographic symbols, including punctuation marks and logos (e.g., for LaTeX).
Technically we don't need to disable output escaping for all of these, but it's probably better to code them all consistently, rather than trying to figure out which ones do need it (e.g., &#160; for a non-breaking space) and which ones don't (e.g., &amp;).
 
The "strip" mode forms of the templates are for use in the context of an HTML <title> element (so the mode is only relevant to the HTML formats). Embedding HTML markup inside the <title> element causes the markup to appear verbatim in the window title, i.e., <title><em>foo</em> bar</title> will appear in the window title as "<em>foo</em> bar", not "foo bar". Putting the stylesheet into strip mode means that it will only output text nodes unless otherwise specified for a particular element. Generally the "strip" templates will simply call-template to the original, unless the original contains markup that needs to be eliminated (e.g., see space below).
-->
 
<stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
 
<!-- Sharp/number symbol (#). -->
<template name="sharp-sign" match="sharp|hash|number-sign">
<common formats="/latex/xelatex/">{\#}</common>
<common formats="/html/xhtml/">
<xsl:call-template name="trademark-sign" />
</common>
</template>
 
<!-- The LaTeX logo. Technically this isn't a "symbol", but this is the most logical place to put it. -->
<template name="LaTeX" match="LaTeX|latex">
<common formats="/latex/xelatex/">{\LaTeX}</common>
<common formats="/html/xhtml/">L<sup>A</sup>T<sub>E</sub>X</common>
</template>
 
<template name="LaTeX-strip" match="LaTeX|latex" mode="strip">
<common formats="/html/xhtml/">LaTeX</common>
</template>
</stylesheet>
View
68
modules/q-and-a.xml 0 → 100755
<?xml version="1.0" encoding="utf-8"?>
 
<!--
Elements for generating question and sample answer text in the likes of tutorial and lab exercises.
-->
 
<stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
 
<!--
Question text. This only exists so that we can ensure that appropriate <p> tags are correctly inserted. If this template didn't exist, showing the answers would generate invalid HTML. The answers are enclosed in a <div class="answer">...</div>. Without this template, the answer markup ends up embedded inside <p>...</p>, which is invalid.
-->
<template name="question" match="question">
<common formats="/latex/xelatex/"><xsl:apply-templates /></common>
<common formats="/html/xhtml/">
<xsl:choose>
<!--
Check whether there are actual paragraphs inside the question. If so, let them worry about inserting the <p> tags.
-->
<xsl:when test="count(paragraph|para|p|question|answer|code-block) != 0">
<xsl:apply-templates />
</xsl:when>
<!-- Otherwise, insert <p> tags surrounding the question content. -->
<xsl:otherwise>
<p><xsl:apply-templates /></p>
</xsl:otherwise>
</xsl:choose>
</common>
</template>
 
<!--
Sample answers, which may optionally be excluded from the output. This can be done globally for all answers by setting the style sheet parameter $showanswers to "no", or it can be done locally on a question-by-question basis by setting the @hide attribute of the element to "yes".
@hide: If "yes", don't include this answer in the output stream. The default is to include the answer.
-->
<template name="answer" match="answer">
<common formats="/latex/xelatex/">
<!--
It's nice to weed out the sample answer markup at the XSLT processing stage to make LaTeX run faster. Note that \showanswers still needs to be called so that LaTeX can format chapter headings like "Answers for ..."
-->
<xsl:if test="$showanswers='yes'">
<xsl:text>\begin{answer}
</xsl:text>
<xsl:apply-templates />
<xsl:text>\end{answer}
 
</xsl:text>
</xsl:if>
</common>
<common formats="/html/xhtml/">
<xsl:if test="$showanswers='yes'">
<div class="answer">
<xsl:apply-templates />
</div>
</xsl:if>
</common>
</template>
<!--
Match hidden answers and do nothing.
-->
<template name="hidden-answer" match="answer[@hide='yes']" />
 
</stylesheet>