Color text in topic

Post here questions and problems related to editing and publishing DITA content.
Le Basque
Posts: 147
Joined: Sat Oct 19, 2013 8:21 am

Color text in topic

Post by Le Basque »

Hi,

Exist a attribute that allows you to change colors on portions of text?

Thank you
Radu
Posts: 9420
Joined: Fri Jul 09, 2004 5:18 pm

Re: Color text in topic

Post by Radu »

Hi,

No, you would need to add a <ph> element with a certain @outputclass attribute value around that portion of text and then from the XSLs or from the CSS in case of the XHTML output match that output class and change the foreground color.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Le Basque
Posts: 147
Joined: Sat Oct 19, 2013 8:21 am

Re: Color text in topic

Post by Le Basque »

hi,

In topic i indicate :

Code: Select all


<p>blablablas <ph outputclass="font-color-red">I am red</ph></p>
In custom file i indicate :

Code: Select all


<xsl:template name="decoration">
<xsl:choose>
<xsl:when test="@outputclass='font-color-red'">
<xsl:attribute name="color">#8E2323</xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:template>

<!-- call decoration -->
<xsl:template match="*[contains(@class,' topic/ph ')]">
<fo:inline xsl:use-attribute-sets="ph">
<xsl:call-template name="decoration"/>
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
In resut PDF not color RED ?
thank you
Radu
Posts: 9420
Joined: Fri Jul 09, 2004 5:18 pm

Re: Color text in topic

Post by Radu »

Hi,

You could try to add xsl:messages in the XSLT customization to see after the publishing is finished in the ANT console output if your template is being called.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Le Basque
Posts: 147
Joined: Sat Oct 19, 2013 8:21 am

Re: Color text in topic

Post by Le Basque »

hi

ok when i replace #8E2323 by red the result is OK ?

thank you
Radu
Posts: 9420
Joined: Fri Jul 09, 2004 5:18 pm

Re: Color text in topic

Post by Radu »

Hi,

Is this a question or is this a statement?
The color attribute in XSL-FO should handle colors specified with the hexadecimal notation.
You can also edit the transformation scenario and set the parameter clean.temp to "no", then after the transformation look in the temporary files folder at a file called topic.fo which is the resulting XSL-FO file and see if the color attribute properly appeared on the fo:inline.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Le Basque
Posts: 147
Joined: Sat Oct 19, 2013 8:21 am

Re: Color text in topic

Post by Le Basque »

hi

there is a simpler solution for insert background color in entry of table ?

thank you
Radu
Posts: 9420
Joined: Fri Jul 09, 2004 5:18 pm

Re: Color text in topic

Post by Radu »

Hi,

You can probably also set the @outputclass attribute on a table entry like:

Code: Select all


<entry outputclass="red">AAAAAA</entry>
then in the XSL:

OXYGEN_INSTALL_DIR\frameworks\dita\DITA-OT\plugins\org.dita.pdf2\xsl\fo\tables.xsl

make modifications to the template which matches table body entries so that it looks for that attribute:

Code: Select all

    <xsl:template match="*[contains(@class, ' topic/tbody ')]/*[contains(@class, ' topic/row ')]/*[contains(@class, ' topic/entry ')]">
<fo:table-cell xsl:use-attribute-sets="tbody.row.entry">
<xsl:if test="@outputclass">
<xsl:attribute name="background-color"><xsl:value-of select="@outputclass"/></xsl:attribute>
</xsl:if>
<xsl:call-template name="commonattributes"/>
<xsl:call-template name="applySpansAttrs"/>
<xsl:call-template name="applyAlignAttrs"/>
<xsl:call-template name="generateTableEntryBorder"/>
<fo:block xsl:use-attribute-sets="tbody.row.entry__content">
<xsl:call-template name="processEntryContent"/>
</fo:block>
</fo:table-cell>
</xsl:template>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply