diff --git a/Doc/Sda1/Ref/Fig/Makefile b/Doc/Sda1/Ref/Fig/Makefile index 7c96366f8a2fd3dc4fbb2dbb686a00eb16523adc..f147f7067e9535269fa73914be57de4c8dd5a50b 100644 --- a/Doc/Sda1/Ref/Fig/Makefile +++ b/Doc/Sda1/Ref/Fig/Makefile @@ -1,5 +1,5 @@ -FIGFILES=\ +#FIGFILES=\ attribInElement domtree invoicedataimplement jdbcurl pageStack sqlinject xhtml \ attributes entityresolve jdbcarch memofour persistence sqlTransport xml2fo2pdf \ booknavigate externalize jdbcFourTier memorelativexpath persistentStates sqlTransportPrepare xml2html \ @@ -12,6 +12,12 @@ dictionaryStack invoicedata jdbcThreeTier pagerefStack saxxmlr #FIGFILES=clientserv FIGFILES=$(shell /bin/ls *.fig | sed -e s/\.fig//g) +TEXFILES=$(shell cd Generate;/bin/ls *.tex | sed -e s/\.tex//g) + +p: + @echo $(FIGFILES) + @echo "" +# @echo $(TEXFILES) include ../../../../make.rules diff --git a/Doc/make.rules b/Doc/make.rules index 5b2671832ae4d14b67a61ad02ee5886ac2bbd18f..277f8972f4ee3eaf44355e2a0b15fa1b8ee4f4d4 100644 --- a/Doc/make.rules +++ b/Doc/make.rules @@ -1,13 +1,20 @@ -%.pdf:%.fig +%.fig.pdf:%.fig fig2dev -L pstex $< | epstopdf -f > $*.fig.pdf - cd Generate; fig2mpdf -l -m ../$< #&& touch $*.done - cd Generate; if [ -e $*.tex ]; then pdflatex $* && mv -f $*.pdf ..; fi; -pdf:$(foreach figfile, $(FIGFILES), $(figfile).pdf) # $(foreach figfile, $(FIGFILES), $(figfile).fig.pdf) +%.pdf:%.fig + if [ ! -f Generate/$*.tex ]; then \ + echo File $< " is not being referenced from any XML document, exiting!"; \ + exit 1; \ + fi + cd Generate; fig2mpdf -l -m ../$< + cd Generate; pdflatex $* && mv -f $*.pdf .. + +pdf:$(foreach figfile, $(FIGFILES), $(figfile).pdf $(figfile).fig.pdf ) all: pdf -clean: - rm -rf $(foreach figfile, $(FIGFILES), $(figfile).pdf $(figfile).fig.pdf Generate/$(figfile)-*.pdf) - cd Generate; rm -f *.aux *.log *.nav *.out *.snm *.toc +clean: + rm -rf $(foreach figfile, $(FIGFILES), $(figfile).fig.pdf) + cd Generate; rm -f *.aux *.log *.nav *.out *.snm *.toc $(foreach texfile, $(TEXFILES), ../$(texfile).pdf $(texfile)-*.pdf) +#end diff --git a/ws/Docbook/Extensions/addon/config/docbook5/xsl/common/hdmextensions.xsl b/ws/Docbook/Extensions/addon/config/docbook5/xsl/common/hdmextensions.xsl index 5010719507faef3d5d2cb77f5a8400ecdee1f382..872986ede8160dd5d6c102dcc1e50cf56d47b654 100644 --- a/ws/Docbook/Extensions/addon/config/docbook5/xsl/common/hdmextensions.xsl +++ b/ws/Docbook/Extensions/addon/config/docbook5/xsl/common/hdmextensions.xsl @@ -4,19 +4,18 @@ exclude-result-prefixes="d" version="1.1"> - <xsl:template match="d:figure" mode="goik"> + <xsl:template match="d:imagedata" mode="goik"> - <xsl:variable name="fullFileName" select="d:mediaobject/d:imageobject/d:imagedata/@fileref"/> <xsl:variable name="dirPath"> <xsl:call-template name="hdm.get.leftmost.of.seperator"> - <xsl:with-param name="path" select="$fullFileName"/> + <xsl:with-param name="path" select="@fileref"/> <xsl:with-param name="seperator" select="'/'"/> </xsl:call-template> </xsl:variable> <xsl:variable name="fileName"> <xsl:call-template name="hdm.get.pure.filename"> - <xsl:with-param name="path" select="$fullFileName"/> + <xsl:with-param name="path" select="@fileref"/> </xsl:call-template> </xsl:variable> @@ -44,8 +43,13 @@ <xsl:document method="text" encoding="utf-8" href="{$fullGenerateBasename}.tex"> <xsl:text>\input{../pre.tex} - \begin{mycenterframe}{</xsl:text> - <xsl:apply-templates select="." mode="object.title.markup.textonly"/> + \begin{mycenterframe}{</xsl:text> + <xsl:choose> + <xsl:when test="ancestor::d:figure"> + <xsl:apply-templates select="ancestor::d:figure" mode="object.title.markup.textonly"/> + </xsl:when> + <xsl:otherwise>-</xsl:otherwise> + </xsl:choose> <xsl:text>} \multifigure{</xsl:text> <xsl:value-of select="$fileBaseName" /> @@ -53,6 +57,7 @@ \end{mycenterframe} \end{document}</xsl:text> </xsl:document> + </xsl:template> diff --git a/ws/Docbook/Extensions/addon/config/docbook5/xsl/html/formal.xsl b/ws/Docbook/Extensions/addon/config/docbook5/xsl/html/formal.xsl index 963801e9534274184f1b3b738bd5b856eb9f52d4..5c4f6ce6d9e68dfb396d4cc52cbbe15b68d75e12 100644 --- a/ws/Docbook/Extensions/addon/config/docbook5/xsl/html/formal.xsl +++ b/ws/Docbook/Extensions/addon/config/docbook5/xsl/html/formal.xsl @@ -1,4 +1,4 @@ -<?xml version='1.0'?> +?xml version='1.0'?> <xsl:stylesheet exclude-result-prefixes="d" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:d="http://docbook.org/ns/docbook" @@ -177,7 +177,6 @@ version='1.0'> </xsl:template> <xsl:template match="d:figure"> - <xsl:apply-templates select="self::d:figure[d:mediaobject/d:imageobject]" mode="goik"/> <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement), concat(local-name(.), ' '))"/> diff --git a/ws/Docbook/Extensions/addon/config/docbook5/xsl/html/graphics.xsl b/ws/Docbook/Extensions/addon/config/docbook5/xsl/html/graphics.xsl new file mode 100644 index 0000000000000000000000000000000000000000..b4b9ab7ad468b362181bf96e5ae3ff763a1ff5ff --- /dev/null +++ b/ws/Docbook/Extensions/addon/config/docbook5/xsl/html/graphics.xsl @@ -0,0 +1,1610 @@ +<?xml version='1.0'?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:d="http://docbook.org/ns/docbook" +xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:stext="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.TextFactory" + xmlns:simg="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.ImageIntrinsics" + xmlns:ximg="xalan://com.nwalsh.xalan.ImageIntrinsics" + xmlns:xtext="xalan://com.nwalsh.xalan.Text" + xmlns:lxslt="http://xml.apache.org/xslt" + exclude-result-prefixes="xlink stext xtext lxslt simg ximg d" + extension-element-prefixes="stext xtext" + version='1.0'> + +<!-- ******************************************************************** + $Id: graphics.xsl 9710 2013-01-22 19:34:18Z bobstayton $ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://docbook.sf.net/release/xsl/current/ for + copyright and other information. + + Contributors: + Colin Paul Adams, <colin@colina.demon.co.uk> + + ******************************************************************** --> + +<lxslt:component prefix="xtext" elements="d:insertfile"/> +<lxslt:component prefix="ximg" functions="new getWidth getDepth"/> + +<!-- ==================================================================== --> +<!-- Graphic format tests for the HTML backend --> + +<xsl:template name="is.graphic.format"> + <xsl:param name="format"></xsl:param> + <xsl:if test="$format = 'SVG' + or $format = 'PNG' + or $format = 'JPG' + or $format = 'JPEG' + or $format = 'linespecific' + or $format = 'GIF' + or $format = 'GIF87a' + or $format = 'GIF89a' + or $format = 'BMP'">1</xsl:if> +</xsl:template> + +<xsl:template name="is.graphic.extension"> + <xsl:param name="ext"></xsl:param> + <xsl:variable name="lcext" select="translate($ext, + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', + 'abcdefghijklmnopqrstuvwxyz')"/> + <xsl:if test="$lcext = 'svg' + or $lcext = 'png' + or $lcext = 'jpeg' + 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> + +<!-- ==================================================================== --> + +<xsl:template match="d:screenshot"> + <div> + <xsl:apply-templates select="." mode="common.html.attributes"/> + <xsl:call-template name="id.attribute"/> + <xsl:call-template name="anchor"/> + <xsl:apply-templates/> + </div> +</xsl:template> + +<xsl:template match="d:screenshot/d:title"> + <xsl:call-template name="formal.object.heading"> + <xsl:with-param name="object" select=".."/> + </xsl:call-template> +</xsl:template> + +<xsl:template match="d:screeninfo"> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template name="process.image"> + <!-- When this template is called, the current node should be --> + <!-- a graphic, inlinegraphic, imagedata, or videodata. All --> + <!-- those elements have the same set of attributes, so we can --> + <!-- handle them all in one place. --> + <xsl:param name="tag" select="'img'"/> + <xsl:param name="alt"/> + <xsl:param name="longdesc"/> + + <!-- The HTML img element only supports the notion of content-area + scaling; it doesn't support the distinction between a + content-area and a viewport-area, so we have to make some + compromises. + + 1. If only the content-area is specified, everything is fine. + (If you ask for a three inch image, that's what you'll get.) + + 2. If only the viewport-area is provided: + - If scalefit=1, treat it as both the content-area and + the viewport-area. (If you ask for an image in a five inch + area, we'll make the image five inches to fill that area.) + - If scalefit=0, ignore the viewport-area specification. + + Note: this is not quite the right semantic and has the additional + problem that it can result in anamorphic scaling, which scalefit + should never cause. + + 3. If both the content-area and the viewport-area is specified + on a graphic element, ignore the viewport-area. + (If you ask for a three inch image in a five inch area, we'll assume + it's better to give you a three inch image in an unspecified area + than a five inch image in a five inch area. + + Relative units also cause problems. As a general rule, the stylesheets + are operating too early and too loosely coupled with the rendering engine + to know things like the current font size or the actual dimensions of + an image. Therefore: + + 1. We use a fixed size for pixels, $pixels.per.inch + + 2. We use a fixed size for "em"s, $points.per.em + + Percentages are problematic. In the following discussion, we speak + of width and contentwidth, but the same issues apply to depth and + contentdepth + + 1. A width of 50% means "half of the available space for the image." + That's fine. But note that in HTML, this is a dynamic property and + the image size will vary if the browser window is resized. + + 2. A contentwidth of 50% means "half of the actual image width". But + the stylesheets have no way to assess the image's actual size. Treating + this as a width of 50% is one possibility, but it produces behavior + (dynamic scaling) that seems entirely out of character with the + meaning. + + Instead, the stylesheets define a $nominal.image.width + and convert percentages to actual values based on that nominal size. + + Scale can be problematic. Scale applies to the contentwidth, so + a scale of 50 when a contentwidth is not specified is analagous to a + width of 50%. (If a contentwidth is specified, the scaling factor can + be applied to that value and no problem exists.) + + If scale is specified but contentwidth is not supplied, the + nominal.image.width is used to calculate a base size + for scaling. + + Warning: as a consequence of these decisions, unless the aspect ratio + of your image happens to be exactly the same as (nominal width / nominal height), + specifying contentwidth="50%" and contentdepth="50%" is NOT going to + scale the way you expect (or really, the way it should). + + Don't do that. In fact, a percentage value is not recommended for content + size at all. Use scale instead. + + Finally, align and valign are troublesome. Horizontal alignment is now + supported by wrapping the image in a <div align="{@align}"> (in block + contexts!). I can't think of anything (practical) to do about vertical + alignment. + --> + + <xsl:variable name="width-units"> + <xsl:choose> + <xsl:when test="$ignore.image.scaling != 0"></xsl:when> + <xsl:when test="@width"> + <xsl:call-template name="length-units"> + <xsl:with-param name="length" select="@width"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="not(@depth) and $default.image.width != ''"> + <xsl:call-template name="length-units"> + <xsl:with-param name="length" select="$default.image.width"/> + </xsl:call-template> + </xsl:when> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="width"> + <xsl:choose> + <xsl:when test="$ignore.image.scaling != 0"></xsl:when> + <xsl:when test="@width"> + <xsl:choose> + <xsl:when test="$width-units = '%'"> + <xsl:value-of select="@width"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="length-spec"> + <xsl:with-param name="length" select="@width"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:when test="not(@depth) and $default.image.width != ''"> + <xsl:value-of select="$default.image.width"/> + </xsl:when> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="scalefit"> + <xsl:choose> + <xsl:when test="$ignore.image.scaling != 0">0</xsl:when> + <xsl:when test="@contentwidth or @contentdepth">0</xsl:when> + <xsl:when test="@scale">0</xsl:when> + <xsl:when test="@scalefit"><xsl:value-of select="@scalefit"/></xsl:when> + <xsl:when test="$width != '' or @depth">1</xsl:when> + <xsl:otherwise>0</xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="scale"> + <xsl:choose> + <xsl:when test="$ignore.image.scaling != 0">1.0</xsl:when> + <xsl:when test="@contentwidth or @contentdepth">1.0</xsl:when> + <xsl:when test="@scale"> + <xsl:value-of select="@scale div 100.0"/> + </xsl:when> + <xsl:otherwise>1.0</xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="filename"> + <xsl:choose> + <xsl:when test="local-name(.) = 'graphic' + or local-name(.) = 'inlinegraphic'"> + <!-- handle legacy graphic and inlinegraphic by new template --> + <xsl:call-template name="mediaobject.filename"> + <xsl:with-param name="object" select="."/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <!-- imagedata, videodata, audiodata --> + <xsl:call-template name="mediaobject.filename"> + <xsl:with-param name="object" select=".."/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="output_filename"> + <xsl:choose> + <xsl:when test="@entityref"> + <xsl:value-of select="$filename"/> + </xsl:when> + <!-- + Moved test for $keep.relative.image.uris to template below: + <xsl:template match="@fileref"> + --> + <xsl:otherwise> + <xsl:value-of select="$filename"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="img.src.path.pi"> + <xsl:call-template name="pi.dbhtml_img.src.path"> + <xsl:with-param name="node" select=".."/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="filename.for.graphicsize"> + <xsl:choose> + <xsl:when test="$img.src.path.pi != ''"> + <xsl:value-of select="concat($img.src.path.pi, $filename)"/> + </xsl:when> + <xsl:when test="$img.src.path != '' and + $graphicsize.use.img.src.path != 0 and + $tag = 'img' and + not(starts-with($filename, '/')) and + not(contains($filename, '://'))"> + <xsl:value-of select="concat($img.src.path, $filename)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$filename"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="realintrinsicwidth"> + <!-- This funny compound test works around a bug in XSLTC --> + <xsl:choose> + <xsl:when test="$use.extensions != 0 and $graphicsize.extension != 0 + and not(@format='SVG')"> + <xsl:choose> + <xsl:when test="function-available('simg:getWidth')"> + <xsl:value-of select="simg:getWidth(simg:new($filename.for.graphicsize), + $nominal.image.width)"/> + </xsl:when> + <xsl:when test="function-available('ximg:getWidth')"> + <xsl:value-of select="ximg:getWidth(ximg:new($filename.for.graphicsize), + $nominal.image.width)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="0"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="0"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="intrinsicwidth"> + <xsl:choose> + <xsl:when test="$realintrinsicwidth = 0"> + <xsl:value-of select="$nominal.image.width"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$realintrinsicwidth"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="intrinsicdepth"> + <!-- This funny compound test works around a bug in XSLTC --> + <xsl:choose> + <xsl:when test="$use.extensions != 0 and $graphicsize.extension != 0 + and not(@format='SVG')"> + <xsl:choose> + <xsl:when test="function-available('simg:getDepth')"> + <xsl:value-of select="simg:getDepth(simg:new($filename.for.graphicsize), + $nominal.image.depth)"/> + </xsl:when> + <xsl:when test="function-available('ximg:getDepth')"> + <xsl:value-of select="ximg:getDepth(ximg:new($filename.for.graphicsize), + $nominal.image.depth)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$nominal.image.depth"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$nominal.image.depth"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="contentwidth"> + <xsl:choose> + <xsl:when test="$ignore.image.scaling != 0"></xsl:when> + <xsl:when test="@contentwidth"> + <xsl:variable name="units"> + <xsl:call-template name="length-units"> + <xsl:with-param name="length" select="@contentwidth"/> + </xsl:call-template> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$units = '%'"> + <xsl:variable name="cmagnitude"> + <xsl:call-template name="length-magnitude"> + <xsl:with-param name="length" select="@contentwidth"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="$intrinsicwidth * $cmagnitude div 100.0"/> + <xsl:text>px</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="length-spec"> + <xsl:with-param name="length" select="@contentwidth"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$intrinsicwidth"/> + <xsl:text>px</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="scaled.contentwidth"> + <xsl:if test="$contentwidth != ''"> + <xsl:variable name="cwidth.in.points"> + <xsl:call-template name="length-in-points"> + <xsl:with-param name="length" select="$contentwidth"/> + <xsl:with-param name="pixels.per.inch" select="$pixels.per.inch"/> + <xsl:with-param name="em.size" select="$points.per.em"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="round($cwidth.in.points div 72.0 * $pixels.per.inch * $scale)"/> + </xsl:if> + </xsl:variable> + + <xsl:variable name="html.width"> + <xsl:choose> + <xsl:when test="$ignore.image.scaling != 0"></xsl:when> + <xsl:when test="$width-units = '%'"> + <xsl:value-of select="$width"/> + </xsl:when> + <xsl:when test="$width != ''"> + <xsl:variable name="width.in.points"> + <xsl:call-template name="length-in-points"> + <xsl:with-param name="length" select="$width"/> + <xsl:with-param name="pixels.per.inch" select="$pixels.per.inch"/> + <xsl:with-param name="em.size" select="$points.per.em"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="round($width.in.points div 72.0 * $pixels.per.inch)"/> + </xsl:when> + <xsl:otherwise></xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="contentdepth"> + <xsl:choose> + <xsl:when test="$ignore.image.scaling != 0"></xsl:when> + <xsl:when test="@contentdepth"> + <xsl:variable name="units"> + <xsl:call-template name="length-units"> + <xsl:with-param name="length" select="@contentdepth"/> + </xsl:call-template> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$units = '%'"> + <xsl:variable name="cmagnitude"> + <xsl:call-template name="length-magnitude"> + <xsl:with-param name="length" select="@contentdepth"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="$intrinsicdepth * $cmagnitude div 100.0"/> + <xsl:text>px</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="length-spec"> + <xsl:with-param name="length" select="@contentdepth"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$intrinsicdepth"/> + <xsl:text>px</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="scaled.contentdepth"> + <xsl:if test="$contentdepth != ''"> + <xsl:variable name="cdepth.in.points"> + <xsl:call-template name="length-in-points"> + <xsl:with-param name="length" select="$contentdepth"/> + <xsl:with-param name="pixels.per.inch" select="$pixels.per.inch"/> + <xsl:with-param name="em.size" select="$points.per.em"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="round($cdepth.in.points div 72.0 * $pixels.per.inch * $scale)"/> + </xsl:if> + </xsl:variable> + + <xsl:variable name="depth-units"> + <xsl:if test="@depth"> + <xsl:call-template name="length-units"> + <xsl:with-param name="length" select="@depth"/> + </xsl:call-template> + </xsl:if> + </xsl:variable> + + <xsl:variable name="depth"> + <xsl:if test="@depth"> + <xsl:choose> + <xsl:when test="$depth-units = '%'"> + <xsl:value-of select="@depth"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="length-spec"> + <xsl:with-param name="length" select="@depth"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:if> + </xsl:variable> + + <xsl:variable name="html.depth"> + <xsl:choose> + <xsl:when test="$ignore.image.scaling != 0"></xsl:when> + <xsl:when test="$depth-units = '%'"> + <xsl:value-of select="$depth"/> + </xsl:when> + <xsl:when test="@depth and @depth != ''"> + <xsl:variable name="depth.in.points"> + <xsl:call-template name="length-in-points"> + <xsl:with-param name="length" select="$depth"/> + <xsl:with-param name="pixels.per.inch" select="$pixels.per.inch"/> + <xsl:with-param name="em.size" select="$points.per.em"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="round($depth.in.points div 72.0 * $pixels.per.inch)"/> + </xsl:when> + <xsl:otherwise></xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="viewport"> + <xsl:choose> + <xsl:when test="$ignore.image.scaling != 0">0</xsl:when> + <xsl:when test="local-name(.) = 'inlinegraphic' + or ancestor::d:inlinemediaobject + or ancestor::d:inlineequation">0</xsl:when> + <xsl:otherwise> + <xsl:value-of select="$make.graphic.viewport"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + +<!-- + <xsl:message>===================================== +scale: <xsl:value-of select="$scale"/>, <xsl:value-of select="$scalefit"/> +@contentwidth <xsl:value-of select="@contentwidth"/> +$contentwidth <xsl:value-of select="$contentwidth"/> +scaled.contentwidth: <xsl:value-of select="$scaled.contentwidth"/> +@width: <xsl:value-of select="@width"/> +width: <xsl:value-of select="$width"/> +html.width: <xsl:value-of select="$html.width"/> +@contentdepth <xsl:value-of select="@contentdepth"/> +$contentdepth <xsl:value-of select="$contentdepth"/> +scaled.contentdepth: <xsl:value-of select="$scaled.contentdepth"/> +@depth: <xsl:value-of select="@depth"/> +depth: <xsl:value-of select="$depth"/> +html.depth: <xsl:value-of select="$html.depth"/> +align: <xsl:value-of select="@align"/> +valign: <xsl:value-of select="@valign"/></xsl:message> +--> + + <xsl:variable name="scaled" + select="@width|@depth|@contentwidth|@contentdepth + |@scale|@scalefit"/> + + <xsl:variable name="img"> + <xsl:choose> + <xsl:when test="@format = 'SVG'"> + <object type="image/svg+xml"> + <xsl:attribute name="data"> + <xsl:choose> + <xsl:when test="$img.src.path != '' and + $tag = 'img' and + not(starts-with($output_filename, '/')) and + not(contains($output_filename, '://'))"> + <xsl:value-of select="$img.src.path"/> + </xsl:when> + </xsl:choose> + <xsl:value-of select="$output_filename"/> + </xsl:attribute> + <xsl:call-template name="process.image.attributes"> + <!--xsl:with-param name="alt" select="$alt"/ there's no alt here--> + <xsl:with-param name="html.depth" select="$html.depth"/> + <xsl:with-param name="html.width" select="$html.width"/> + <xsl:with-param name="longdesc" select="$longdesc"/> + <xsl:with-param name="scale" select="$scale"/> + <xsl:with-param name="scalefit" select="$scalefit"/> + <xsl:with-param name="scaled.contentdepth" select="$scaled.contentdepth"/> + <xsl:with-param name="scaled.contentwidth" select="$scaled.contentwidth"/> + <xsl:with-param name="viewport" select="$viewport"/> + </xsl:call-template> + <xsl:if test="@align"> + <xsl:attribute name="align"> + <xsl:choose> + <xsl:when test="@align = 'center'">middle</xsl:when> + <xsl:otherwise> + <xsl:value-of select="@align"/> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> + </xsl:if> + <xsl:if test="$use.embed.for.svg != 0"> + <embed type="image/svg+xml"> + <xsl:attribute name="src"> + <xsl:choose> + <xsl:when test="$img.src.path != '' and + $tag = 'img' and + not(starts-with($output_filename, '/')) and + not(contains($output_filename, '://'))"> + <xsl:value-of select="$img.src.path"/> + </xsl:when> + </xsl:choose> + <xsl:value-of select="$output_filename"/> + </xsl:attribute> + <xsl:call-template name="process.image.attributes"> + <!--xsl:with-param name="alt" select="$alt"/ there's no alt here --> + <xsl:with-param name="html.depth" select="$html.depth"/> + <xsl:with-param name="html.width" select="$html.width"/> + <xsl:with-param name="longdesc" select="$longdesc"/> + <xsl:with-param name="scale" select="$scale"/> + <xsl:with-param name="scalefit" select="$scalefit"/> + <xsl:with-param name="scaled.contentdepth" select="$scaled.contentdepth"/> + <xsl:with-param name="scaled.contentwidth" select="$scaled.contentwidth"/> + <xsl:with-param name="viewport" select="$viewport"/> + </xsl:call-template> + </embed> + </xsl:if> + </object> + </xsl:when> + <xsl:otherwise> + <xsl:element name="{$tag}"> + <xsl:if test="$tag = 'img' and ../../self::d:imageobjectco"> + <xsl:variable name="mapname"> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select="../../d:areaspec"/> + </xsl:call-template> + </xsl:variable> + <xsl:choose> + <xsl:when test="$scaled"> + <!-- It might be possible to handle some scaling; needs --> + <!-- more investigation --> + <xsl:message> + <xsl:text>Warning: imagemaps not supported </xsl:text> + <xsl:text>on scaled images</xsl:text> + </xsl:message> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="border">0</xsl:attribute> + <xsl:attribute name="usemap"> + <xsl:value-of select="concat('#', $mapname)"/> + </xsl:attribute> + </xsl:otherwise> + </xsl:choose> + </xsl:if> + + <xsl:attribute name="src"> + <xsl:choose> + <xsl:when test="$img.src.path != '' and + $tag = 'img' and + not(starts-with($output_filename, '/')) and + not(contains($output_filename, '://'))"> + <xsl:value-of select="$img.src.path"/> + </xsl:when> + </xsl:choose> + <xsl:value-of select="$output_filename"/> + </xsl:attribute> + + <xsl:if test="@align"> + <xsl:attribute name="align"> + <xsl:choose> + <xsl:when test="@align = 'center'">middle</xsl:when> + <xsl:otherwise> + <xsl:value-of select="@align"/> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> + </xsl:if> + + <xsl:call-template name="process.image.attributes"> + <xsl:with-param name="alt"> + <xsl:choose> + <xsl:when test="$alt != ''"> + <xsl:copy-of select="$alt"/> + </xsl:when> + <xsl:when test="ancestor::d:figure"> + <xsl:variable name="fig.title"> + <xsl:apply-templates select="ancestor::d:figure/d:title/node()"/> + </xsl:variable> + <xsl:value-of select="normalize-space($fig.title)"/> + </xsl:when> + </xsl:choose> + </xsl:with-param> + <xsl:with-param name="html.depth" select="$html.depth"/> + <xsl:with-param name="html.width" select="$html.width"/> + <xsl:with-param name="longdesc" select="$longdesc"/> + <xsl:with-param name="scale" select="$scale"/> + <xsl:with-param name="scalefit" select="$scalefit"/> + <xsl:with-param name="scaled.contentdepth" select="$scaled.contentdepth"/> + <xsl:with-param name="scaled.contentwidth" select="$scaled.contentwidth"/> + <xsl:with-param name="viewport" select="$viewport"/> + </xsl:call-template> + </xsl:element> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="bgcolor"> + <xsl:call-template name="pi.dbhtml_background-color"> + <xsl:with-param name="node" select=".."/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="use.viewport" + select="$viewport != 0 + and ($html.width != '' + or ($html.depth != '' and $depth-units != '%') + or $bgcolor != '' + or @valign)"/> + + <xsl:choose> + <xsl:when test="$use.viewport"> + <table border="{$table.border.off}"> + <xsl:if test="$div.element != 'section'"> + <xsl:attribute name="summary">manufactured viewport for HTML img</xsl:attribute> + </xsl:if> + <xsl:if test="$css.decoration != ''"> + <xsl:attribute name="style">cellpadding: 0; cellspacing: 0;</xsl:attribute> + </xsl:if> + <xsl:if test="$html.width != ''"> + <xsl:attribute name="width"> + <xsl:value-of select="$html.width"/> + </xsl:attribute> + </xsl:if> + <tr> + <xsl:if test="$html.depth != '' and $depth-units != '%'"> + <!-- don't do this for percentages because browsers get confused --> + <xsl:choose> + <xsl:when test="$css.decoration != 0"> + <xsl:attribute name="style"> + <xsl:text>height: </xsl:text> + <xsl:value-of select="$html.depth"/> + <xsl:text>px</xsl:text> + </xsl:attribute> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="height"> + <xsl:value-of select="$html.depth"/> + </xsl:attribute> + </xsl:otherwise> + </xsl:choose> + </xsl:if> + <td> + <xsl:if test="$bgcolor != ''"> + <xsl:choose> + <xsl:when test="$css.decoration != 0"> + <xsl:attribute name="style"> + <xsl:text>background-color: </xsl:text> + <xsl:value-of select="$bgcolor"/> + </xsl:attribute> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="bgcolor"> + <xsl:value-of select="$bgcolor"/> + </xsl:attribute> + </xsl:otherwise> + </xsl:choose> + </xsl:if> + <xsl:if test="@align"> + <xsl:attribute name="align"> + <xsl:value-of select="@align"/> + </xsl:attribute> + </xsl:if> + <xsl:if test="@valign"> + <xsl:attribute name="valign"> + <xsl:value-of select="@valign"/> + </xsl:attribute> + </xsl:if> + <xsl:copy-of select="$img"/> + </td> + </tr> + </table> + </xsl:when> + <xsl:otherwise> + <xsl:copy-of select="$img"/> + </xsl:otherwise> + </xsl:choose> + + <xsl:if test="$tag = 'img' and ../../self::d:imageobjectco and not($scaled)"> + <xsl:variable name="mapname"> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select="../../d:areaspec"/> + </xsl:call-template> + </xsl:variable> + + <map name="{$mapname}"> + <xsl:for-each select="../../d:areaspec//d:area"> + <xsl:variable name="units"> + <xsl:choose> + <xsl:when test="@units = 'other' and @otherunits"> + <xsl:value-of select="@otherunits"/> + </xsl:when> + <xsl:when test="@units"> + <xsl:value-of select="@units"/> + </xsl:when> + <!-- areaspec|areaset/area --> + <xsl:when test="../@units = 'other' and ../@otherunits"> + <xsl:value-of select="../@otherunits"/> + </xsl:when> + <xsl:when test="../@units"> + <xsl:value-of select="../@units"/> + </xsl:when> + <!-- areaspec/areaset/area --> + <xsl:when test="../../@units = 'other' and ../../@otherunits"> + <xsl:value-of select="../@otherunits"/> + </xsl:when> + <xsl:when test="../../@units"> + <xsl:value-of select="../../@units"/> + </xsl:when> + <xsl:otherwise>calspair</xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$units = 'calspair' or + $units = 'imagemap'"> + <xsl:variable name="coords" select="normalize-space(@coords)"/> + + <area shape="rect"> + <xsl:variable name="linkends"> + <xsl:choose> + <xsl:when test="@linkends"> + <xsl:value-of select="normalize-space(@linkends)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="normalize-space(../@linkends)"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="href"> + <xsl:choose> + <xsl:when test="@xlink:href"> + <xsl:value-of select="@xlink:href"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="../@xlink:href"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$linkends != ''"> + <xsl:variable name="linkend"> + <xsl:choose> + <xsl:when test="contains($linkends, ' ')"> + <xsl:value-of select="substring-before($linkends, ' ')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$linkends"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="target" select="key('id', $linkend)[1]"/> + + <xsl:if test="$target"> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select="$target"/> + </xsl:call-template> + </xsl:attribute> + </xsl:if> + </xsl:when> + <xsl:when test="$href != ''"> + <xsl:attribute name="href"> + <xsl:value-of select="$href"/> + </xsl:attribute> + </xsl:when> + </xsl:choose> + + <xsl:if test="d:alt"> + <xsl:attribute name="alt"> + <xsl:value-of select="d:alt[1]"/> + </xsl:attribute> + </xsl:if> + + <xsl:attribute name="coords"> + <xsl:choose> + <xsl:when test="$units = 'calspair'"> + + <xsl:variable name="p1" + select="substring-before($coords, ' ')"/> + <xsl:variable name="p2" + select="substring-after($coords, ' ')"/> + + <xsl:variable name="x1" select="substring-before($p1,',')"/> + <xsl:variable name="y1" select="substring-after($p1,',')"/> + <xsl:variable name="x2" select="substring-before($p2,',')"/> + <xsl:variable name="y2" select="substring-after($p2,',')"/> + + <xsl:variable name="x1p" select="$x1 div 100.0"/> + <xsl:variable name="y1p" select="$y1 div 100.0"/> + <xsl:variable name="x2p" select="$x2 div 100.0"/> + <xsl:variable name="y2p" select="$y2 div 100.0"/> + + <!-- + <xsl:message> + <xsl:text>units: </xsl:text> + <xsl:value-of select="$units"/> + <xsl:text> </xsl:text> + <xsl:value-of select="$x1p"/><xsl:text>, </xsl:text> + <xsl:value-of select="$y1p"/><xsl:text>, </xsl:text> + <xsl:value-of select="$x2p"/><xsl:text>, </xsl:text> + <xsl:value-of select="$y2p"/><xsl:text>, </xsl:text> + </xsl:message> + + <xsl:message> + <xsl:text> </xsl:text> + <xsl:value-of select="$intrinsicwidth"/> + <xsl:text>, </xsl:text> + <xsl:value-of select="$intrinsicdepth"/> + </xsl:message> + + <xsl:message> + <xsl:text> </xsl:text> + <xsl:value-of select="$units"/> + <xsl:text> </xsl:text> + <xsl:value-of + select="round($x1p * $intrinsicwidth div 100.0)"/> + <xsl:text>,</xsl:text> + <xsl:value-of select="round($intrinsicdepth + - ($y2p * $intrinsicdepth div 100.0))"/> + <xsl:text>,</xsl:text> + <xsl:value-of select="round($x2p * + $intrinsicwidth div 100.0)"/> + <xsl:text>,</xsl:text> + <xsl:value-of select="round($intrinsicdepth + - ($y1p * $intrinsicdepth div 100.0))"/> + </xsl:message> + --> + <xsl:value-of + select="round($x1p * $intrinsicwidth div 100.0)"/> + <xsl:text>,</xsl:text> + <xsl:value-of select="round($intrinsicdepth + - ($y2p * $intrinsicdepth div 100.0))"/> + <xsl:text>,</xsl:text> + <xsl:value-of + select="round($x2p * $intrinsicwidth div 100.0)"/> + <xsl:text>,</xsl:text> + <xsl:value-of select="round($intrinsicdepth + - ($y1p * $intrinsicdepth div 100.0))"/> + </xsl:when> + <xsl:otherwise> + <xsl:copy-of select="$coords"/> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> + </area> + </xsl:when> + <xsl:otherwise> + <xsl:message> + <xsl:text>Warning: only calspair or </xsl:text> + <xsl:text>otherunits='imagemap' supported </xsl:text> + <xsl:text>in imageobjectco</xsl:text> + </xsl:message> + </xsl:otherwise> + </xsl:choose> + </xsl:for-each> + </map> + </xsl:if> +</xsl:template> + +<xsl:template name="process.image.attributes"> + <xsl:param name="alt"/> + <xsl:param name="html.width"/> + <xsl:param name="html.depth"/> + <xsl:param name="longdesc"/> + <xsl:param name="scale"/> + <xsl:param name="scalefit"/> + <xsl:param name="scaled.contentdepth"/> + <xsl:param name="scaled.contentwidth"/> + <xsl:param name="viewport"/> + + <xsl:choose> + <xsl:when test="@contentwidth or @contentdepth"> + <!-- ignore @width/@depth, @scale, and @scalefit if specified --> + <xsl:if test="@contentwidth and $scaled.contentwidth != ''"> + <xsl:attribute name="width"> + <xsl:value-of select="$scaled.contentwidth"/> + </xsl:attribute> + </xsl:if> + <xsl:if test="@contentdepth and $scaled.contentdepth != ''"> + <xsl:attribute name="height"> + <xsl:value-of select="$scaled.contentdepth"/> + </xsl:attribute> + </xsl:if> + </xsl:when> + + <xsl:when test="number($scale) != 1.0"> + <!-- scaling is always uniform, so we only have to specify one dimension --> + <!-- ignore @scalefit if specified --> + <xsl:attribute name="width"> + <xsl:value-of select="$scaled.contentwidth"/> + </xsl:attribute> + </xsl:when> + + <xsl:when test="$scalefit != 0"> + <xsl:choose> + <xsl:when test="contains($html.width, '%')"> + <xsl:choose> + <xsl:when test="$viewport != 0"> + <!-- The *viewport* will be scaled, so use 100% here! --> + <xsl:attribute name="width"> + <xsl:value-of select="'100%'"/> + </xsl:attribute> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="width"> + <xsl:value-of select="$html.width"/> + </xsl:attribute> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + + <xsl:when test="contains($html.depth, '%')"> + <!-- HTML doesn't deal with this case very well...do nothing --> + </xsl:when> + + <xsl:when test="$scaled.contentwidth != '' and $html.width != '' + and $scaled.contentdepth != '' and $html.depth != ''"> + <!-- scalefit should not be anamorphic; figure out which direction --> + <!-- has the limiting scale factor and scale in that direction --> + <xsl:choose> + <xsl:when test="$html.width div $scaled.contentwidth > + $html.depth div $scaled.contentdepth"> + <xsl:attribute name="height"> + <xsl:value-of select="$html.depth"/> + </xsl:attribute> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="width"> + <xsl:value-of select="$html.width"/> + </xsl:attribute> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + + <xsl:when test="$scaled.contentwidth != '' and $html.width != ''"> + <xsl:attribute name="width"> + <xsl:value-of select="$html.width"/> + </xsl:attribute> + </xsl:when> + + <xsl:when test="$scaled.contentdepth != '' and $html.depth != ''"> + <xsl:attribute name="height"> + <xsl:value-of select="$html.depth"/> + </xsl:attribute> + </xsl:when> + </xsl:choose> + </xsl:when> + </xsl:choose> + + <xsl:if test="$alt != ''"> + <xsl:attribute name="alt"> + <xsl:value-of select="normalize-space($alt)"/> + </xsl:attribute> + </xsl:if> + + <!-- Turn off longdesc attribute since not supported by browsers + <xsl:if test="$longdesc != ''"> + <xsl:attribute name="longdesc"> + <xsl:value-of select="$longdesc"/> + </xsl:attribute> + </xsl:if> + --> + + <xsl:if test="@align and $viewport = 0"> + <xsl:attribute name="align"> + <xsl:choose> + <xsl:when test="@align = 'center'">middle</xsl:when> + <xsl:otherwise> + <xsl:value-of select="@align"/> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> + </xsl:if> + + <xsl:call-template name="extension.process.image.attributes"/> +</xsl:template> + +<xsl:template name="extension.process.image.attributes"/> + +<!-- ==================================================================== --> + +<xsl:template match="d:graphic"> + <xsl:choose> + <xsl:when test="parent::d:inlineequation"> + <span> + <xsl:call-template name="id.attribute"/> + <xsl:call-template name="anchor"/> + <xsl:call-template name="process.image"/> + </span> + </xsl:when> + <xsl:otherwise> + <div> + <xsl:call-template name="id.attribute"/> + <xsl:if test="@align"> + <xsl:attribute name="align"> + <xsl:value-of select="@align"/> + </xsl:attribute> + </xsl:if> + <xsl:call-template name="anchor"/> + <xsl:call-template name="process.image"/> + </div> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="d:inlinegraphic"> + <xsl:variable name="filename"> + <xsl:choose> + <xsl:when test="@entityref"> + <xsl:value-of select="unparsed-entity-uri(@entityref)"/> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="@fileref"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:call-template name="anchor"/> + + <xsl:choose> + <xsl:when test="@format='linespecific'"> + <xsl:choose> + <xsl:when test="$use.extensions != '0' + and $textinsert.extension != '0'"> + <xsl:choose> + <xsl:when test="element-available('stext:insertfile')"> + <stext:insertfile href="{$filename}" encoding="{$textdata.default.encoding}"/> + </xsl:when> + <xsl:when test="element-available('xtext:insertfile')"> + <xtext:insertfile href="{$filename}"/> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes"> + <xsl:text>No insertfile extension available.</xsl:text> + </xsl:message> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes"> + <xsl:text>Cannot insert </xsl:text><xsl:value-of select="$filename"/> + <xsl:text>. Check use.extensions and textinsert.extension parameters.</xsl:text> + </xsl:message> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="process.image"/> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="d:mediaobject|d:mediaobjectco"> + + <xsl:variable name="olist" select="d:imageobject|d:imageobjectco + |d:videoobject|d:audioobject + |d:textobject"/> + + <xsl:variable name="object.index"> + <xsl:call-template name="select.mediaobject.index"> + <xsl:with-param name="olist" select="$olist"/> + <xsl:with-param name="count" select="1"/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="object" select="$olist[position() = $object.index]"/> + + <xsl:variable name="align"> + <xsl:value-of select="$object/descendant::d:imagedata[@align][1]/@align"/> + </xsl:variable> + + <div> + <xsl:apply-templates select="." mode="common.html.attributes"/> + <xsl:if test="$align != '' "> + <xsl:attribute name="align"> + <xsl:value-of select="$align"/> + </xsl:attribute> + </xsl:if> + <xsl:call-template name="id.attribute"/> + <xsl:call-template name="anchor"/> + + <xsl:apply-templates select="$object"/> + <xsl:apply-templates select="d:caption"/> + </div> +</xsl:template> + +<xsl:template match="d:inlinemediaobject"> + <span> + <xsl:apply-templates select="." mode="common.html.attributes"/> + <xsl:call-template name="id.attribute"/> + <xsl:call-template name="anchor"/> + <xsl:call-template name="select.mediaobject"/> + </span> +</xsl:template> + +<xsl:template match="d:programlisting/d:inlinemediaobject + |d:screen/d:inlinemediaobject" priority="2"> + <!-- the additional span causes problems in some cases --> + <xsl:call-template name="select.mediaobject"/> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="d:imageobjectco"> + <xsl:call-template name="anchor"/> + <xsl:choose> + <!-- select one imageobject? --> + <xsl:when test="$use.role.for.mediaobject != 0 and + count(d:imageobject) > 1 and + d:imageobject[@role]"> + <xsl:variable name="olist" select="d:imageobject"/> + + <xsl:variable name="object.index"> + <xsl:call-template name="select.mediaobject.index"> + <xsl:with-param name="olist" select="$olist"/> + <xsl:with-param name="count" select="1"/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="object" select="$olist[position() = $object.index]"/> + + <xsl:apply-templates select="$object"/> + </xsl:when> + <xsl:otherwise> + <!-- otherwise process them all --> + <xsl:apply-templates select="d:imageobject"/> + </xsl:otherwise> + </xsl:choose> + + <xsl:apply-templates select="d:calloutlist"/> + +</xsl:template> + +<xsl:template match="d:imageobject"> + <xsl:apply-templates select="d:imagedata"/> +</xsl:template> + +<xsl:template match="d:imagedata"> + <xsl:apply-templates select="." mode="goik"/> + <xsl:variable name="filename"> + <xsl:call-template name="mediaobject.filename"> + <xsl:with-param name="object" select=".."/> + </xsl:call-template> + </xsl:variable> + + <xsl:choose> + <!-- Handle MathML and SVG markup in imagedata --> + <xsl:when test="mml:*" xmlns:mml="http://www.w3.org/1998/Math/MathML"> + <xsl:apply-templates/> + </xsl:when> + + <xsl:when test="svg:*" xmlns:svg="http://www.w3.org/2000/svg"> + <xsl:apply-templates/> + </xsl:when> + + <xsl:when test="@format='linespecific'"> + <xsl:choose> + <xsl:when test="$use.extensions != '0' + and $textinsert.extension != '0'"> + <xsl:choose> + <xsl:when test="element-available('stext:insertfile')"> + <stext:insertfile href="{$filename}" encoding="{$textdata.default.encoding}"/> + </xsl:when> + <xsl:when test="element-available('xtext:insertfile')"> + <xtext:insertfile href="{$filename}"/> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes"> + <xsl:text>No insertfile extension available.</xsl:text> + </xsl:message> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <a xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" + href="{$filename}"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:variable name="longdesc.uri"> + <xsl:call-template name="longdesc.uri"> + <xsl:with-param name="mediaobject" + select="ancestor::d:imageobject/parent::*"/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="phrases" + select="ancestor::d:mediaobject/d:textobject[d:phrase] + |ancestor::d:inlinemediaobject/d:textobject[d:phrase] + |ancestor::d:mediaobjectco/d:textobject[d:phrase]"/> + + <xsl:call-template name="process.image"> + <xsl:with-param name="alt"> + <xsl:choose> + <xsl:when test="ancestor::d:mediaobject/d:alt"> + <xsl:apply-templates select="ancestor::d:mediaobject/d:alt"/> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="$phrases[not(@role) or @role!='tex'][1]"/> + </xsl:otherwise> + </xsl:choose> + </xsl:with-param> + <xsl:with-param name="longdesc"> + <xsl:call-template name="write.longdesc"> + <xsl:with-param name="mediaobject" + select="ancestor::d:imageobject/parent::*"/> + </xsl:call-template> + </xsl:with-param> + </xsl:call-template> + + <xsl:if test="$html.longdesc != 0 and $html.longdesc.link != 0 + and ancestor::d:imageobject/parent::*/d:textobject[not(d:phrase)]"> + <xsl:call-template name="longdesc.link"> + <xsl:with-param name="longdesc.uri" select="$longdesc.uri"/> + </xsl:call-template> + </xsl:if> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template name="longdesc.uri"> + <xsl:param name="mediaobject" select="."/> + <xsl:if test="$html.longdesc"> + <xsl:if test="$mediaobject/d:textobject[not(d:phrase)]"> + <xsl:variable name="dbhtml.dir"> + <xsl:call-template name="dbhtml-dir"/> + </xsl:variable> + <xsl:variable name="filename"> + <xsl:call-template name="make-relative-filename"> + <xsl:with-param name="base.dir"> + <xsl:choose> + <xsl:when test="$dbhtml.dir != ''"> + <xsl:value-of select="$dbhtml.dir"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$chunk.base.dir"/> + </xsl:otherwise> + </xsl:choose> + </xsl:with-param> + <xsl:with-param name="base.name"> + <xsl:choose> + <xsl:when test=" + $mediaobject/@*[local-name() = 'id'] + and not($use.id.as.filename = 0)"> + <!-- * if this mediaobject has an ID, then we use the --> + <!-- * value of that ID as basename for the "longdesc" --> + <!-- * file (that is, without prepending an "ld-" too it) --> + <xsl:value-of select="$mediaobject/@*[local-name() = 'id']"/> + <xsl:value-of select="$html.ext"/> + </xsl:when> + <xsl:otherwise> + <!-- * otherwise, if this mediaobject does not have an --> + <!-- * ID, then we generate an ID... --> + <xsl:variable name="image-id"> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select="$mediaobject"/> + </xsl:call-template> + </xsl:variable> + <!-- * ...and then we take that generated ID, prepend an --> + <!-- * "ld-" to it, and use that as the basename for the file --> + <xsl:value-of select="concat('ld-',$image-id,$html.ext)"/> + </xsl:otherwise> + </xsl:choose> + </xsl:with-param> + </xsl:call-template> + </xsl:variable> + + <xsl:value-of select="$filename"/> + </xsl:if> + </xsl:if> +</xsl:template> + +<xsl:template name="write.longdesc"> + <xsl:param name="mediaobject" select="."/> + <xsl:if test="$html.longdesc != 0 and $mediaobject/d:textobject[not(d:phrase)]"> + <xsl:variable name="filename"> + <xsl:call-template name="longdesc.uri"> + <xsl:with-param name="mediaobject" select="$mediaobject"/> + </xsl:call-template> + </xsl:variable> + + <xsl:value-of select="$filename"/> + + <xsl:call-template name="write.chunk"> + <xsl:with-param name="filename" select="$filename"/> + <xsl:with-param name="quiet" select="$chunk.quietly"/> + <xsl:with-param name="content"> + <xsl:call-template name="user.preroot"/> + <html> + <head> + <xsl:call-template name="system.head.content"/> + <xsl:call-template name="head.content"> + <xsl:with-param name="title" select="'Long Description'"/> + </xsl:call-template> + <xsl:call-template name="user.head.content"/> + </head> + <body> + <xsl:call-template name="body.attributes"/> + <xsl:for-each select="$mediaobject/d:textobject[not(d:phrase)]"> + <xsl:apply-templates select="./*"/> + </xsl:for-each> + </body> + </html> + <xsl:value-of select="$chunk.append"/> + </xsl:with-param> + </xsl:call-template> + </xsl:if> +</xsl:template> + +<xsl:template name="longdesc.link"> + <xsl:param name="longdesc.uri" select="''"/> + + <xsl:variable name="this.uri"> + <xsl:call-template name="make-relative-filename"> + <xsl:with-param name="base.dir" select="$chunk.base.dir"/> + <xsl:with-param name="base.name"> + <xsl:call-template name="href.target.uri"/> + </xsl:with-param> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="href.to"> + <xsl:call-template name="trim.common.uri.paths"> + <xsl:with-param name="uriA" select="$longdesc.uri"/> + <xsl:with-param name="uriB" select="$this.uri"/> + <xsl:with-param name="return" select="'A'"/> + </xsl:call-template> + </xsl:variable> + + <div class="longdesc-link" align="{$direction.align.end}"> + <br clear="all"/> + <span class="longdesc-link"> + <xsl:text>[</xsl:text> + <a href="{$href.to}" target="longdesc">D</a> + <xsl:text>]</xsl:text> + </span> + </div> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="d:mediaobject/d:alt"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="d:videoobject"> + <xsl:apply-templates select="d:videodata"/> +</xsl:template> + +<xsl:template match="d:videodata"> + <video controls="controls" preload="auto"> + <xsl:attribute name="title"> + <xsl:value-of select="normalize-space(../../../d:title)"/> + </xsl:attribute> + + <xsl:variable name="hdm_ImageFilename"> <!-- hdm_ prefix: do not mess with docbook! --> + <xsl:call-template name="mediaobject.filename"> + <xsl:with-param name="object" select=".."/> + </xsl:call-template> + </xsl:variable> + + <source src="{$hdm_ImageFilename}" type='video/mp4' /> + <source src="{$hdm_ImageFilename}.ogv"/> + </video> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="d:audioobject"> + <xsl:apply-templates select="d:audiodata"/> +</xsl:template> + +<xsl:template match="d:audiodata"> + <xsl:call-template name="process.image"> + <xsl:with-param name="tag" select="'embed'"/> + <xsl:with-param name="alt"> + <xsl:choose> + <xsl:when test="ancestor::d:mediaobject/d:alt"> + <xsl:apply-templates select="ancestor::d:mediaobject/d:alt"/> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="(ancestor::d:mediaobject/d:textobject/d:phrase)[1]"/> + </xsl:otherwise> + </xsl:choose> + </xsl:with-param> + </xsl:call-template> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="d:textobject"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="d:textdata"> + <xsl:variable name="filename"> + <xsl:choose> + <xsl:when test="@entityref"> + <xsl:value-of select="unparsed-entity-uri(@entityref)"/> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="@fileref"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="encoding"> + <xsl:choose> + <xsl:when test="@encoding"> + <xsl:value-of select="@encoding"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$textdata.default.encoding"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$use.extensions != '0' + and $textinsert.extension != '0'"> + <xsl:choose> + <xsl:when test="element-available('stext:insertfile')"> + <stext:insertfile href="{$filename}" encoding="{$encoding}"/> + </xsl:when> + <xsl:when test="element-available('xtext:insertfile')"> + <xtext:insertfile href="{$filename}"/> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes"> + <xsl:text>No insertfile extension available.</xsl:text> + </xsl:message> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes"> + <xsl:text>Cannot insert </xsl:text><xsl:value-of select="$filename"/> + <xsl:text>. Check use.extensions and textinsert.extension parameters.</xsl:text> + </xsl:message> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="d:caption"> + <div> + <xsl:apply-templates select="." mode="common.html.attributes"/> + <xsl:call-template name="id.attribute"/> + <xsl:if test="@align = 'right' or @align = 'left' or @align='center'"> + <xsl:attribute name="align"><xsl:value-of + select="@align"/></xsl:attribute> + </xsl:if> + <xsl:apply-templates/> + </div> +</xsl:template> + +<!-- ==================================================================== --> +<!-- "Support" for SVG --> + +<xsl:template match="svg:*" xmlns:svg="http://www.w3.org/2000/svg"> + <xsl:copy> + <xsl:copy-of select="@*"/> + <xsl:apply-templates/> + </xsl:copy> +</xsl:template> + + +<!-- The following works sometimes, but needs to take into account + 1. When there is no /*/@xml:base + 2. When the chunks are going somewhere else +<xsl:variable name="relpath"> + <xsl:call-template name="relative-uri"> + <xsl:with-param name="filename" select="@fileref"/> + </xsl:call-template> +</xsl:variable> + +<xsl:choose> + <xsl:when test="/*/@xml:base + and starts-with($relpath,/*/@xml:base)"> + <xsl:value-of select="substring-after($relpath,/*/@xml:base)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="@fileref"/> + </xsl:otherwise> +</xsl:choose> +<xsl:value-of select="@fileref"/> + </xsl:when> +--> +<!-- Resolve xml:base attributes --> +<xsl:template match="@fileref"> + <!-- need a check for absolute urls --> + <xsl:choose> + <xsl:when test="contains(., ':')"> + <!-- it has a uri scheme so it is an absolute uri --> + <xsl:value-of select="."/> + </xsl:when> + <xsl:when test="$keep.relative.image.uris != 0"> + <!-- leave it alone --> + <xsl:value-of select="."/> + </xsl:when> + <xsl:otherwise> + <!-- its a relative uri that needs xml:base processing --> + <xsl:call-template name="relative-uri"> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +</xsl:stylesheet> diff --git a/ws/Docbook/Extensions/addon/config/docbook5/xsl/xhtml-1_1/formal.xsl b/ws/Docbook/Extensions/addon/config/docbook5/xsl/xhtml-1_1/formal.xsl new file mode 100644 index 0000000000000000000000000000000000000000..9947ec18f8e5ffd04903ef9df05d650c40e0680f --- /dev/null +++ b/ws/Docbook/Extensions/addon/config/docbook5/xsl/xhtml-1_1/formal.xsl @@ -0,0 +1,497 @@ +<?xml version="1.0" encoding="ASCII"?> +<!--This file was created automatically by html2xhtml--> +<!--from the HTML stylesheets.--> +<xsl:stylesheet exclude-result-prefixes="d" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:d="http://docbook.org/ns/docbook" +xmlns="http://www.w3.org/1999/xhtml" version="1.0"> + +<!-- ******************************************************************** + $Id: formal.xsl 9501 2012-07-16 00:14:50Z bobstayton $ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://docbook.sf.net/release/xsl/current/ for + copyright and other information. + + ******************************************************************** --> + +<xsl:include href="../common/hdmextensions.xsl"/> +<xsl:param name="formal.object.break.after">1</xsl:param> + +<xsl:template name="formal.object"> + <xsl:param name="placement" select="'before'"/> + <xsl:param name="class"> + <xsl:apply-templates select="." mode="class.value"/> + </xsl:param> + + <xsl:call-template name="id.warning"/> + + <xsl:variable name="content"> + <div class="{$class}"> + <xsl:call-template name="id.attribute"> + <xsl:with-param name="conditional" select="0"/> + </xsl:call-template> + <xsl:call-template name="anchor"> + <xsl:with-param name="conditional" select="0"/> + </xsl:call-template> + + <xsl:choose> + <xsl:when test="$placement = 'before'"> + <xsl:call-template name="formal.object.heading"/> + <div class="{$class}-contents"> + <xsl:apply-templates/> + </div> + <!-- HACK: This doesn't belong inside formal.object; it + should be done by the table template, but I want + the link to be inside the DIV, so... --> + <xsl:if test="local-name(.) = 'table'"> + <xsl:call-template name="table.longdesc"/> + </xsl:if> + + <xsl:if test="$spacing.paras != 0"><p/></xsl:if> + </xsl:when> + <xsl:otherwise> + <xsl:if test="$spacing.paras != 0"><p/></xsl:if> + <div class="{$class}-contents"><xsl:apply-templates/></div> + <!-- HACK: This doesn't belong inside formal.object; it + should be done by the table template, but I want + the link to be inside the DIV, so... --> + <xsl:if test="local-name(.) = 'table'"> + <xsl:call-template name="table.longdesc"/> + </xsl:if> + + <xsl:call-template name="formal.object.heading"/> + </xsl:otherwise> + </xsl:choose> + </div> + <xsl:if test="not($formal.object.break.after = '0')"> + <br class="{$class}-break"/> + </xsl:if> + </xsl:variable> + + <xsl:variable name="floatstyle"> + <xsl:call-template name="floatstyle"/> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$floatstyle != ''"> + <xsl:call-template name="floater"> + <xsl:with-param name="class"><xsl:value-of select="$class"/>-float</xsl:with-param> + <xsl:with-param name="floatstyle" select="$floatstyle"/> + <xsl:with-param name="content" select="$content"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:copy-of select="$content"/> + </xsl:otherwise> + </xsl:choose> + +</xsl:template> + +<xsl:template name="formal.object.heading"> + <xsl:param name="object" select="."/> + <xsl:param name="title"> + <xsl:apply-templates select="$object" mode="object.title.markup"> + <xsl:with-param name="allow-anchors" select="1"/> + </xsl:apply-templates> + </xsl:param> + + + <xsl:choose> + <xsl:when test="$make.clean.html != 0"> + <xsl:variable name="html.class" select="concat(local-name($object),'-title')"/> + <div class="{$html.class}"> + <xsl:copy-of select="$title"/> + </div> + </xsl:when> + <xsl:otherwise> + <p class="title"> + <strong xmlns:xslo="http://www.w3.org/1999/XSL/Transform"> + <xsl:copy-of select="$title"/> + </strong> + </p> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template name="informal.object"> + <xsl:param name="class"> + <xsl:apply-templates select="." mode="class.value"/> + </xsl:param> + + <xsl:variable name="content"> + <div class="{$class}"> + <xsl:call-template name="id.attribute"/> + <xsl:if test="$spacing.paras != 0"><p/></xsl:if> + <xsl:call-template name="anchor"/> + <xsl:apply-templates/> + + <!-- HACK: This doesn't belong inside formal.object; it + should be done by the table template, but I want + the link to be inside the DIV, so... --> + <xsl:if test="local-name(.) = 'informaltable'"> + <xsl:call-template name="table.longdesc"/> + </xsl:if> + + <xsl:if test="$spacing.paras != 0"><p/></xsl:if> + </div> + </xsl:variable> + + <xsl:variable name="floatstyle"> + <xsl:call-template name="floatstyle"/> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$floatstyle != ''"> + <xsl:call-template name="floater"> + <xsl:with-param name="class"><xsl:value-of select="$class"/>-float</xsl:with-param> + <xsl:with-param name="floatstyle" select="$floatstyle"/> + <xsl:with-param name="content" select="$content"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:copy-of select="$content"/> + </xsl:otherwise> + </xsl:choose> + +</xsl:template> + +<xsl:template name="semiformal.object"> + <xsl:param name="placement" select="'before'"/> + <xsl:param name="class" select="local-name(.)"/> + + <xsl:choose> + <xsl:when test="d:title or d:info/d:title"> + <xsl:call-template name="formal.object"> + <xsl:with-param name="placement" select="$placement"/> + <xsl:with-param name="class" select="$class"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="informal.object"> + <xsl:with-param name="class" select="$class"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="d:figure"> + <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement), concat(local-name(.), ' '))"/> + + <xsl:variable name="placement"> + <xsl:choose> + <xsl:when test="contains($param.placement, ' ')"> + <xsl:value-of select="substring-before($param.placement, ' ')"/> + </xsl:when> + <xsl:when test="$param.placement = ''">before</xsl:when> + <xsl:otherwise> + <xsl:value-of select="$param.placement"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:call-template name="formal.object"> + <xsl:with-param name="placement" select="$placement"/> + </xsl:call-template> + +</xsl:template> + +<xsl:template match="d:table"> + <xsl:choose> + <xsl:when test="d:tgroup|d:mediaobject|d:graphic"> + <xsl:call-template name="calsTable"/> + </xsl:when> + <xsl:when test="d:caption"> + <xsl:call-template name="htmlTable.with.caption"/> + </xsl:when> + <xsl:otherwise> + <!-- do not use xsl:copy because of XHTML's needs --> + <div> + <xsl:call-template name="generate.class.attribute"/> + <xsl:call-template name="id.attribute"/> + <xsl:call-template name="anchor"/> + <xsl:element name="table" namespace="http://www.w3.org/1999/xhtml"> + <xsl:apply-templates select="@*" mode="htmlTableAtt"/> + <xsl:call-template name="htmlTable"/> + </xsl:element> + </div> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<!-- Handle html markup table like formal.object --> +<xsl:template name="htmlTable.with.caption"> + <xsl:param name="class"> + <xsl:apply-templates select="." mode="class.value"/> + </xsl:param> + + <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement), concat(local-name(.), ' '))"/> + + <xsl:variable name="placement"> + <xsl:choose> + <xsl:when test="contains($param.placement, ' ')"> + <xsl:value-of select="substring-before($param.placement, ' ')"/> + </xsl:when> + <xsl:when test="$param.placement = ''">before</xsl:when> + <xsl:otherwise> + <xsl:value-of select="$param.placement"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:call-template name="id.warning"/> + + <xsl:variable name="content"> + <div class="{$class}"> + <xsl:call-template name="id.attribute"> + <xsl:with-param name="conditional" select="0"/> + </xsl:call-template> + <xsl:call-template name="anchor"> + <xsl:with-param name="conditional" select="0"/> + </xsl:call-template> + + <xsl:choose> + <xsl:when test="$placement = 'before'"> + + <xsl:call-template name="formal.object.heading"/> + + <div class="{$class}-contents"> + <xsl:apply-templates select="." mode="htmlTable"/> + </div> + + <xsl:call-template name="table.longdesc"/> + + <xsl:if test="$spacing.paras != 0"><p/></xsl:if> + </xsl:when> + <xsl:otherwise> + <xsl:if test="$spacing.paras != 0"><p/></xsl:if> + + <div class="{$class}-contents"> + <xsl:apply-templates select="." mode="htmlTable"/> + </div> + + <xsl:call-template name="table.longdesc"/> + + <xsl:call-template name="formal.object.heading"/> + </xsl:otherwise> + </xsl:choose> + </div> + <xsl:if test="not($formal.object.break.after = '0')"> + <br class="{$class}-break"/> + </xsl:if> + </xsl:variable> + + <xsl:variable name="floatstyle"> + <xsl:call-template name="floatstyle"/> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$floatstyle != ''"> + <xsl:call-template name="floater"> + <xsl:with-param name="class"><xsl:value-of select="$class"/>-float</xsl:with-param> + <xsl:with-param name="floatstyle" select="$floatstyle"/> + <xsl:with-param name="content" select="$content"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:copy-of select="$content"/> + </xsl:otherwise> + </xsl:choose> + +</xsl:template> + +<xsl:template name="calsTable"> + <xsl:if test="d:tgroup/d:tbody/d:tr |d:tgroup/d:thead/d:tr |d:tgroup/d:tfoot/d:tr"> + <xsl:message terminate="yes">Broken table: tr descendent of CALS Table.</xsl:message> + </xsl:if> + + <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement), concat(local-name(.), ' '))"/> + + <xsl:variable name="placement"> + <xsl:choose> + <xsl:when test="contains($param.placement, ' ')"> + <xsl:value-of select="substring-before($param.placement, ' ')"/> + </xsl:when> + <xsl:when test="$param.placement = ''">before</xsl:when> + <xsl:otherwise> + <xsl:value-of select="$param.placement"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:call-template name="formal.object"> + <xsl:with-param name="placement" select="$placement"/> + </xsl:call-template> +</xsl:template> + +<xsl:template match="d:table|d:informaltable" mode="class.value"> + <xsl:choose> + <xsl:when test="@tabstyle"> + <xsl:value-of select="@tabstyle"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="local-name(.)"/> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template name="htmlTable"> + <xsl:if test="d:tgroup/d:tbody/d:row |d:tgroup/d:thead/d:row |d:tgroup/d:tfoot/d:row"> + <xsl:message terminate="yes">Broken table: row descendent of HTML table.</xsl:message> + </xsl:if> + + <xsl:apply-templates mode="htmlTable"/> + + <xsl:if test=".//d:footnote|../d:title//d:footnote"> + <tbody class="footnotes"> + <tr> + <td colspan="50"> + <xsl:apply-templates select=".//d:footnote|../d:title//d:footnote" mode="table.footnote.mode"/> + </td> + </tr> + </tbody> + </xsl:if> +</xsl:template> + +<xsl:template match="d:example"> + <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement), concat(local-name(.), ' '))"/> + + <xsl:variable name="placement"> + <xsl:choose> + <xsl:when test="contains($param.placement, ' ')"> + <xsl:value-of select="substring-before($param.placement, ' ')"/> + </xsl:when> + <xsl:when test="$param.placement = ''">before</xsl:when> + <xsl:otherwise> + <xsl:value-of select="$param.placement"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:call-template name="formal.object"> + <xsl:with-param name="placement" select="$placement"/> + </xsl:call-template> + +</xsl:template> + +<xsl:template match="d:equation"> + <xsl:variable name="param.placement" select="substring-after(normalize-space($formal.title.placement), concat(local-name(.), ' '))"/> + + <xsl:variable name="placement"> + <xsl:choose> + <xsl:when test="contains($param.placement, ' ')"> + <xsl:value-of select="substring-before($param.placement, ' ')"/> + </xsl:when> + <xsl:when test="$param.placement = ''">before</xsl:when> + <xsl:otherwise> + <xsl:value-of select="$param.placement"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:call-template name="formal.object"> + <xsl:with-param name="placement" select="$placement"/> + </xsl:call-template> + +</xsl:template> + +<xsl:template match="d:figure/d:title"/> +<xsl:template match="d:figure/d:titleabbrev"/> +<xsl:template match="d:table/d:title"/> +<xsl:template match="d:table/d:titleabbrev"/> +<xsl:template match="d:table/d:textobject"/> +<xsl:template match="d:example/d:title"/> +<xsl:template match="d:example/d:titleabbrev"/> +<xsl:template match="d:equation/d:title"/> +<xsl:template match="d:equation/d:titleabbrev"/> + +<xsl:template match="d:informalfigure"> + <xsl:call-template name="informal.object"/> +</xsl:template> + +<xsl:template match="d:informalexample"> + <xsl:call-template name="informal.object"/> +</xsl:template> + +<xsl:template match="d:informaltable"> + <xsl:choose> + <xsl:when test="d:tgroup|d:mediaobject|d:graphic"> + <xsl:call-template name="informal.object"/> + </xsl:when> + <xsl:otherwise> + <div> + <xsl:call-template name="generate.class.attribute"/> + <xsl:call-template name="id.attribute"/> + <xsl:call-template name="anchor"/> + <xsl:element name="table" namespace="http://www.w3.org/1999/xhtml"> + <xsl:apply-templates select="@*" mode="htmlTableAtt"/> + <xsl:call-template name="htmlTable"/> + </xsl:element> + </div> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="d:informaltable/d:textobject"/> + +<xsl:template name="table.longdesc"> + <!-- HACK: This doesn't belong inside formal.objectt; it should be done by --> + <!-- the table template, but I want the link to be inside the DIV, so... --> + <xsl:variable name="longdesc.uri"> + <xsl:call-template name="longdesc.uri"> + <xsl:with-param name="mediaobject" select="."/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="irrelevant"> + <!-- write.longdesc returns the filename ... --> + <xsl:call-template name="write.longdesc"> + <xsl:with-param name="mediaobject" select="."/> + </xsl:call-template> + </xsl:variable> + + <xsl:if test="$html.longdesc != 0 and $html.longdesc.link != 0 and d:textobject[not(d:phrase)]"> + <xsl:call-template name="longdesc.link"> + <xsl:with-param name="longdesc.uri" select="$longdesc.uri"/> + </xsl:call-template> + </xsl:if> +</xsl:template> + +<xsl:template match="d:informalequation"> + <xsl:call-template name="informal.object"/> +</xsl:template> + +<xsl:template name="floatstyle"> + <xsl:if test="(@float and @float != '0') or @floatstyle != ''"> + <xsl:choose> + <xsl:when test="@floatstyle != ''"> + <xsl:value-of select="@floatstyle"/> + </xsl:when> + <xsl:when test="@float = '1'"> + <xsl:value-of select="$default.float.class"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="@float"/> + </xsl:otherwise> + </xsl:choose> + </xsl:if> +</xsl:template> + +<xsl:template name="floater"> + <xsl:param name="content"/> + <xsl:param name="class" select="'float'"/> + <xsl:param name="floatstyle" select="'left'"/> + + <div class="{$class}"> + <xsl:if test="$floatstyle = 'left' or $floatstyle = 'right'"> + <xsl:attribute name="style"> + <xsl:text>float: </xsl:text> + <xsl:value-of select="$floatstyle"/> + <xsl:text>;</xsl:text> + </xsl:attribute> + </xsl:if> + <xsl:copy-of select="$content"/> + </div> +</xsl:template> + +</xsl:stylesheet> diff --git a/ws/Docbook/Extensions/addon/config/docbook5/xsl/xhtml-1_1/graphics.xsl b/ws/Docbook/Extensions/addon/config/docbook5/xsl/xhtml-1_1/graphics.xsl new file mode 100644 index 0000000000000000000000000000000000000000..5c3ae44653da7263dd14cb490b789f9f6eebf38f --- /dev/null +++ b/ws/Docbook/Extensions/addon/config/docbook5/xsl/xhtml-1_1/graphics.xsl @@ -0,0 +1,1519 @@ +<?xml version="1.0" encoding="ASCII"?><!--This file was created automatically by html2xhtml--><!--from the HTML stylesheets.--><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:d="http://docbook.org/ns/docbook" +xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:stext="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.TextFactory" xmlns:simg="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.ImageIntrinsics" xmlns:ximg="xalan://com.nwalsh.xalan.ImageIntrinsics" xmlns:xtext="xalan://com.nwalsh.xalan.Text" xmlns:lxslt="http://xml.apache.org/xslt" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="xlink stext xtext lxslt simg ximg d" extension-element-prefixes="stext xtext" version="1.0"> + +<!-- ******************************************************************** + $Id: graphics.xsl 9710 2013-01-22 19:34:18Z bobstayton $ + ******************************************************************** + + This file is part of the XSL DocBook Stylesheet distribution. + See ../README or http://docbook.sf.net/release/xsl/current/ for + copyright and other information. + + Contributors: + Colin Paul Adams, <colin@colina.demon.co.uk> + + ******************************************************************** --> + +<lxslt:component prefix="xtext" elements="d:insertfile"/> +<lxslt:component prefix="ximg" functions="new getWidth getDepth"/> + +<!-- ==================================================================== --> +<!-- Graphic format tests for the HTML backend --> + +<xsl:template name="is.graphic.format"> + <xsl:param name="format"/> + <xsl:if test="$format = 'SVG' or $format = 'PNG' or $format = 'JPG' or $format = 'JPEG' or $format = 'linespecific' or $format = 'GIF' or $format = 'GIF87a' or $format = 'GIF89a' or $format = 'BMP'">1</xsl:if> +</xsl:template> + +<xsl:template name="is.graphic.extension"> + <xsl:param name="ext"/> + <xsl:variable name="lcext" select="translate($ext, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/> + <xsl:if test="$lcext = 'svg' or $lcext = 'png' or $lcext = 'jpeg' 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> + +<!-- ==================================================================== --> + +<xsl:template match="d:screenshot"> + <div> + <xsl:apply-templates select="." mode="common.html.attributes"/> + <xsl:call-template name="id.attribute"/> + <xsl:call-template name="anchor"/> + <xsl:apply-templates/> + </div> +</xsl:template> + +<xsl:template match="d:screenshot/d:title"> + <xsl:call-template name="formal.object.heading"> + <xsl:with-param name="object" select=".."/> + </xsl:call-template> +</xsl:template> + +<xsl:template match="d:screeninfo"> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template name="process.image"> + <!-- When this template is called, the current node should be --> + <!-- a graphic, inlinegraphic, imagedata, or videodata. All --> + <!-- those elements have the same set of attributes, so we can --> + <!-- handle them all in one place. --> + <xsl:param name="tag" select="'img'"/> + <xsl:param name="alt"/> + <xsl:param name="longdesc"/> + + <!-- The HTML img element only supports the notion of content-area + scaling; it doesn't support the distinction between a + content-area and a viewport-area, so we have to make some + compromises. + + 1. If only the content-area is specified, everything is fine. + (If you ask for a three inch image, that's what you'll get.) + + 2. If only the viewport-area is provided: + - If scalefit=1, treat it as both the content-area and + the viewport-area. (If you ask for an image in a five inch + area, we'll make the image five inches to fill that area.) + - If scalefit=0, ignore the viewport-area specification. + + Note: this is not quite the right semantic and has the additional + problem that it can result in anamorphic scaling, which scalefit + should never cause. + + 3. If both the content-area and the viewport-area is specified + on a graphic element, ignore the viewport-area. + (If you ask for a three inch image in a five inch area, we'll assume + it's better to give you a three inch image in an unspecified area + than a five inch image in a five inch area. + + Relative units also cause problems. As a general rule, the stylesheets + are operating too early and too loosely coupled with the rendering engine + to know things like the current font size or the actual dimensions of + an image. Therefore: + + 1. We use a fixed size for pixels, $pixels.per.inch + + 2. We use a fixed size for "em"s, $points.per.em + + Percentages are problematic. In the following discussion, we speak + of width and contentwidth, but the same issues apply to depth and + contentdepth + + 1. A width of 50% means "half of the available space for the image." + That's fine. But note that in HTML, this is a dynamic property and + the image size will vary if the browser window is resized. + + 2. A contentwidth of 50% means "half of the actual image width". But + the stylesheets have no way to assess the image's actual size. Treating + this as a width of 50% is one possibility, but it produces behavior + (dynamic scaling) that seems entirely out of character with the + meaning. + + Instead, the stylesheets define a $nominal.image.width + and convert percentages to actual values based on that nominal size. + + Scale can be problematic. Scale applies to the contentwidth, so + a scale of 50 when a contentwidth is not specified is analagous to a + width of 50%. (If a contentwidth is specified, the scaling factor can + be applied to that value and no problem exists.) + + If scale is specified but contentwidth is not supplied, the + nominal.image.width is used to calculate a base size + for scaling. + + Warning: as a consequence of these decisions, unless the aspect ratio + of your image happens to be exactly the same as (nominal width / nominal height), + specifying contentwidth="50%" and contentdepth="50%" is NOT going to + scale the way you expect (or really, the way it should). + + Don't do that. In fact, a percentage value is not recommended for content + size at all. Use scale instead. + + Finally, align and valign are troublesome. Horizontal alignment is now + supported by wrapping the image in a <div align="{@align}"> (in block + contexts!). I can't think of anything (practical) to do about vertical + alignment. + --> + + <xsl:variable name="width-units"> + <xsl:choose> + <xsl:when test="$ignore.image.scaling != 0"/> + <xsl:when test="@width"> + <xsl:call-template name="length-units"> + <xsl:with-param name="length" select="@width"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="not(@depth) and $default.image.width != ''"> + <xsl:call-template name="length-units"> + <xsl:with-param name="length" select="$default.image.width"/> + </xsl:call-template> + </xsl:when> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="width"> + <xsl:choose> + <xsl:when test="$ignore.image.scaling != 0"/> + <xsl:when test="@width"> + <xsl:choose> + <xsl:when test="$width-units = '%'"> + <xsl:value-of select="@width"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="length-spec"> + <xsl:with-param name="length" select="@width"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:when test="not(@depth) and $default.image.width != ''"> + <xsl:value-of select="$default.image.width"/> + </xsl:when> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="scalefit"> + <xsl:choose> + <xsl:when test="$ignore.image.scaling != 0">0</xsl:when> + <xsl:when test="@contentwidth or @contentdepth">0</xsl:when> + <xsl:when test="@scale">0</xsl:when> + <xsl:when test="@scalefit"><xsl:value-of select="@scalefit"/></xsl:when> + <xsl:when test="$width != '' or @depth">1</xsl:when> + <xsl:otherwise>0</xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="scale"> + <xsl:choose> + <xsl:when test="$ignore.image.scaling != 0">1.0</xsl:when> + <xsl:when test="@contentwidth or @contentdepth">1.0</xsl:when> + <xsl:when test="@scale"> + <xsl:value-of select="@scale div 100.0"/> + </xsl:when> + <xsl:otherwise>1.0</xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="filename"> + <xsl:choose> + <xsl:when test="local-name(.) = 'graphic' or local-name(.) = 'inlinegraphic'"> + <!-- handle legacy graphic and inlinegraphic by new template --> + <xsl:call-template name="mediaobject.filename"> + <xsl:with-param name="object" select="."/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <!-- imagedata, videodata, audiodata --> + <xsl:call-template name="mediaobject.filename"> + <xsl:with-param name="object" select=".."/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="output_filename"> + <xsl:choose> + <xsl:when test="@entityref"> + <xsl:value-of select="$filename"/> + </xsl:when> + <!-- + Moved test for $keep.relative.image.uris to template below: + <xsl:template match="@fileref"> + --> + <xsl:otherwise> + <xsl:value-of select="$filename"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="img.src.path.pi"> + <xsl:call-template name="pi.dbhtml_img.src.path"> + <xsl:with-param name="node" select=".."/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="filename.for.graphicsize"> + <xsl:choose> + <xsl:when test="$img.src.path.pi != ''"> + <xsl:value-of select="concat($img.src.path.pi, $filename)"/> + </xsl:when> + <xsl:when test="$img.src.path != '' and $graphicsize.use.img.src.path != 0 and $tag = 'img' and not(starts-with($filename, '/')) and not(contains($filename, '://'))"> + <xsl:value-of select="concat($img.src.path, $filename)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$filename"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="realintrinsicwidth"> + <!-- This funny compound test works around a bug in XSLTC --> + <xsl:choose> + <xsl:when test="$use.extensions != 0 and $graphicsize.extension != 0 and not(@format='SVG')"> + <xsl:choose> + <xsl:when test="function-available('simg:getWidth')"> + <xsl:value-of select="simg:getWidth(simg:new($filename.for.graphicsize), $nominal.image.width)"/> + </xsl:when> + <xsl:when test="function-available('ximg:getWidth')"> + <xsl:value-of select="ximg:getWidth(ximg:new($filename.for.graphicsize), $nominal.image.width)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="0"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="0"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="intrinsicwidth"> + <xsl:choose> + <xsl:when test="$realintrinsicwidth = 0"> + <xsl:value-of select="$nominal.image.width"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$realintrinsicwidth"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="intrinsicdepth"> + <!-- This funny compound test works around a bug in XSLTC --> + <xsl:choose> + <xsl:when test="$use.extensions != 0 and $graphicsize.extension != 0 and not(@format='SVG')"> + <xsl:choose> + <xsl:when test="function-available('simg:getDepth')"> + <xsl:value-of select="simg:getDepth(simg:new($filename.for.graphicsize), $nominal.image.depth)"/> + </xsl:when> + <xsl:when test="function-available('ximg:getDepth')"> + <xsl:value-of select="ximg:getDepth(ximg:new($filename.for.graphicsize), $nominal.image.depth)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$nominal.image.depth"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$nominal.image.depth"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="contentwidth"> + <xsl:choose> + <xsl:when test="$ignore.image.scaling != 0"/> + <xsl:when test="@contentwidth"> + <xsl:variable name="units"> + <xsl:call-template name="length-units"> + <xsl:with-param name="length" select="@contentwidth"/> + </xsl:call-template> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$units = '%'"> + <xsl:variable name="cmagnitude"> + <xsl:call-template name="length-magnitude"> + <xsl:with-param name="length" select="@contentwidth"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="$intrinsicwidth * $cmagnitude div 100.0"/> + <xsl:text>px</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="length-spec"> + <xsl:with-param name="length" select="@contentwidth"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$intrinsicwidth"/> + <xsl:text>px</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="scaled.contentwidth"> + <xsl:if test="$contentwidth != ''"> + <xsl:variable name="cwidth.in.points"> + <xsl:call-template name="length-in-points"> + <xsl:with-param name="length" select="$contentwidth"/> + <xsl:with-param name="pixels.per.inch" select="$pixels.per.inch"/> + <xsl:with-param name="em.size" select="$points.per.em"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="round($cwidth.in.points div 72.0 * $pixels.per.inch * $scale)"/> + </xsl:if> + </xsl:variable> + + <xsl:variable name="html.width"> + <xsl:choose> + <xsl:when test="$ignore.image.scaling != 0"/> + <xsl:when test="$width-units = '%'"> + <xsl:value-of select="$width"/> + </xsl:when> + <xsl:when test="$width != ''"> + <xsl:variable name="width.in.points"> + <xsl:call-template name="length-in-points"> + <xsl:with-param name="length" select="$width"/> + <xsl:with-param name="pixels.per.inch" select="$pixels.per.inch"/> + <xsl:with-param name="em.size" select="$points.per.em"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="round($width.in.points div 72.0 * $pixels.per.inch)"/> + </xsl:when> + <xsl:otherwise/> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="contentdepth"> + <xsl:choose> + <xsl:when test="$ignore.image.scaling != 0"/> + <xsl:when test="@contentdepth"> + <xsl:variable name="units"> + <xsl:call-template name="length-units"> + <xsl:with-param name="length" select="@contentdepth"/> + </xsl:call-template> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$units = '%'"> + <xsl:variable name="cmagnitude"> + <xsl:call-template name="length-magnitude"> + <xsl:with-param name="length" select="@contentdepth"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="$intrinsicdepth * $cmagnitude div 100.0"/> + <xsl:text>px</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="length-spec"> + <xsl:with-param name="length" select="@contentdepth"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$intrinsicdepth"/> + <xsl:text>px</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="scaled.contentdepth"> + <xsl:if test="$contentdepth != ''"> + <xsl:variable name="cdepth.in.points"> + <xsl:call-template name="length-in-points"> + <xsl:with-param name="length" select="$contentdepth"/> + <xsl:with-param name="pixels.per.inch" select="$pixels.per.inch"/> + <xsl:with-param name="em.size" select="$points.per.em"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="round($cdepth.in.points div 72.0 * $pixels.per.inch * $scale)"/> + </xsl:if> + </xsl:variable> + + <xsl:variable name="depth-units"> + <xsl:if test="@depth"> + <xsl:call-template name="length-units"> + <xsl:with-param name="length" select="@depth"/> + </xsl:call-template> + </xsl:if> + </xsl:variable> + + <xsl:variable name="depth"> + <xsl:if test="@depth"> + <xsl:choose> + <xsl:when test="$depth-units = '%'"> + <xsl:value-of select="@depth"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="length-spec"> + <xsl:with-param name="length" select="@depth"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:if> + </xsl:variable> + + <xsl:variable name="html.depth"> + <xsl:choose> + <xsl:when test="$ignore.image.scaling != 0"/> + <xsl:when test="$depth-units = '%'"> + <xsl:value-of select="$depth"/> + </xsl:when> + <xsl:when test="@depth and @depth != ''"> + <xsl:variable name="depth.in.points"> + <xsl:call-template name="length-in-points"> + <xsl:with-param name="length" select="$depth"/> + <xsl:with-param name="pixels.per.inch" select="$pixels.per.inch"/> + <xsl:with-param name="em.size" select="$points.per.em"/> + </xsl:call-template> + </xsl:variable> + <xsl:value-of select="round($depth.in.points div 72.0 * $pixels.per.inch)"/> + </xsl:when> + <xsl:otherwise/> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="viewport"> + <xsl:choose> + <xsl:when test="$ignore.image.scaling != 0">0</xsl:when> + <xsl:when test="local-name(.) = 'inlinegraphic' or ancestor::d:inlinemediaobject or ancestor::d:inlineequation">0</xsl:when> + <xsl:otherwise> + <xsl:value-of select="$make.graphic.viewport"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + +<!-- + <xsl:message>===================================== +scale: <xsl:value-of select="$scale"/>, <xsl:value-of select="$scalefit"/> +@contentwidth <xsl:value-of select="@contentwidth"/> +$contentwidth <xsl:value-of select="$contentwidth"/> +scaled.contentwidth: <xsl:value-of select="$scaled.contentwidth"/> +@width: <xsl:value-of select="@width"/> +width: <xsl:value-of select="$width"/> +html.width: <xsl:value-of select="$html.width"/> +@contentdepth <xsl:value-of select="@contentdepth"/> +$contentdepth <xsl:value-of select="$contentdepth"/> +scaled.contentdepth: <xsl:value-of select="$scaled.contentdepth"/> +@depth: <xsl:value-of select="@depth"/> +depth: <xsl:value-of select="$depth"/> +html.depth: <xsl:value-of select="$html.depth"/> +align: <xsl:value-of select="@align"/> +valign: <xsl:value-of select="@valign"/></xsl:message> +--> + + <xsl:variable name="scaled" select="@width|@depth|@contentwidth|@contentdepth |@scale|@scalefit"/> + + <xsl:variable name="img"> + <xsl:choose> + <xsl:when test="@format = 'SVG'"> + <object type="image/svg+xml"> + <xsl:attribute name="data"> + <xsl:choose> + <xsl:when test="$img.src.path != '' and $tag = 'img' and not(starts-with($output_filename, '/')) and not(contains($output_filename, '://'))"> + <xsl:value-of select="$img.src.path"/> + </xsl:when> + </xsl:choose> + <xsl:value-of select="$output_filename"/> + </xsl:attribute> + <xsl:call-template name="process.image.attributes"> + <!--xsl:with-param name="alt" select="$alt"/ there's no alt here--> + <xsl:with-param name="html.depth" select="$html.depth"/> + <xsl:with-param name="html.width" select="$html.width"/> + <xsl:with-param name="longdesc" select="$longdesc"/> + <xsl:with-param name="scale" select="$scale"/> + <xsl:with-param name="scalefit" select="$scalefit"/> + <xsl:with-param name="scaled.contentdepth" select="$scaled.contentdepth"/> + <xsl:with-param name="scaled.contentwidth" select="$scaled.contentwidth"/> + <xsl:with-param name="viewport" select="$viewport"/> + </xsl:call-template> + <xsl:if test="@align"> + <xsl:attribute name="style"><xsl:text>text-align: </xsl:text> + <xsl:choose> + <xsl:when test="@align = 'center'">middle</xsl:when> + <xsl:otherwise> + <xsl:value-of select="@align"/> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> + </xsl:if> + <xsl:if test="$use.embed.for.svg != 0"> + <embed type="image/svg+xml"> + <xsl:attribute name="src"> + <xsl:choose> + <xsl:when test="$img.src.path != '' and $tag = 'img' and not(starts-with($output_filename, '/')) and not(contains($output_filename, '://'))"> + <xsl:value-of select="$img.src.path"/> + </xsl:when> + </xsl:choose> + <xsl:value-of select="$output_filename"/> + </xsl:attribute> + <xsl:call-template name="process.image.attributes"> + <!--xsl:with-param name="alt" select="$alt"/ there's no alt here --> + <xsl:with-param name="html.depth" select="$html.depth"/> + <xsl:with-param name="html.width" select="$html.width"/> + <xsl:with-param name="longdesc" select="$longdesc"/> + <xsl:with-param name="scale" select="$scale"/> + <xsl:with-param name="scalefit" select="$scalefit"/> + <xsl:with-param name="scaled.contentdepth" select="$scaled.contentdepth"/> + <xsl:with-param name="scaled.contentwidth" select="$scaled.contentwidth"/> + <xsl:with-param name="viewport" select="$viewport"/> + </xsl:call-template> + </embed> + </xsl:if> + </object> + </xsl:when> + <xsl:otherwise> + <xsl:element name="{$tag}" namespace="http://www.w3.org/1999/xhtml"> + <xsl:if test="$tag = 'img' and ../../self::d:imageobjectco"> + <xsl:variable name="mapname"> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select="../../d:areaspec"/> + </xsl:call-template> + </xsl:variable> + <xsl:choose> + <xsl:when test="$scaled"> + <!-- It might be possible to handle some scaling; needs --> + <!-- more investigation --> + <xsl:message> + <xsl:text>Warning: imagemaps not supported </xsl:text> + <xsl:text>on scaled images</xsl:text> + </xsl:message> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="border">0</xsl:attribute> + <xsl:attribute name="usemap"> + <xsl:value-of select="concat('#', $mapname)"/> + </xsl:attribute> + </xsl:otherwise> + </xsl:choose> + </xsl:if> + + <xsl:attribute name="src"> + <xsl:choose> + <xsl:when test="$img.src.path != '' and $tag = 'img' and not(starts-with($output_filename, '/')) and not(contains($output_filename, '://'))"> + <xsl:value-of select="$img.src.path"/> + </xsl:when> + </xsl:choose> + <xsl:value-of select="$output_filename"/> + </xsl:attribute> + + <xsl:if test="@align"> + <xsl:attribute name="style"><xsl:text>text-align: </xsl:text> + <xsl:choose> + <xsl:when test="@align = 'center'">middle</xsl:when> + <xsl:otherwise> + <xsl:value-of select="@align"/> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> + </xsl:if> + + <xsl:call-template name="process.image.attributes"> + <xsl:with-param name="alt"> + <xsl:choose> + <xsl:when test="$alt != ''"> + <xsl:copy-of select="$alt"/> + </xsl:when> + <xsl:when test="ancestor::d:figure"> + <xsl:variable name="fig.title"> + <xsl:apply-templates select="ancestor::d:figure/d:title/node()"/> + </xsl:variable> + <xsl:value-of select="normalize-space($fig.title)"/> + </xsl:when> + <xsl:otherwise> + <!-- alt is a required attribute --> + <xsl:call-template name="filename-basename"> + <xsl:with-param name="filename" select="$output_filename"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:with-param> + <xsl:with-param name="html.depth" select="$html.depth"/> + <xsl:with-param name="html.width" select="$html.width"/> + <xsl:with-param name="longdesc" select="$longdesc"/> + <xsl:with-param name="scale" select="$scale"/> + <xsl:with-param name="scalefit" select="$scalefit"/> + <xsl:with-param name="scaled.contentdepth" select="$scaled.contentdepth"/> + <xsl:with-param name="scaled.contentwidth" select="$scaled.contentwidth"/> + <xsl:with-param name="viewport" select="$viewport"/> + </xsl:call-template> + </xsl:element> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="bgcolor"> + <xsl:call-template name="pi.dbhtml_background-color"> + <xsl:with-param name="node" select=".."/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="use.viewport" select="0"/> + + <xsl:choose> + <xsl:when test="$use.viewport"> + <table border="{$table.border.off}"> + <xsl:if test="$div.element != 'section'"> + <xsl:attribute name="summary">manufactured viewport for HTML img</xsl:attribute> + </xsl:if> + <xsl:if test="$css.decoration != ''"> + <xsl:attribute name="style">cellpadding: 0; cellspacing: 0;</xsl:attribute> + </xsl:if> + <xsl:if test="$html.width != ''"> + <xsl:attribute name="width"> + <xsl:value-of select="$html.width"/> + </xsl:attribute> + </xsl:if> + <tr> + <xsl:if test="$html.depth != '' and $depth-units != '%'"> + <!-- don't do this for percentages because browsers get confused --> + <xsl:choose> + <xsl:when test="$css.decoration != 0"> + <xsl:attribute name="style"> + <xsl:text>height: </xsl:text> + <xsl:value-of select="$html.depth"/> + <xsl:text>px</xsl:text> + </xsl:attribute> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="height"> + <xsl:value-of select="$html.depth"/> + </xsl:attribute> + </xsl:otherwise> + </xsl:choose> + </xsl:if> + <td> + <xsl:if test="$bgcolor != ''"> + <xsl:choose> + <xsl:when test="$css.decoration != 0"> + <xsl:attribute name="style"> + <xsl:text>background-color: </xsl:text> + <xsl:value-of select="$bgcolor"/> + </xsl:attribute> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="style"><xsl:text>background-color: </xsl:text> + <xsl:value-of select="$bgcolor"/> + </xsl:attribute> + </xsl:otherwise> + </xsl:choose> + </xsl:if> + <xsl:if test="@align"> + <xsl:attribute name="style"><xsl:text>text-align: </xsl:text> + <xsl:value-of select="@align"/> + </xsl:attribute> + </xsl:if> + <xsl:if test="@valign"> + <xsl:attribute name="valign"> + <xsl:value-of select="@valign"/> + </xsl:attribute> + </xsl:if> + <xsl:copy-of select="$img"/> + </td> + </tr> + </table> + </xsl:when> + <xsl:otherwise> + <xsl:copy-of select="$img"/> + </xsl:otherwise> + </xsl:choose> + + <xsl:if test="$tag = 'img' and ../../self::d:imageobjectco and not($scaled)"> + <xsl:variable name="mapname"> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select="../../d:areaspec"/> + </xsl:call-template> + </xsl:variable> + + <map name="{$mapname}"> + <xsl:for-each select="../../d:areaspec//d:area"> + <xsl:variable name="units"> + <xsl:choose> + <xsl:when test="@units = 'other' and @otherunits"> + <xsl:value-of select="@otherunits"/> + </xsl:when> + <xsl:when test="@units"> + <xsl:value-of select="@units"/> + </xsl:when> + <!-- areaspec|areaset/area --> + <xsl:when test="../@units = 'other' and ../@otherunits"> + <xsl:value-of select="../@otherunits"/> + </xsl:when> + <xsl:when test="../@units"> + <xsl:value-of select="../@units"/> + </xsl:when> + <!-- areaspec/areaset/area --> + <xsl:when test="../../@units = 'other' and ../../@otherunits"> + <xsl:value-of select="../@otherunits"/> + </xsl:when> + <xsl:when test="../../@units"> + <xsl:value-of select="../../@units"/> + </xsl:when> + <xsl:otherwise>calspair</xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$units = 'calspair' or $units = 'imagemap'"> + <xsl:variable name="coords" select="normalize-space(@coords)"/> + + <area shape="rect"> + <xsl:variable name="linkends"> + <xsl:choose> + <xsl:when test="@linkends"> + <xsl:value-of select="normalize-space(@linkends)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="normalize-space(../@linkends)"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="href"> + <xsl:choose> + <xsl:when test="@xlink:href"> + <xsl:value-of select="@xlink:href"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="../@xlink:href"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$linkends != ''"> + <xsl:variable name="linkend"> + <xsl:choose> + <xsl:when test="contains($linkends, ' ')"> + <xsl:value-of select="substring-before($linkends, ' ')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$linkends"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="target" select="key('id', $linkend)[1]"/> + + <xsl:if test="$target"> + <xsl:attribute name="href"> + <xsl:call-template name="href.target"> + <xsl:with-param name="object" select="$target"/> + </xsl:call-template> + </xsl:attribute> + </xsl:if> + </xsl:when> + <xsl:when test="$href != ''"> + <xsl:attribute name="href"> + <xsl:value-of select="$href"/> + </xsl:attribute> + </xsl:when> + </xsl:choose> + + <xsl:if test="d:alt"> + <xsl:attribute name="alt"> + <xsl:value-of select="d:alt[1]"/> + </xsl:attribute> + </xsl:if> + + <xsl:attribute name="coords"> + <xsl:choose> + <xsl:when test="$units = 'calspair'"> + + <xsl:variable name="p1" select="substring-before($coords, ' ')"/> + <xsl:variable name="p2" select="substring-after($coords, ' ')"/> + + <xsl:variable name="x1" select="substring-before($p1,',')"/> + <xsl:variable name="y1" select="substring-after($p1,',')"/> + <xsl:variable name="x2" select="substring-before($p2,',')"/> + <xsl:variable name="y2" select="substring-after($p2,',')"/> + + <xsl:variable name="x1p" select="$x1 div 100.0"/> + <xsl:variable name="y1p" select="$y1 div 100.0"/> + <xsl:variable name="x2p" select="$x2 div 100.0"/> + <xsl:variable name="y2p" select="$y2 div 100.0"/> + + <!-- + <xsl:message> + <xsl:text>units: </xsl:text> + <xsl:value-of select="$units"/> + <xsl:text> </xsl:text> + <xsl:value-of select="$x1p"/><xsl:text>, </xsl:text> + <xsl:value-of select="$y1p"/><xsl:text>, </xsl:text> + <xsl:value-of select="$x2p"/><xsl:text>, </xsl:text> + <xsl:value-of select="$y2p"/><xsl:text>, </xsl:text> + </xsl:message> + + <xsl:message> + <xsl:text> </xsl:text> + <xsl:value-of select="$intrinsicwidth"/> + <xsl:text>, </xsl:text> + <xsl:value-of select="$intrinsicdepth"/> + </xsl:message> + + <xsl:message> + <xsl:text> </xsl:text> + <xsl:value-of select="$units"/> + <xsl:text> </xsl:text> + <xsl:value-of + select="round($x1p * $intrinsicwidth div 100.0)"/> + <xsl:text>,</xsl:text> + <xsl:value-of select="round($intrinsicdepth + - ($y2p * $intrinsicdepth div 100.0))"/> + <xsl:text>,</xsl:text> + <xsl:value-of select="round($x2p * + $intrinsicwidth div 100.0)"/> + <xsl:text>,</xsl:text> + <xsl:value-of select="round($intrinsicdepth + - ($y1p * $intrinsicdepth div 100.0))"/> + </xsl:message> + --> + <xsl:value-of select="round($x1p * $intrinsicwidth div 100.0)"/> + <xsl:text>,</xsl:text> + <xsl:value-of select="round($intrinsicdepth - ($y2p * $intrinsicdepth div 100.0))"/> + <xsl:text>,</xsl:text> + <xsl:value-of select="round($x2p * $intrinsicwidth div 100.0)"/> + <xsl:text>,</xsl:text> + <xsl:value-of select="round($intrinsicdepth - ($y1p * $intrinsicdepth div 100.0))"/> + </xsl:when> + <xsl:otherwise> + <xsl:copy-of select="$coords"/> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> + </area> + </xsl:when> + <xsl:otherwise> + <xsl:message> + <xsl:text>Warning: only calspair or </xsl:text> + <xsl:text>otherunits='imagemap' supported </xsl:text> + <xsl:text>in imageobjectco</xsl:text> + </xsl:message> + </xsl:otherwise> + </xsl:choose> + </xsl:for-each> + </map> + </xsl:if> +</xsl:template> + +<xsl:template name="process.image.attributes"> + <xsl:param name="alt"/> + <xsl:param name="html.width"/> + <xsl:param name="html.depth"/> + <xsl:param name="longdesc"/> + <xsl:param name="scale"/> + <xsl:param name="scalefit"/> + <xsl:param name="scaled.contentdepth"/> + <xsl:param name="scaled.contentwidth"/> + <xsl:param name="viewport"/> + + <xsl:choose> + <xsl:when test="@contentwidth or @contentdepth"> + <!-- ignore @width/@depth, @scale, and @scalefit if specified --> + <xsl:if test="@contentwidth and $scaled.contentwidth != ''"> + <xsl:attribute name="width"> + <xsl:value-of select="$scaled.contentwidth"/> + </xsl:attribute> + </xsl:if> + <xsl:if test="@contentdepth and $scaled.contentdepth != ''"> + <xsl:attribute name="height"> + <xsl:value-of select="$scaled.contentdepth"/> + </xsl:attribute> + </xsl:if> + </xsl:when> + + <xsl:when test="number($scale) != 1.0"> + <!-- scaling is always uniform, so we only have to specify one dimension --> + <!-- ignore @scalefit if specified --> + <xsl:attribute name="width"> + <xsl:value-of select="$scaled.contentwidth"/> + </xsl:attribute> + </xsl:when> + + <xsl:when test="$scalefit != 0"> + <xsl:choose> + <xsl:when test="contains($html.width, '%')"> + <xsl:choose> + <xsl:when test="$viewport != 0"> + <!-- The *viewport* will be scaled, so use 100% here! --> + <xsl:attribute name="width"> + <xsl:value-of select="'100%'"/> + </xsl:attribute> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="width"> + <xsl:value-of select="$html.width"/> + </xsl:attribute> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + + <xsl:when test="contains($html.depth, '%')"> + <!-- HTML doesn't deal with this case very well...do nothing --> + </xsl:when> + + <xsl:when test="$scaled.contentwidth != '' and $html.width != '' and $scaled.contentdepth != '' and $html.depth != ''"> + <!-- scalefit should not be anamorphic; figure out which direction --> + <!-- has the limiting scale factor and scale in that direction --> + <xsl:choose> + <xsl:when test="$html.width div $scaled.contentwidth > $html.depth div $scaled.contentdepth"> + <xsl:attribute name="height"> + <xsl:value-of select="$html.depth"/> + </xsl:attribute> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="width"> + <xsl:value-of select="$html.width"/> + </xsl:attribute> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + + <xsl:when test="$scaled.contentwidth != '' and $html.width != ''"> + <xsl:attribute name="width"> + <xsl:value-of select="$html.width"/> + </xsl:attribute> + </xsl:when> + + <xsl:when test="$scaled.contentdepth != '' and $html.depth != ''"> + <xsl:attribute name="height"> + <xsl:value-of select="$html.depth"/> + </xsl:attribute> + </xsl:when> + </xsl:choose> + </xsl:when> + </xsl:choose> + + <xsl:if test="$alt != ''"> + <xsl:attribute name="alt"> + <xsl:value-of select="normalize-space($alt)"/> + </xsl:attribute> + </xsl:if> + + <!-- Turn off longdesc attribute since not supported by browsers + <xsl:if test="$longdesc != ''"> + <xsl:attribute name="longdesc"> + <xsl:value-of select="$longdesc"/> + </xsl:attribute> + </xsl:if> + --> + + <xsl:if test="@align and $viewport = 0"> + <xsl:attribute name="style"><xsl:text>text-align: </xsl:text> + <xsl:choose> + <xsl:when test="@align = 'center'">middle</xsl:when> + <xsl:otherwise> + <xsl:value-of select="@align"/> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> + </xsl:if> + + <xsl:call-template name="extension.process.image.attributes"/> +</xsl:template> + +<xsl:template name="extension.process.image.attributes"/> + +<!-- ==================================================================== --> + +<xsl:template match="d:graphic"> + <xsl:choose> + <xsl:when test="parent::d:inlineequation"> + <span> + <xsl:call-template name="id.attribute"/> + <xsl:call-template name="anchor"/> + <xsl:call-template name="process.image"/> + </span> + </xsl:when> + <xsl:otherwise> + <div> + <xsl:call-template name="id.attribute"/> + <xsl:if test="@align"> + <xsl:attribute name="style"><xsl:text>text-align: </xsl:text> + <xsl:value-of select="@align"/> + </xsl:attribute> + </xsl:if> + <xsl:call-template name="anchor"/> + <xsl:call-template name="process.image"/> + </div> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="d:inlinegraphic"> + <xsl:variable name="filename"> + <xsl:choose> + <xsl:when test="@entityref"> + <xsl:value-of select="unparsed-entity-uri(@entityref)"/> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="@fileref"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:call-template name="anchor"/> + + <xsl:choose> + <xsl:when test="@format='linespecific'"> + <xsl:choose> + <xsl:when test="$use.extensions != '0' and $textinsert.extension != '0'"> + <xsl:choose> + <xsl:when test="element-available('stext:insertfile')"> + <stext:insertfile href="{$filename}" encoding="{$textdata.default.encoding}"/> + </xsl:when> + <xsl:when test="element-available('xtext:insertfile')"> + <xtext:insertfile href="{$filename}"/> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes"> + <xsl:text>No insertfile extension available.</xsl:text> + </xsl:message> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes"> + <xsl:text>Cannot insert </xsl:text><xsl:value-of select="$filename"/> + <xsl:text>. Check use.extensions and textinsert.extension parameters.</xsl:text> + </xsl:message> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="process.image"/> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="d:mediaobject|d:mediaobjectco"> + + <xsl:variable name="olist" select="d:imageobject|d:imageobjectco |d:videoobject|d:audioobject |d:textobject"/> + + <xsl:variable name="object.index"> + <xsl:call-template name="select.mediaobject.index"> + <xsl:with-param name="olist" select="$olist"/> + <xsl:with-param name="count" select="1"/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="object" select="$olist[position() = $object.index]"/> + + <xsl:variable name="align"> + <xsl:value-of select="$object/descendant::d:imagedata[@align][1]/@align"/> + </xsl:variable> + + <div> + <xsl:apply-templates select="." mode="common.html.attributes"/> + <xsl:if test="$align != '' "> + <xsl:attribute name="style"><xsl:text>text-align: </xsl:text> + <xsl:value-of select="$align"/> + </xsl:attribute> + </xsl:if> + <xsl:call-template name="id.attribute"/> + <xsl:call-template name="anchor"/> + + <xsl:apply-templates select="$object"/> + <xsl:apply-templates select="d:caption"/> + </div> +</xsl:template> + +<xsl:template match="d:inlinemediaobject"> + <span> + <xsl:apply-templates select="." mode="common.html.attributes"/> + <xsl:call-template name="id.attribute"/> + <xsl:call-template name="anchor"/> + <xsl:call-template name="select.mediaobject"/> + </span> +</xsl:template> + +<xsl:template match="d:programlisting/d:inlinemediaobject |d:screen/d:inlinemediaobject" priority="2"> + <!-- the additional span causes problems in some cases --> + <xsl:call-template name="select.mediaobject"/> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="d:imageobjectco"> + <xsl:call-template name="anchor"/> + <xsl:choose> + <!-- select one imageobject? --> + <xsl:when test="$use.role.for.mediaobject != 0 and count(d:imageobject) > 1 and d:imageobject[@role]"> + <xsl:variable name="olist" select="d:imageobject"/> + + <xsl:variable name="object.index"> + <xsl:call-template name="select.mediaobject.index"> + <xsl:with-param name="olist" select="$olist"/> + <xsl:with-param name="count" select="1"/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="object" select="$olist[position() = $object.index]"/> + + <xsl:apply-templates select="$object"/> + </xsl:when> + <xsl:otherwise> + <!-- otherwise process them all --> + <xsl:apply-templates select="d:imageobject"/> + </xsl:otherwise> + </xsl:choose> + + <xsl:apply-templates select="d:calloutlist"/> + +</xsl:template> + +<xsl:template match="d:imageobject"> + <xsl:apply-templates select="d:imagedata"/> +</xsl:template> + +<xsl:template match="d:imagedata"> + <xsl:apply-templates select="." mode="goik"/> + <xsl:variable name="filename"> + <xsl:call-template name="mediaobject.filename"> + <xsl:with-param name="object" select=".."/> + </xsl:call-template> + </xsl:variable> + + <xsl:choose> + <!-- Handle MathML and SVG markup in imagedata --> + <xsl:when xmlns:mml="http://www.w3.org/1998/Math/MathML" test="mml:*"> + <xsl:apply-templates/> + </xsl:when> + + <xsl:when xmlns:svg="http://www.w3.org/2000/svg" test="svg:*"> + <xsl:apply-templates/> + </xsl:when> + + <xsl:when test="@format='linespecific'"> + <xsl:choose> + <xsl:when test="$use.extensions != '0' and $textinsert.extension != '0'"> + <xsl:choose> + <xsl:when test="element-available('stext:insertfile')"> + <stext:insertfile href="{$filename}" encoding="{$textdata.default.encoding}"/> + </xsl:when> + <xsl:when test="element-available('xtext:insertfile')"> + <xtext:insertfile href="{$filename}"/> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes"> + <xsl:text>No insertfile extension available.</xsl:text> + </xsl:message> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <a xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" href="{$filename}"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:variable name="longdesc.uri"> + <xsl:call-template name="longdesc.uri"> + <xsl:with-param name="mediaobject" select="ancestor::d:imageobject/parent::*"/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="phrases" select="ancestor::d:mediaobject/d:textobject[d:phrase] |ancestor::d:inlinemediaobject/d:textobject[d:phrase] |ancestor::d:mediaobjectco/d:textobject[d:phrase]"/> + + <xsl:call-template name="process.image"> + <xsl:with-param name="alt"> + <xsl:choose> + <xsl:when test="ancestor::d:mediaobject/d:alt"> + <xsl:apply-templates select="ancestor::d:mediaobject/d:alt"/> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="$phrases[not(@role) or @role!='tex'][1]"/> + </xsl:otherwise> + </xsl:choose> + </xsl:with-param> + <xsl:with-param name="longdesc"> + <xsl:call-template name="write.longdesc"> + <xsl:with-param name="mediaobject" select="ancestor::d:imageobject/parent::*"/> + </xsl:call-template> + </xsl:with-param> + </xsl:call-template> + + <xsl:if test="$html.longdesc != 0 and $html.longdesc.link != 0 and ancestor::d:imageobject/parent::*/d:textobject[not(d:phrase)]"> + <xsl:call-template name="longdesc.link"> + <xsl:with-param name="longdesc.uri" select="$longdesc.uri"/> + </xsl:call-template> + </xsl:if> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template name="longdesc.uri"> + <xsl:param name="mediaobject" select="."/> + <xsl:if test="$html.longdesc"> + <xsl:if test="$mediaobject/d:textobject[not(d:phrase)]"> + <xsl:variable name="dbhtml.dir"> + <xsl:call-template name="dbhtml-dir"/> + </xsl:variable> + <xsl:variable name="filename"> + <xsl:call-template name="make-relative-filename"> + <xsl:with-param name="base.dir"> + <xsl:choose> + <xsl:when test="$dbhtml.dir != ''"> + <xsl:value-of select="$dbhtml.dir"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$chunk.base.dir"/> + </xsl:otherwise> + </xsl:choose> + </xsl:with-param> + <xsl:with-param name="base.name"> + <xsl:choose> + <xsl:when test=" $mediaobject/@*[local-name() = 'id'] and not($use.id.as.filename = 0)"> + <!-- * if this mediaobject has an ID, then we use the --> + <!-- * value of that ID as basename for the "longdesc" --> + <!-- * file (that is, without prepending an "ld-" too it) --> + <xsl:value-of select="$mediaobject/@*[local-name() = 'id']"/> + <xsl:value-of select="$html.ext"/> + </xsl:when> + <xsl:otherwise> + <!-- * otherwise, if this mediaobject does not have an --> + <!-- * ID, then we generate an ID... --> + <xsl:variable name="image-id"> + <xsl:call-template name="object.id"> + <xsl:with-param name="object" select="$mediaobject"/> + </xsl:call-template> + </xsl:variable> + <!-- * ...and then we take that generated ID, prepend an --> + <!-- * "ld-" to it, and use that as the basename for the file --> + <xsl:value-of select="concat('ld-',$image-id,$html.ext)"/> + </xsl:otherwise> + </xsl:choose> + </xsl:with-param> + </xsl:call-template> + </xsl:variable> + + <xsl:value-of select="$filename"/> + </xsl:if> + </xsl:if> +</xsl:template> + +<xsl:template name="write.longdesc"> + <xsl:param name="mediaobject" select="."/> + <xsl:if test="$html.longdesc != 0 and $mediaobject/d:textobject[not(d:phrase)]"> + <xsl:variable name="filename"> + <xsl:call-template name="longdesc.uri"> + <xsl:with-param name="mediaobject" select="$mediaobject"/> + </xsl:call-template> + </xsl:variable> + + <xsl:value-of select="$filename"/> + + <xsl:call-template name="write.chunk"> + <xsl:with-param name="filename" select="$filename"/> + <xsl:with-param name="quiet" select="$chunk.quietly"/> + <xsl:with-param name="content"> + <xsl:call-template name="user.preroot"/> + <html> + <head> + <xsl:call-template name="system.head.content"/> + <xsl:call-template name="head.content"> + <xsl:with-param name="title" select="'Long Description'"/> + </xsl:call-template> + <xsl:call-template name="user.head.content"/> + </head> + <body> + <xsl:call-template name="body.attributes"/> + <xsl:for-each select="$mediaobject/d:textobject[not(d:phrase)]"> + <xsl:apply-templates select="./*"/> + </xsl:for-each> + </body> + </html> + <xsl:value-of select="$chunk.append"/> + </xsl:with-param> + </xsl:call-template> + </xsl:if> +</xsl:template> + +<xsl:template name="longdesc.link"> + <xsl:param name="longdesc.uri" select="''"/> + + <xsl:variable name="this.uri"> + <xsl:call-template name="make-relative-filename"> + <xsl:with-param name="base.dir" select="$chunk.base.dir"/> + <xsl:with-param name="base.name"> + <xsl:call-template name="href.target.uri"/> + </xsl:with-param> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="href.to"> + <xsl:call-template name="trim.common.uri.paths"> + <xsl:with-param name="uriA" select="$longdesc.uri"/> + <xsl:with-param name="uriB" select="$this.uri"/> + <xsl:with-param name="return" select="'A'"/> + </xsl:call-template> + </xsl:variable> + + <div class="longdesc-link" align="{$direction.align.end}"> + <br clear="all"/> + <span class="longdesc-link"> + <xsl:text>[</xsl:text> + <a href="{$href.to}" target="longdesc">D</a> + <xsl:text>]</xsl:text> + </span> + </div> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="d:mediaobject/d:alt"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="d:videoobject"> + <xsl:apply-templates select="d:videodata"/> +</xsl:template> + +<xsl:template match="d:videodata"> + <video controls="controls" preload="auto"> + <xsl:attribute name="title"> + <xsl:value-of select="normalize-space(../../../d:title)"/> + </xsl:attribute> + + <xsl:variable name="hdm_ImageFilename"> <!-- hdm_ prefix: do not mess with docbook! --> + <xsl:call-template name="mediaobject.filename"> + <xsl:with-param name="object" select=".."/> + </xsl:call-template> + </xsl:variable> + + <source src="{$hdm_ImageFilename}" type='video/mp4' /> + <source src="{$hdm_ImageFilename}.ogv"/> + </video> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="d:audioobject"> + <xsl:apply-templates select="d:audiodata"/> +</xsl:template> + +<xsl:template match="d:audiodata"> + <xsl:call-template name="process.image"> + <xsl:with-param name="tag" select="'embed'"/> + <xsl:with-param name="alt"> + <xsl:choose> + <xsl:when test="ancestor::d:mediaobject/d:alt"> + <xsl:apply-templates select="ancestor::d:mediaobject/d:alt"/> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="(ancestor::d:mediaobject/d:textobject/d:phrase)[1]"/> + </xsl:otherwise> + </xsl:choose> + </xsl:with-param> + </xsl:call-template> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="d:textobject"> + <xsl:apply-templates/> +</xsl:template> + +<xsl:template match="d:textdata"> + <xsl:variable name="filename"> + <xsl:choose> + <xsl:when test="@entityref"> + <xsl:value-of select="unparsed-entity-uri(@entityref)"/> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="@fileref"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="encoding"> + <xsl:choose> + <xsl:when test="@encoding"> + <xsl:value-of select="@encoding"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$textdata.default.encoding"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$use.extensions != '0' and $textinsert.extension != '0'"> + <xsl:choose> + <xsl:when test="element-available('stext:insertfile')"> + <stext:insertfile href="{$filename}" encoding="{$encoding}"/> + </xsl:when> + <xsl:when test="element-available('xtext:insertfile')"> + <xtext:insertfile href="{$filename}"/> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes"> + <xsl:text>No insertfile extension available.</xsl:text> + </xsl:message> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:message terminate="yes"> + <xsl:text>Cannot insert </xsl:text><xsl:value-of select="$filename"/> + <xsl:text>. Check use.extensions and textinsert.extension parameters.</xsl:text> + </xsl:message> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<!-- ==================================================================== --> + +<xsl:template match="d:caption"> + <div> + <xsl:apply-templates select="." mode="common.html.attributes"/> + <xsl:call-template name="id.attribute"/> + <xsl:if test="@align = 'right' or @align = 'left' or @align='center'"> + <xsl:attribute name="style"><xsl:text>text-align: </xsl:text><xsl:value-of select="@align"/></xsl:attribute> + </xsl:if> + <xsl:apply-templates/> + </div> +</xsl:template> + +<!-- ==================================================================== --> +<!-- "Support" for SVG --> + +<xsl:template xmlns:svg="http://www.w3.org/2000/svg" match="svg:*"> + <xsl:copy> + <xsl:copy-of select="@*"/> + <xsl:apply-templates/> + </xsl:copy> +</xsl:template> + + +<!-- The following works sometimes, but needs to take into account + 1. When there is no /*/@xml:base + 2. When the chunks are going somewhere else +<xsl:variable name="relpath"> + <xsl:call-template name="relative-uri"> + <xsl:with-param name="filename" select="@fileref"/> + </xsl:call-template> +</xsl:variable> + +<xsl:choose> + <xsl:when test="/*/@xml:base + and starts-with($relpath,/*/@xml:base)"> + <xsl:value-of select="substring-after($relpath,/*/@xml:base)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="@fileref"/> + </xsl:otherwise> +</xsl:choose> +<xsl:value-of select="@fileref"/> + </xsl:when> +--> +<!-- Resolve xml:base attributes --> +<xsl:template match="@fileref"> + <!-- need a check for absolute urls --> + <xsl:choose> + <xsl:when test="contains(., ':')"> + <!-- it has a uri scheme so it is an absolute uri --> + <xsl:value-of select="."/> + </xsl:when> + <xsl:when test="$keep.relative.image.uris != 0"> + <!-- leave it alone --> + <xsl:value-of select="."/> + </xsl:when> + <xsl:otherwise> + <!-- its a relative uri that needs xml:base processing --> + <xsl:call-template name="relative-uri"> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +</xsl:stylesheet>