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


    ----- Original Message -----
    From: "Fabien Tillier" <f.tillier@cerep.fr>
    To: <docbook-apps@lists.oasis-open.org>
    Sent: Monday, August 29, 2011 3:18 AM
    Subject: [docbook-apps] image class or role in mediaobject


    Hi List.
    I want to add some tooling in the html output of my docbook for images,
    and thus need to select only some of the ones I have displayed.
    So, I have a class/role defined on the imagedata item
    <mediaobject>
    <imageobject class="imgopen2">
    <imagedata class="histogram" role="histogram" align="center"
    fileref="{$path}" width="18cm" format="PNG"/>
    </imageobject>
    ...
    </mediaobject>
    However, when generating the html version, the class is not propagate,
    thus


    cellpadding="0" cellspacing="0" width="638">




    titlealign="middle" width="638">



    Note, however that the class define on the imageobject is kept.

    Is there a way I can have the "histogram" class propagated at the image
    level ?

    Thanks in advance
    Best regards,
    Fabien

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
    For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org