docbook-apps

Re: [docbook-apps] image class or role in mediaobject

  • 1.  Re: [docbook-apps] image class or role in mediaobject

    Posted 08-31-2011 03:33
    Hi Fabien,
    There is no class attribute defined for DocBook's imageobject element, so it is
    unlikely that its value would be handled by the stylesheet. Were you thinking of the
    role attribute? I see both class and role on imagedata, but since you are asking
    about role="histogram", I'll assume you mean to use the role attribute.

    Also, I'm not able to duplicate your results of getting the imageobject's
    class="imgopen2" to appear on the div element. Are you using a stylesheet
    customization that does that?

    DocBook XSL has some limited support for propagating a role attribute to a class
    attribute, but that is not a universal mechanism, simply because people use role for
    many things and would not necessarily want to see its values appear in their HTML
    output.

    The stylesheets have a general mechanism for customizing a class attribute, but it
    does not apply to . That would require customizing a rather large template named
    'process.image.attributes' to add a class attribute. But the class customization
    mechanism does work for mediaobject, however. For example, if your source has a role
    on mediaobject:

    <mediaobject role="histogram">

    when combined with the following stylesheet customization (remove the d: namespace if
    using DocBook 4):

    <xsl:template match="d:mediaobject" mode="class.value">
    <xsl:choose>
    <xsl:when test="@role">
    <xsl:value-of select="@role"/>
    </xsl:when>
    <xsl:otherwise>mediaobject</xsl:otherwise>
    </xsl:choose>
    </xsl:template>

    will result in this output:






    and you can use a CSS selector such as:

    div.histogram img {
    }

    to apply any CSS styles you need on the img element.

    See this reference for more information on using mode="class.value":

    http://www.sagehill.net/docbookxsl/UsingCSS.html#CustomClass


    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net





    Global message icon