Improved alt text handling and added/fixed support for numerous other tags.
This commit is contained in:
parent
b937107f39
commit
08641acec4
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
<xsl:template match="b">
|
||||
<!-- b not available -->
|
||||
|
@ -38,10 +38,12 @@
|
|||
</xsl:template>
|
||||
<xsl:template match="SideNote">
|
||||
<br/>
|
||||
<hr/>
|
||||
<span class="required-prodnote">Side note</span>
|
||||
<xsl:apply-templates/>
|
||||
<br/>
|
||||
<xsl:apply-templates/>
|
||||
<span class="optional-prodnote">End of side note</span>
|
||||
<hr/>
|
||||
<br/>
|
||||
</xsl:template>
|
||||
<xsl:template match="SideNote/Heading">
|
||||
|
@ -54,16 +56,18 @@
|
|||
<br/>
|
||||
<xsl:apply-templates/>
|
||||
</xsl:template>
|
||||
<xsl:template match="Footnote">
|
||||
<xsl:template match="Footnote">
|
||||
<br/>
|
||||
<hr/>
|
||||
<span class="required-prodnote">Footnote</span>
|
||||
<br/>
|
||||
<xsl:apply-templates/>
|
||||
<br/>
|
||||
<hr/>
|
||||
<span class="optional-prodnote">End of footnote</span>
|
||||
<br/>
|
||||
</xsl:template>
|
||||
<xsl:template match="InlineEquation">
|
||||
<xsl:template match="InlineEquation">
|
||||
<br/>
|
||||
<xsl:apply-templates/>
|
||||
</xsl:template>
|
||||
|
|
|
@ -2,16 +2,20 @@
|
|||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
<xsl:template name="apply-templates-lang">
|
||||
<xsl:for-each select="@xml:lang">
|
||||
<xsl:copy/>
|
||||
<xsl:if test="string-length(.) > 0">
|
||||
<xsl:copy/>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
<xsl:apply-templates/>
|
||||
</xsl:template>
|
||||
<xsl:template match="language">
|
||||
<span>
|
||||
<xsl:attribute name="xml:lang">
|
||||
<xsl:value-of select="@val"/>
|
||||
</xsl:attribute>
|
||||
<xsl:apply-templates/>
|
||||
</span>
|
||||
<xsl:if test="string-length(@val) > 0">
|
||||
<span>
|
||||
<xsl:attribute name="xml:lang">
|
||||
<xsl:value-of select="@val"/>
|
||||
</xsl:attribute>
|
||||
<xsl:apply-templates/>
|
||||
</span>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
|
|
|
@ -103,20 +103,36 @@
|
|||
<p>
|
||||
<span class="optional-prodnote">Figure</span>
|
||||
</p>
|
||||
<p>
|
||||
<img>
|
||||
<xsl:attribute name="src">
|
||||
<xsl:value-of select="./Image/@src"/>
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="alt">
|
||||
<xsl:value-of select="./Image/@alt"/>
|
||||
</xsl:attribute>
|
||||
</img>
|
||||
</p>
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length(./Image/@src) > 0">
|
||||
<img>
|
||||
<xsl:attribute name="src">
|
||||
<xsl:value-of select="./Image/@src"/>
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="alt">
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length(./Image/@alt) > 0">
|
||||
<xsl:value-of select="./Image/@alt"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="string-length(Alternative) > 0">
|
||||
<xsl:value-of select="Alternative"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>no alternative text</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
</img>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<p>
|
||||
<xsl:apply-templates select="./Image/text() | ./Image/* "/>
|
||||
</p>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:apply-templates select="Caption"/>
|
||||
<xsl:apply-templates select="Alternative"/>
|
||||
<xsl:apply-templates select="Description"/>
|
||||
<xsl:apply-tempaltes select="SourceReference"/>
|
||||
<xsl:apply-templates select="SourceReference"/>
|
||||
<p>
|
||||
<span class="optional-prodnote">End of figure</span>
|
||||
</p>
|
||||
|
@ -125,22 +141,39 @@
|
|||
<p>
|
||||
<span class="optional-prodnote">Equation</span>
|
||||
</p>
|
||||
<p>
|
||||
<img>
|
||||
<xsl:attribute name="src">
|
||||
<xsl:value-of select="./Image/@src"/>
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="alt">
|
||||
<xsl:value-of select="./Image/@alt"/>
|
||||
</xsl:attribute>
|
||||
</img>
|
||||
</p>
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length(./Image/@src) > 0">
|
||||
<img>
|
||||
<xsl:attribute name="src">
|
||||
<xsl:value-of select="./Image/@src"/>
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="alt">
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length(./Image/@alt) > 0">
|
||||
<xsl:value-of select="./Image/@alt"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="string-length(Alternative) > 0">
|
||||
<xsl:value-of select="Alternative"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>no alternative text</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
</img>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<p>
|
||||
<xsl:apply-templates select="./Image/text() | ./Image/* "/>
|
||||
</p>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:apply-templates select="Label"/>
|
||||
<xsl:apply-templates select="TeX"/>
|
||||
<xsl:apply-templates select="MathML"/>
|
||||
<xsl:apply-templates select="Caption"/>
|
||||
<xsl:apply-templates select="Alternative"/>
|
||||
<xsl:apply-templates select="Description"/>
|
||||
<xsl:apply-tempaltes select="SourceReference"/>
|
||||
<xsl:apply-templates select="SourceReference"/>
|
||||
<span class="optional-prodnote">End of equation</span>
|
||||
</xsl:template>
|
||||
<xsl:template match="Equation/TeX">
|
||||
|
|
|
@ -10,9 +10,11 @@
|
|||
</xsl:template>
|
||||
<xsl:template match="UnitID"/>
|
||||
<xsl:template match="UnitTitle">
|
||||
<h1>
|
||||
<xsl:call-template name="apply-templates-lang"/>
|
||||
</h1>
|
||||
<xsl:if test="string-length(./text()) > 0">
|
||||
<h1>
|
||||
<xsl:call-template name="apply-templates-lang"/>
|
||||
</h1>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template match="Unit/ByLine">
|
||||
<p>
|
||||
|
@ -125,14 +127,18 @@
|
|||
</xsl:template>
|
||||
<xsl:template match="MediaContent">
|
||||
<xsl:if test="@type = 'audio'">
|
||||
<p><span class="required-prodnote">[Audio content]</span></p>
|
||||
<p>
|
||||
<span class="required-prodnote">[Audio content]</span>
|
||||
</p>
|
||||
<p>
|
||||
<a><xsl:attribute name="href"><xsl:value-of select="@src"/>.mp3</xsl:attribute>MP3 file
|
||||
</a>
|
||||
</p>
|
||||
</xsl:if>
|
||||
<xsl:if test="@type = 'pdf'">
|
||||
<p><span class="required-prodnote">[PDF content]</span></p>
|
||||
<p>
|
||||
<span class="required-prodnote">[PDF content]</span>
|
||||
</p>
|
||||
<!--<p><a><xsl:attribute name="href"><xsl:value-of select="@src"/>.pdf</xsl:attribute></a></p>-->
|
||||
</xsl:if>
|
||||
<xsl:call-template name="apply-templates-lang"/>
|
||||
|
@ -162,22 +168,32 @@
|
|||
</xsl:template>
|
||||
<xsl:template match="Caption">
|
||||
<p>
|
||||
<xsl:call-template name="apply-templates-lang"/>
|
||||
<span class="caption">
|
||||
<xsl:call-template name="apply-templates-lang"/>
|
||||
</span>
|
||||
</p>
|
||||
</xsl:template>
|
||||
<xsl:template match="Alternative">
|
||||
<p>
|
||||
<xsl:if test="string-length(.) > 0">
|
||||
<span class="optional-prodnote"><strong>Alternative</strong>: </span>
|
||||
</xsl:if>
|
||||
<xsl:call-template name="apply-templates-lang"/>
|
||||
</p>
|
||||
</xsl:template>
|
||||
<xsl:template match="Description">
|
||||
<p>
|
||||
<xsl:if test="string-length(.) > 0">
|
||||
<span class="optional-prodnote"><strong>Description</strong>: </span>
|
||||
</xsl:if>
|
||||
<xsl:call-template name="apply-templates-lang"/>
|
||||
</p>
|
||||
</xsl:template>
|
||||
<xsl:template match="Label">
|
||||
<p>
|
||||
<xsl:call-template name="apply-templates-lang"/>
|
||||
<strong>
|
||||
<xsl:call-template name="apply-templates-lang"/>
|
||||
</strong>
|
||||
</p>
|
||||
</xsl:template>
|
||||
<xsl:template match="Table">
|
||||
|
|
Loading…
Reference in New Issue