Page 1 of 1
Move figure caption above the figure
Posted: Fri Oct 31, 2014 12:33 am
by Lachlan_Murray
Hi,
I'm using Oxygen XML Editor 16.0 and outputting HTML WebHelp from DITA. Could someone tell me how to move figure captions from below the figure to above the figure?
In dita2htmlImpl.xsl, it looks like there was a patch at some point to move the figure caption below the figure. Basically, I want to reverse that change and move the caption back above the figure.
Thanks.
Re: Move figure caption above the figure
Posted: Fri Oct 31, 2014 6:47 pm
by sorin_ristache
Hello,
For moving the caption back above the figure please replace the following lines between lines 1558 and 1562 in the file
OXYGEN_INSTALL_DIR\frameworks\dita\DITA-OT\plugins\org.dita.xhtml\xsl\xslhtml\dita2htmlImpl.xsl:
Code: Select all
<!-- OXYGEN PATCH START EXM-18109 EXM-28090 - moved image caption below. -->
<xsl:apply-templates select="*[contains(@class,' topic/image ')]|*[contains(@class,' topic/object ')]"/>
<xsl:call-template name="place-fig-lbl"/>
<xsl:apply-templates select="*[not(contains(@class,' topic/title '))][not(contains(@class,' topic/desc '))][not(contains(@class,' topic/image '))][not(contains(@class,' topic/object '))] |text()|comment()|processing-instruction()"/>
<!-- OXYGEN PATCH END EXM-18109 EXM-28090 -->
with the following lines:
Code: Select all
<xsl:call-template name="place-fig-lbl"/>
<xsl:apply-templates select="*[not(contains(@class, ' topic/title '))][not(contains(@class, ' topic/desc '))] |text()|comment()|processing-instruction()"/>
Re: Move figure caption above the figure
Posted: Sat Nov 01, 2014 3:45 am
by Lachlan_Murray
Thanks, Sorin. That worked.
In the HTML output there's a <br/> tag that gets inserted between the figure caption and the figure that I'd really like to get rid of. My captions are currently too far away from the figures, but I can't get them any closer using css because of the <br/> tag. I tried commenting out <xsl:value-of select="$newline"/> immediately below the piece of code you gave me to insert, but it didn't make any difference. Could you direct me to the location where that <br/> is specified?
I also uncommented lines 3747-3759 in dita2htmlImpl.xsl to restore the "Figure" prefix and figure numbering, in case that makes a difference.
Re: Move figure caption above the figure
Posted: Mon Nov 03, 2014 6:39 pm
by sorin_ristache
Sorry, there is no
<br/> tag inserted between the figure caption and the figure. The code that I showed you to be replaced and also the entire
<img> tag is inside a
<div> tag like the following:
Code: Select all
<div class="fig fignone"><p class="figcap">IRIS TITLE</p>
<img class="image" src="../../images/Iris_sanguinea.jpg" height="166" width="125"></img>
</div>
The line
inserts only a newline character, not a
<br/> tag.
Maybe you use a different Oxygen version? Please tell me what Oxygen version number and build number you use (they are visible in the
Help -> About dialog box) and also post the code that you have in the WebHelp page, including the
<img> tag with the reference to the image file and the
<br/> tag.
Re: Move figure caption above the figure
Posted: Mon Nov 03, 2014 7:31 pm
by Lachlan_Murray
Hi Sorin,
Here's my build info: <oXygen/> XML Editor 16.0, build 2014070913
I think I may have found a solution. If I comment out lines 1593-1595 in
dita2htmlImpl.xsl, then the
<br/> tag does not get inserted between the figure caption and the figure. I commented out these lines in the
topic.image template:
Code: Select all
<xsl:when test="@placement = 'break'">
<br/>
</xsl:when>
If I do not comment out the lines, here's the code that gets generated in the WebHelp page:
Code: Select all
<div class="fig fignone"><p class="figcap">Figure 2. Main tab in a command dialog box</p><br/><div class="imageleft"><img class="image imageleft" src="../images/Summarize_Main_tab.png"/></div><br/></div>
And here's the code that gets generated with the lines commented out:
Code: Select all
<div class="fig fignone"><p class="figcap">Figure 2. Main tab in a command dialog box</p><div class="imageleft"><img class="image imageleft" src="../images/Summarize_Main_tab.png"/></div><br/></div>
I hope that commenting out those lines doesn't affect anything else. So far, everything else in the generated WebHelp looks okay.
Re: Move figure caption above the figure
Posted: Tue Nov 04, 2014 10:51 am
by sorin_ristache
Hi,
Now I understand, you have the placement=break attribute on the image element. No, commenting out that code doesn't affect anything else.
Re: Move figure caption above the figure
Posted: Fri Nov 07, 2014 7:41 pm
by Lachlan_Murray
Thanks. I'll take a look at those placement attributes. Just leaving the code commented out might be easier than resetting the attributes on all the images in our documentation. I'm assuming they're set that way because that's what we need in our current transformation from DITA to Eclipse Help.
Re: Move figure caption above the figure
Posted: Mon Nov 10, 2014 9:53 am
by sorin_ristache
The default value of the placement attribute is inline. So it was explicitly set to break for separating each image from the surrounding text. This separation will occur in all types of output created from such an XML topic file.