Customize styles in com.elovirta.ooxml plugin

188 views
Skip to first unread message

mr.uma...@gmail.com

unread,
Nov 5, 2020, 10:48:03 PM11/5/20
to DITA-OT Users

Hi,

We wanted to generate docx output from ditamap files. We are planning to use com.elovirta.ooxml (https://github.com/jelovirt/com.elovirta.ooxml) plugin and extend it to apply our styles. The plugin works perfectly. Thank you so much.

I tried to update styles in com.elovirta.ooxml/resources/Normal.docx file; but changes are not reflecting in the output docx. For example, I selected "Heading 1" and changed its color to "Red" (#FF0000). I saved this document and regenerated docx file. The docx output still has default blue color (#2F5496). Am I missing something here?

Is this the correct way to change the styles of docx output?

I attached the updated Normal.docx file for your reference.

Best Regards,
Uma Shankar
Normal.docx

Radu Coravu

unread,
Nov 6, 2020, 8:03:30 AM11/6/20
to mr.uma...@gmail.com, DITA-OT Users
Hi Uma,

I do not have right now time to investigate this on my side. I'm attaching two screenshots showing how the styles can be modified using the Word "Styles" side-view. Have you done this in order to change the coloring of the Heading 1? If not, can you change it like this, save the word document and see if it works  better?

Regards,
Radu

--
You received this message because you are subscribed to the Google Groups "DITA-OT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dita-ot-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/dita-ot-users/66793ce1-3358-49b1-9f78-d50b18294d32n%40googlegroups.com.
Screen Shot 2020-11-06 at 3.00.52 PM.png
Screen Shot 2020-11-06 at 3.00.42 PM.png

kcho...@mail.com

unread,
Nov 6, 2020, 8:49:23 AM11/6/20
to DITA-OT Users
Hello, 

here is one way to do that. Create docx file and style it the way you want (you probably already did it in the file you attached). Then rename it to .zip and extract its content to a folder. You should get bunch of xml files. Then open file [extracted_files_folder]word\document.xml and search for some of your elements (for example "My Text" or whatever you have in the document). You will note that for the parts you've colored you have something like this:

<w:r w:rsidRPr="00250D93">
<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
          <w:t>Some Text</w:t>
</w:r> 

Now open:
[DITA-OT-TOOLKIT]\plugins\com.elovirta.ooxml-master\docx\word\document.topic.xsl

end change the stylesheet to generate this color elements the way you want. For example:
<xsl:template match="text()">
    <xsl:param name="styles" as="element()*" tunnel="yes">
      <xsl:apply-templates select="ancestor::*" mode="inline-style"/>
    </xsl:param>
    <w:r>
<w:rPr>
<w:color w:val="FF0000"/>
</w:rPr>
      <xsl:if test="exists($styles)">
        <w:rPr>
          <xsl:copy-of select="$styles"/>
        </w:rPr>
      </xsl:if>
      <xsl:choose>
        <xsl:when test="contains(., '&#x2011;')">
          <xsl:for-each select="tokenize(., '&#x2011;')">
            <xsl:if test="position() ne 1">
              <w:noBreakHyphen/>
            </xsl:if>
            <w:t>
              <xsl:value-of select="."/>
            </w:t>
          </xsl:for-each>
        </xsl:when>
        <xsl:otherwise>
          <w:t>
            <xsl:value-of select="."/>
          </w:t>
        </xsl:otherwise>
      </xsl:choose>
    </w:r>
  </xsl:template>

Hope it helps.

-----------
jAuthor - www.jauthor.com

kcho...@mail.com

unread,
Nov 6, 2020, 9:05:59 AM11/6/20
to DITA-OT Users
As you can see from previous example it is also possible set styles (no time to test this now):

<xsl:param name="styles" as="element()*" tunnel="yes">
      <xsl:apply-templates select="ancestor::*" mode="inline-style"/>
</xsl:param>

<xsl:if test="exists($styles)">
        <w:rPr>
          <xsl:copy-of select="$styles"/>
        </w:rPr>
</xsl:if>

-----------
jAuthor - www.jauthor.com

jha...@pasco.com

unread,
Nov 6, 2020, 11:34:07 AM11/6/20
to DITA-OT Users
Hi Uma,

I checked your Normal.docx file and confirmed that the problem is that you only changed the text color in the document and not the style of "Heading 1" (see attached image). Follow Radu's instructions that he provided earlier and that will fix the issue.

Here's additional information from Microsoft if you need help modifying a style in Word:

Best Regards,
Jonathan

modify_style.png

Uma Shankar

unread,
Nov 10, 2020, 3:23:57 PM11/10/20
to jha...@pasco.com, DITA-OT Users
Thank you all. I got the answers I was looking for. 

You received this message because you are subscribed to a topic in the Google Groups "DITA-OT Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dita-ot-users/hMeF97gQZ00/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dita-ot-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/dita-ot-users/562575fe-dd4b-4905-9daf-2c40557b98fbn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages