From: <bob...@us...> - 2012-04-16 20:41:26
|
Revision: 9282 http://docbook.svn.sourceforge.net/docbook/?rev=9282&view=rev Author: bobstayton Date: 2012-04-16 20:41:20 +0000 (Mon, 16 Apr 2012) Log Message: ----------- Fix handling of mediatypes for video and audio files, mostly for HTML5 and EPUB3 outputs. Modified Paths: -------------- trunk/xsl/common/common.xsl trunk/xsl/epub3/epub3-element-mods.xsl trunk/xsl/fo/graphics.xsl trunk/xsl/html/graphics.xsl Modified: trunk/xsl/common/common.xsl =================================================================== --- trunk/xsl/common/common.xsl 2012-04-16 08:24:39 UTC (rev 9281) +++ trunk/xsl/common/common.xsl 2012-04-16 20:41:20 UTC (rev 9282) @@ -1,4 +1,8 @@ <?xml version='1.0'?> +<!DOCTYPE xsl:stylesheet [ +<!ENTITY lowercase "'abcdefghijklmnopqrstuvwxyz'"> +<!ENTITY uppercase "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"> + ]> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" xmlns:dyn="http://exslt.org/dynamic" @@ -2045,4 +2049,48 @@ </xsl:otherwise> </xsl:choose> </xsl:template> + + +<doc:template name="graphic.format.content-type" xmlns=""> + <refpurpose>Returns mimetype for media format</refpurpose> + <refdescription id="graphic.format.content-type-desc"> + <para>This takes as input a 'format' param and returns + a mimetype string. It uses an xsl:choose after first + converting the input to all uppercase.</para> + </refdescription> +</doc:template> +<xsl:template name="graphic.format.content-type"> + <xsl:param name="format"/> + <xsl:variable name="upperformat" select="translate($format,&lowercase;,&uppercase;)"/> + <xsl:choose> + <xsl:when test="$upperformat = ''"></xsl:when> + <xsl:when test="$upperformat = 'linespecific'"></xsl:when> + <xsl:when test="$upperformat = 'PS'">application/postscript</xsl:when> + <xsl:when test="$upperformat = 'PDF'">application/pdf</xsl:when> + <xsl:when test="$upperformat = 'PNG'">image/png</xsl:when> + <xsl:when test="$upperformat = 'SVG'">image/svg+xml</xsl:when> + <xsl:when test="$upperformat = 'JPG'">image/jpeg</xsl:when> + <xsl:when test="$upperformat = 'JPEG'">image/jpeg</xsl:when> + <xsl:when test="$upperformat = 'GIF'">image/gif</xsl:when> + <xsl:when test="$upperformat = 'GIF87A'">image/gif</xsl:when> + <xsl:when test="$upperformat = 'GIF89A'">image/gif</xsl:when> + <xsl:when test="$upperformat = 'ACC'">audio/acc</xsl:when> + <xsl:when test="$upperformat = 'MPG'">audio/mpeg</xsl:when> + <xsl:when test="$upperformat = 'MP1'">audio/mpeg</xsl:when> + <xsl:when test="$upperformat = 'MP2'">audio/mpeg</xsl:when> + <xsl:when test="$upperformat = 'MP3'">audio/mpeg</xsl:when> + <xsl:when test="$upperformat = 'M4A'">audio/mp4</xsl:when> + <xsl:when test="$upperformat = 'MPEG'">audio/mpeg</xsl:when> + <xsl:when test="$upperformat = 'WAV'">audio/wav</xsl:when> + <xsl:when test="$upperformat = 'MP4'">video/mp4</xsl:when> + <xsl:when test="$upperformat = 'M4V'">video/mp4</xsl:when> + <xsl:when test="$upperformat = 'OGV'">video/ogg</xsl:when> + <xsl:when test="$upperformat = 'OGG'">video/ogg</xsl:when> + <xsl:when test="$upperformat = 'WEBM'">video/webm</xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat('image/', $upperformat)"/> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + </xsl:stylesheet> Modified: trunk/xsl/epub3/epub3-element-mods.xsl =================================================================== --- trunk/xsl/epub3/epub3-element-mods.xsl 2012-04-16 08:24:39 UTC (rev 9281) +++ trunk/xsl/epub3/epub3-element-mods.xsl 2012-04-16 20:41:20 UTC (rev 9282) @@ -1156,25 +1156,6 @@ </xsl:if> </xsl:template> -<xsl:template name="graphic.format.content-type"> - <xsl:param name="format" select="''"/> - <xsl:choose> - <xsl:when test="$format = ''"></xsl:when> - <xsl:when test="$format = 'linespecific'"></xsl:when> - <xsl:when test="$format = 'PS'">application/postscript</xsl:when> - <xsl:when test="$format = 'PDF'">application/pdf</xsl:when> - <xsl:when test="$format = 'PNG'">image/png</xsl:when> - <xsl:when test="$format = 'SVG'">image/svg+xml</xsl:when> - <xsl:when test="$format = 'JPG'">image/jpeg</xsl:when> - <xsl:when test="$format = 'GIF87a'">image/gif</xsl:when> - <xsl:when test="$format = 'GIF89a'">image/gif</xsl:when> - <xsl:otherwise> - <xsl:value-of select="concat('image/', - translate($format, &uppercase;, &lowercase;))"/> - </xsl:otherwise> - </xsl:choose> -</xsl:template> - <xsl:template name="manifest.toc"> <xsl:variable name="toc.params"> <xsl:call-template name="find.path.params"> @@ -1433,9 +1414,12 @@ <xsl:template match="mediaobject|inlinemediaobject" mode="enumerate-images"> - <xsl:variable name="olist" select="imageobject|imageobjectco| - videoobject|audioobject| - textobject"/> + <xsl:variable name="olist" + select="imageobject[not(@role = 'poster')] + |imageobjectco + |videoobject + |audioobject + |textobject"/> <xsl:variable name="object.index"> <xsl:call-template name="select.mediaobject.index"> @@ -1446,6 +1430,16 @@ <xsl:variable name="object" select="$olist[position() = $object.index]"/> + <xsl:apply-templates select="$object" mode="enumerate-images"/> + + <!-- also include a poster image if present --> + <xsl:apply-templates select="imageobject[@role = 'poster']" mode="enumerate-images"/> + +</xsl:template> + +<xsl:template match="imageobject|videoobject|audioobject" mode="enumerate-images"> + <xsl:param name="object" select="."/> + <xsl:if test="$object"> <xsl:variable name="image.filename"> <xsl:call-template name="mediaobject.filename"> @@ -1477,7 +1471,7 @@ </xsl:if> </xsl:template> - + <!-- Add in the generated images --> <xsl:template match="note|caution|warning|important|tip" mode="enumerate-images"> <xsl:if test="$admon.graphics != 0"> Modified: trunk/xsl/fo/graphics.xsl =================================================================== --- trunk/xsl/fo/graphics.xsl 2012-04-16 08:24:39 UTC (rev 9281) +++ trunk/xsl/fo/graphics.xsl 2012-04-16 20:41:20 UTC (rev 9282) @@ -93,33 +93,7 @@ concat(' ', $lcext, ' '))">1</xsl:if> </xsl:template> -<xsl:template name="graphic.format.content-type"> - <xsl:param name="format"/> - <xsl:variable name="is.graphic.format"> - <xsl:call-template name="is.graphic.format"> - <xsl:with-param name="format" select="$format"/> - </xsl:call-template> - </xsl:variable> - <xsl:if test="$is.graphic.format"> - <xsl:choose> - <xsl:when test="$format = ''"></xsl:when> - <xsl:when test="$format = 'linespecific'"></xsl:when> - <xsl:when test="$format = 'PS'">application/postscript</xsl:when> - <xsl:when test="$format = 'PDF'">application/pdf</xsl:when> - <xsl:when test="$format = 'PNG'">image/png</xsl:when> - <xsl:when test="$format = 'SVG'">image/svg+xml</xsl:when> - <xsl:when test="$format = 'JPG'">image/jpeg</xsl:when> - <xsl:when test="$format = 'GIF87a'">image/gif</xsl:when> - <xsl:when test="$format = 'GIF89a'">image/gif</xsl:when> - <xsl:otherwise> - <xsl:value-of select="concat('image/', - translate($format, &uppercase;, &lowercase;))"/> - </xsl:otherwise> - </xsl:choose> - </xsl:if> -</xsl:template> - <!-- ==================================================================== --> <xsl:template match="screenshot"> Modified: trunk/xsl/html/graphics.xsl =================================================================== --- trunk/xsl/html/graphics.xsl 2012-04-16 08:24:39 UTC (rev 9281) +++ trunk/xsl/html/graphics.xsl 2012-04-16 20:41:20 UTC (rev 9282) @@ -53,9 +53,21 @@ or $lcext = 'jpg' or $lcext = 'avi' or $lcext = 'mpg' + or $lcext = 'mp4' or $lcext = 'mpeg' or $lcext = 'qt' or $lcext = 'gif' + or $lcext = 'acc' + or $lcext = 'mp1' + or $lcext = 'mp2' + or $lcext = 'mp3' + or $lcext = 'mp4' + or $lcext = 'm4v' + or $lcext = 'm4a' + or $lcext = 'wav' + or $lcext = 'ogv' + or $lcext = 'ogg' + or $lcext = 'webm' or $lcext = 'bmp'">1</xsl:if> </xsl:template> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |