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 <img>. 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:

<div class="histogram">
 <table
   <tbody>
     <tr>
       <td>
         <img ...

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
[email protected]


----- Original Message ----- From: "Fabien Tillier" <[email protected]>
To: <[email protected]>
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

  <div class="imgopen2">
       <table summary="manufactured viewport for HTML img" border="0"
cellpadding="0" cellspacing="0" width="638">
       <tbody><tr>
       <td align="center">
<img src="myImage.png" alt="title"
align="middle" width="638"></td>
        </tr>
        </tbody></table>
  </div>

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: [email protected]
For additional commands, e-mail: [email protected]




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to