OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook] How to add a class attribute to a image


[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
bobs@sagehill.net


----- Original Message ----- 
From: "Dominic Marcotte" <d.marcotte@usherbrooke.ca>
To: <docbook@lists.oasis-open.org>
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: docbook-unsubscribe@lists.oasis-open.org
> For additional commands, e-mail: docbook-help@lists.oasis-open.org
>
>
> 



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]