[moving this over to the docbook-apps mailing list where stylesheet issues are discussed.]

Hi,
It is easy to change the class attribute on the mediaobject's div, but hard to add one to img. In DocBook XSL, the class attribute for most elements is generated by processing the element in mode="class.value". Of the three elements that make up a mediaobject for a graphic, only mediaobject itself is processed this way, so no class attribute is generated for <img> currently.

So to change it for mediaobject's div, you can do this:

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

This will result in:

<div class="informalfigure">
  <div class="test2">
      <img alt="alt" src="images/articles/common_law.png"/>
  </div>
</div>

and you can write a CSS selector to apply it to img:

.test2  img {
}

Bob Stayton
Sagehill Enterprises
[email protected]


----- Original Message ----- From: "Dominic Marcotte" <[email protected]>
To: <[email protected]>
Sent: Tuesday, September 01, 2009 1:42 PM
Subject: [docbook] How to add a class attribute to a image


Hello,

I want to add a class attribute to my img tag.

     <informalfigure role="test1">
       <mediaobject role="test2">
         <imageobject  role="test3">
<imagedata role="test4" fileref="images/articles/common_law.png"/>
         </imageobject>
         <textobject><phrase>alt</phrase></textobject>
       </mediaobject>
     </informalfigure>

but the role attribute dont generate a class attribute.

<div class="informalfigure">
   <div class="mediaobject">
       <img alt="alt" src="images/articles/common_law.png"/>
   </div>
</div>

Any idea?

Dominic

---------------------------------------------------------------------
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