- Added a module to generate errors for obsolete element/attribute usages that
might still be in use.
- Moved all deprecated and obsolete items into new "obsolete" module.
- Removed processing code for obsolete child elements of "image".
1 parent 8ae6897 commit a462b1569acb5e30215fee75d02f56f0701c6005
nstanger authored on 27 Sep 2011
Showing 3 changed files
View
34
format-master.xml
 
<!-- Lists (itemised, enumerated, definition). -->
<include href="modules/lists.xml" />
 
<!-- 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
</common>
</template>
<!--
Anything inside a <metadata> is ignored completely. (More
accurately, we pick bits out of it manually as required; it's
only ignored by apply-templates.)
 
If we move to using attributes of "document" for all metadata, this will become redundant.
-->
<template name="metadata" match="metadata">
<common>
<xsl:message><xsl:text>Use of metadata element obsolete!</xsl:text></xsl:message>
</common>
</template>
<!--
Anything inside an <omit> is also ignored completely.
-->
<template name="omit" match="omit" />
 
<!--
...and the legacy id tags inside figures.
-->
<template match="figure/id" />
<template match="figure/label" />
 
<!--
Comments are not quite ignored completely, as they're carried through to the output document (kind of: "It is an error if instantiating the content of xsl:comment creates nodes other than text nodes.")
-->
Include another XML/HTML/LaTeX document into the current one. If
you don't specify @type, it assumes the type of document that
you're currently generating (HTML or LaTeX).
LaTeX documents are simply included using \input{...}. The old
<latex-input> element is now deprecated.
LaTeX documents are simply included using \input{...}.
 
HTML documents are a little trickier, as there's no equivalent
of \input{} in HTML, plus the XSLT processor always seems to
generate a DOCTYPE when producing HTML, whether you want it or
<template name="raw-html" match="raw-code[@format = 'html']|raw-html">
<common formats="/html/xhtml/"><xsl:copy-of select="*" /></common>
</template>
<!-- Generate a LaTeX \input{} macro. -->
<template name="latex-input" match="latex-input">
<common formats="/latex/xelatex/">
<xsl:message>Use of latex-input is deprecated. Please use include-document instead.</xsl:message>
\input{<xsl:value-of select="." />}
</common>
</template>
 
<!--
Conditional processing depending on the format. It may appear redundant to have two templates, but this is the only way to ensure that the LaTeX template is empty in the HTML style sheet, and vice versa.
Note the assumption that all LaTeX format names include the string 'latex' and all HTML format names include the string 'html'.
View
41
modules/images.xml
-->
<template name="latex-image" match="image" mode="latex">
<common formats="/latex/xelatex/">
<xsl:text>\includegraphics</xsl:text>
<xsl:if test="count(latex-scaling) != 0">
<xsl:message terminate="no">&lt;latex-scaling&gt; element is deprecated in &lt;image&gt;; please use latex-options attribute instead.</xsl:message>
<xsl:text>[scale=</xsl:text>
<xsl:value-of select="latex-scaling" />
<xsl:text>]</xsl:text>
</xsl:if>
<!--
Adding general-purpose latex pass-through arguments for \includegraphics; this should eventually subsume the "scale"-only handler above. If providing multiple arguments, these should be comma-separated in the source XML, but do not need the enclosing square brackets.
General-purpose latex pass-through arguments for \includegraphics. If providing multiple arguments, these should be comma-separated in the source XML, but do not need the enclosing square brackets.
-->
<xsl:if test="@latex-options">
<xsl:text>[</xsl:text>
<xsl:value-of select="@latex-options" />
<xsl:value-of select="@location" />
<xsl:text>/</xsl:text>
</xsl:if>
 
<!-- need to phase out "basename" as an element and switch to using an attribute -->
<xsl:if test="count(basename) != 0">
<xsl:message terminate="no">&lt;basename&gt; element is deprecated in &lt;image&gt;; please use basename attribute instead.</xsl:message>
<xsl:value-of select="basename" />
</xsl:if>
<xsl:if test="@basename">
<xsl:value-of select="@basename" />
</xsl:if>
<xsl:text>-print.</xsl:text>
<!-- Figure out the image format. -->
<xsl:choose>
<xsl:when test="count(format) != 0">
<xsl:message terminate="no">&lt;format&gt; element is deprecated in &lt;image&gt;; please use format attribute instead.</xsl:message>
<xsl:value-of select="format" />
</xsl:when>
<xsl:when test="@format">
<xsl:value-of select="@format" />
</xsl:when>
<xsl:otherwise>
TODO: if no description is given, use the basename as the content of the ALT element.
TODO: can we refactor some of this into a function or something?
-->
<template name="normal-image" match="image[count(provide-large-version) = 0]">
<common>
<!--
Check for obsolete child elements. We need to do this explicitly, as there isn't an apply-templates inside this template to pick them up automatically.
-->
<xsl:apply-templates select="basename|format|latex-scaling" />
</common>
<common formats="/latex/xelatex/"><xsl:apply-templates select="." mode="latex" /></common>
<common formats="/html/xhtml/">
<img class="padded" style="border-style: none;">
<xsl:attribute name="src">
<xsl:text>-web.</xsl:text>
 
<xsl:choose>
<!-- CME: oops, I'd originally used the "format" tag to identify the format used in the LaTeX version, not the HTML! -->
<xsl:when test="count(format) != 0">
<xsl:message terminate="no">&lt;format&gt; element is deprecated in &lt;image&gt;; please use format attribute instead.</xsl:message>
<xsl:value-of select="format" />
</xsl:when>
<xsl:when test="@format">
<xsl:value-of select="@format" />
</xsl:when>
<xsl:otherwise>
TODO: if no description is given, use the basename as the content of the ALT element.
TODO: can we refactor some of this into a function or something?
-->
<template name="zoomable-image" match="image[count(provide-large-version) != 0]">
<common>
<!--
Check for obsolete child elements. We need to do this explicitly, as there isn't an apply-templates inside this template to pick them up automatically.
-->
<xsl:apply-templates select="basename|format|latex-scaling" />
</common>
<common formats="/latex/xelatex/"><xsl:apply-templates select="." mode="latex" /></common>
<common formats="/html/xhtml/">
<a>
<xsl:attribute name="href">
<xsl:text>-web-zoom.</xsl:text>
<xsl:choose>
<!-- CME: oops, I'd originally used the "format" tag to identify the format used in the LaTeX version, not the HTML! -->
<xsl:when test="count(format) != 0">
<xsl:message terminate="no">&lt;format&gt; element is deprecated in &lt;image&gt;; please use format attribute instead.</xsl:message>
<xsl:value-of select="format" />
</xsl:when>
<xsl:when test="@format">
<xsl:value-of select="@format" />
</xsl:when>
<xsl:otherwise>
<xsl:text>-web.</xsl:text>
<xsl:choose>
<!-- CME: oops, I'd originally used the "format" tag to identify the format used in the LaTeX version, not the HTML! -->
<xsl:when test="count(format) != 0">
<xsl:message terminate="no">&lt;format&gt; element is deprecated in &lt;image&gt;; please use format attribute instead.</xsl:message>
<xsl:value-of select="format" />
</xsl:when>
<xsl:when test="@format">
<xsl:value-of select="@format" />
</xsl:when>
<xsl:otherwise>
View
modules/obsolete.xml 0 → 100755