Created
March 27, 2017 18:57
-
-
Save ctbarber/eff4cf5b28e7266cff62139e55aa88c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- begin template match for figure snippet --> | |
<xsl:template match="table[@class='snippet-figure']" mode="copy"> | |
<xsl:variable name="figure-alignment"> | |
<xsl:choose> | |
<xsl:when test="lower-case(tbody/tr[3]/td[2]/node()) = 'none'"> | |
<xsl:text></xsl:text> | |
</xsl:when> | |
<xsl:when test="lower-case(tbody/tr[3]/td[2]/node()) = 'right'"> | |
<xsl:text>right </xsl:text> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:text>left </xsl:text> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> | |
<xsl:variable name="caption-alignment"> | |
<xsl:choose> | |
<xsl:when test="lower-case(tbody/tr[5]/td[2]/node()) = 'right'"> | |
<xsl:text>text-right</xsl:text> | |
</xsl:when> | |
<xsl:when test="lower-case(tbody/tr[5]/td[2]/node()) = 'center'"> | |
<xsl:text>text-center</xsl:text> | |
</xsl:when> | |
<!-- left is default and doesn't require extra class so otherwise is left blank --> | |
<xsl:otherwise> | |
<xsl:text>text-left</xsl:text> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> | |
<xsl:variable name="use-border"> | |
<xsl:choose> | |
<xsl:when test="lower-case(tbody/tr[7]/td[2]/node()) = 'no'"> | |
<xsl:text></xsl:text> | |
</xsl:when> | |
<!-- yes will be dafault so if it isn't no, then use border --> | |
<xsl:otherwise> | |
<xsl:text> thumbnail</xsl:text> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> | |
<xsl:variable name="figure-width"> | |
<xsl:choose> | |
<xsl:when test="lower-case(tbody/tr[8]/td[2]/node()) = '30' and lower-case(tbody/tr[10]/td[2]/node()) = 'no'"> | |
<xsl:text>uthsc-figure-small-up-30</xsl:text> | |
</xsl:when> | |
<xsl:when test="lower-case(tbody/tr[8]/td[2]/node()) = '40' and lower-case(tbody/tr[10]/td[2]/node()) = 'no'"> | |
<xsl:text>uthsc-figure-small-up-40</xsl:text> | |
</xsl:when> | |
<xsl:when test="lower-case(tbody/tr[8]/td[2]/node()) = '50' and lower-case(tbody/tr[10]/td[2]/node()) = 'no'"> | |
<xsl:text>uthsc-figure-small-up-50</xsl:text> | |
</xsl:when> | |
<xsl:when test="lower-case(tbody/tr[8]/td[2]/node()) = '60' and lower-case(tbody/tr[10]/td[2]/node()) = 'no'"> | |
<xsl:text>uthsc-figure-small-up-60</xsl:text> | |
</xsl:when> | |
<xsl:when test="lower-case(tbody/tr[8]/td[2]/node()) = '30' and not(lower-case(tbody/tr[10]/td[2]/node()) = 'no')"> | |
<xsl:text>uthsc-figure-30</xsl:text> | |
</xsl:when> | |
<xsl:when test="lower-case(tbody/tr[8]/td[2]/node()) = '50' and not(lower-case(tbody/tr[10]/td[2]/node()) = 'no')"> | |
<xsl:text>uthsc-figure-50</xsl:text> | |
</xsl:when> | |
<xsl:when test="lower-case(tbody/tr[8]/td[2]/node()) = '60' and not(lower-case(tbody/tr[10]/td[2]/node()) = 'no')"> | |
<xsl:text>uthsc-figure-60</xsl:text> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:text>uthsc-figure-40</xsl:text> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> | |
<figure class="{$figure-alignment}uthsc-figure {$figure-width}{$use-border}"> | |
<xsl:apply-templates select="tbody/tr[9]/td[2]/node()" mode="copy"/> | |
<xsl:if test="string-length(normalize-space(replace(tbody/tr[4]/td[2],'\p{Z}',' '))) > 0 or string-length(normalize-space(replace(tbody/tr[6]/td[2],'\p{Z}',' '))) > 0"> | |
<figcaption class="{$caption-alignment}"> | |
<xsl:if test="string-length(normalize-space(replace(tbody/tr[4]/td[2],'\p{Z}',' '))) > 0"> | |
<xsl:apply-templates select="tbody/tr[4]/td[2]//text()" mode="copy"/> | |
</xsl:if> | |
<xsl:if test="tbody/tr[6]/td[2]//a[1] and string-length(normalize-space(replace(tbody/tr[6]/td[2],'\p{Z}',' '))) > 0"> | |
<small class="uthsc-figure-source">Source: <a href="{tbody/td[6]/td[2]//a[1]/@href}"><xsl:apply-templates select="tbody/tr[6]/td[2]//a[1]/node()" mode="copy"/></a></small> | |
</xsl:if> | |
</figcaption> | |
</xsl:if> | |
</figure> | |
</xsl:template> | |
<!-- end template match for figure snippet --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment