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