Topics

Help with filtering in com.elovirta.ooxml #conditional-processing


Leigh White
 

Hi all,

I'm setting up the com.elovirta.ooxml plugin for a customer. Using with OT 2.5.4. They will be using @audience pretty extensively to both filter some elements, and color-code others. For the latter, I have set up a ditaval that flags content based on the value of @audience. This works exactly as expected for pdf outputs but seems to have no effect whatsoever for ooxml output. My knowledge of this plugin and ooxml in general is pretty slim. I'm wondering if the failure lies in the plugin--that it just doesn't account for flagging, or in the template---that some accommodation would need to be made there for displaying the background color? Looking at the CLEANED file, it appears that the flagging is preserved to that point:

<ditaval-startprop class="+ topic/foreign ditaot-d/ditaval-startprop " outputclass="background-color:yellow;">
<prop xmlns:dita-ot="http://dita-ot.sourceforge.net" action="flag" att="audience" backcolor="yellow" val="optional"/>
</ditaval-startprop>split up as indicated<ditaval-endprop class="+ topic/foreign ditaot-d/ditaval-endprop ">
<prop xmlns:dita-ot="http://dita-ot.sourceforge.net" action="flag" att="audience" backcolor="yellow" val="optional"/>
</ditaval-endprop>

So I'm not sure where it gets lost. Any help appreciated!

Thanks,
Leigh


Jonathan Hanna
 

Hi Leigh,

I'd like to preface this by saying that I'm fairly new to DITA (~1 year experience), so my solution is definitely not the best :-). However, I have experience making customizations to the com.elovirta.ooxml over the past year, so maybe I can provide you with a good place to start.

As far as I know, flagging content is not currently supported in the plugin (although filtering is). As a workaround, you can create a custom document.xsl file that contains a custom XSLT rule to highlight content in Word. When running the plugin, you will need to set the document.xsl parameter to the file path of your custom document.xsl file.

To create the custom file:
  1. Make a copy of the document.xsl file provided with the plugin.
  2. The document.xsl file imports many .xsl files in the plugin. In the new document.xsl file, you will need to append plugin:com.elovirta.ooxml:docx/word/ to the href of each imported file. For example, change <xsl:import href="document.utils.xsl"/> to <xsl:import href="plugin:com.elovirta.ooxml:docx/word/document.utils.xsl"/>.
  3. In the new file, add the following XSLT to the end of the file:
    <xsl:template match="*[contains(@audience, 'optional')]" mode="inline-style">
        <w:highlight w:val="yellow"/>
    </xsl:template>


I've attached a custom document.xsl file as an example. There are obvious limitations to this method, such as associating the color yellow with the value of the audience attribute instead of the ditaval property. For example, if you changed the backcolor attribute to green in the ditaval file you would still see a yellow highlight in Word. If I knew how to select properties set in a ditaval file, that would be a much better solution. Hopefully the above at least provides a good start to a better solution.

Best Regards,
Jonathan


Jonathan Hanna
 

Well, I decided to have some fun this afternoon by furthering my knowledge about how ditaval flags work during processing. I think I now have a better solution than what I proposed earlier. Instead of using the XSLT template I provided in the previous message, try the following:

  <xsl:template match="*[ditaval-startprop/prop[@backcolor]]" mode="inline-style">
    <xsl:param name="backcolor" select="ditaval-startprop/prop/@backcolor"/>        
    <w:highlight w:val="{$backcolor}"/>
  </xsl:template>

Again, my XSLT knowledge isn't the best, so there's probably a better way to do this. However, from my brief testing, this seems to work pretty well! I tested this with three different colors (red, green, and blue) and each color appeared in Word as specified in the ditaval file.

Best Regards,
Jonathan