[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: RE: [docbook-apps] Re: DocBook Website and SVG images for the banners
Jochen+oasis-open@Hayek.name said: >>>>>> Sina K Heshmati writes: > >> Do you have a customization layer for website stylesheets? > > http://www.sagehill.net/docbookxsl/WebsiteFormat.html#WebsiteCustomization > > Website stylesheet customization It would have been better if you could fix this in your customization layer. Here's a patch to toc-tabular.xsl that takes care of files with an SVG extension. I haven't tested the code, so please tell feel free to report errors. Kind regards, SinDoc
Index: xsl/website/toc-tabular.xsl =================================================================== --- xsl/website/toc-tabular.xsl (revision 8733) +++ xsl/website/toc-tabular.xsl (working copy) @@ -50,12 +50,26 @@ <xsl:variable name="homebanner" select="/autolayout/config[@param='homebanner-tabular'][1]"/> + <xsl:variable name="homebanner-ext"> + <xsl:call-template name="extract-suffix-from-relpath"> + <xsl:with-param name="relpath" select="$homebanner/@value"/> + </xsl:call-template> + </xsl:variable> + + <xsl:variable name="homebanner-wrapper"> + <xsl:call-template name="dispatch-wrapper-for-graphics"> + <xsl:param name="ext" select="$homebanner-ext"/> + </xsl:call-template> + </xsl:variable> + <xsl:variable name="banner" select="/autolayout/config[@param='banner-tabular'][1]"/> <xsl:choose> <xsl:when test="$pageid = @id"> - <img align="left" border="0"> + <xsl:element name="{$homebanner-wrapper}"> + <xsl:attribute name="align">left</xsl:attribute> + <xsl:attribute name="border">0</xsl:attribute> <xsl:attribute name="src"> <xsl:value-of select="$relpath"/> <xsl:value-of select="$homebanner/@value"/> @@ -63,7 +77,14 @@ <xsl:attribute name="alt"> <xsl:value-of select="$homebanner/@altval"/> </xsl:attribute> - </img> + <xsl:if test="$homebanner-ext = 'svg'"> + <xsl:attribute name="type"> + <xsl:call-template name="dispatch-mime-for-graphics"> + <xsl:with-param name="ext" select="$homebanner-ext"/> + </xsl:call-template> + </xsl:attribute> + </xsl:if> + </xsl:element> <br clear="all"/> <br/> </xsl:when> @@ -477,4 +498,47 @@ </xsl:choose> </xsl:template> +<xsl:template name="dispatch-wrapper-for-graphics"> + <xsl:param name="ext"/> + <xsl:choose> + <xsl:when test="$ext = 'svg'">embed</xsl:when> + <xsl:otherwise>img</xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template name="dispatch-mime-for-graphics"> + <xsl:param name="ext"/> + <xsl:if test="$ext = 'svg'">image/svg+xml</xsl:if> +</xsl:template> + +<xsl:template name="extract-suffix-from-relpath"> + <xsl:param name="relpath"/> + <xsl:call-template name="extract-suffix-from-relpath-helper"> + <xsl:with-param name="relpath" select="translate($relpath, + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + 'abcdefghijklmnopqrstuvwxyz')"/> + </xsl:call-template> +</xsl:template> + +<xsl:template name="extract-suffix-from-relpath-helper"> + <xsl:param name="relpath"/> + <xsl:choose> + <xsl:when test="contains($relpath, '..')"> + <xsl:call-template name="extract-suffix-from-relpath"> + <xsl:with-param name="relpath" + select="substring-after($relpath, '..')" /> + </xsl:call-template> + </xsl:when> + <xsl:when test="contains($relpath, '/')"> + <xsl:call-template name="extract-suffix-from-relpath"> + <xsl:with-param name="relpath" + select="substring-after($relpath, '/')" /> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="substring-after($relpath, '.')" /> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + </xsl:stylesheet>
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]