Edit online

How to Wrap Scientific Numbers in Tables Cells

In your PDF output, you may need to wrap scientific numbers on two lines when they are included in table cells.

To add this functionality, use an Oxygen Publishing Template and follow these steps:
  1. If you have not already created a Publishing Template, you need to create one. For details, see How to Create a Publishing Template.
  2. Link the folder associated with the publishing template to your current project in the Project view.
  3. Using the view, create an xslt folder inside the project root folder.
  4. In the newly created folder, create an XSL file (for example, named merged2html5Extension.xsl) with the following content:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      exclude-result-prefixes="xs"
      version="2.0">
    
      <!-- Matches text from table cells. -->
      <xsl:template match="*[contains(@class, ' topic/entry ') ]/text()">
        <xsl:analyze-string select="." regex="[0-9]\.[0-9]{{2}}e-[0-9]{{2}}">
          <!-- The cell contains a scientific number like 1.23e-08. -->
          <xsl:matching-substring>
            <xsl:variable name="text" select="concat(substring-before(., 'e'),
              'e&#8203;', substring-after(., 'e'))"/>
            <xsl:value-of select="$text"/>
          </xsl:matching-substring>
          <xsl:non-matching-substring>
            <xsl:value-of select="."/>
          </xsl:non-matching-substring>
        </xsl:analyze-string>
      </xsl:template>
    
    </xsl:stylesheet>
  5. Open the template descriptor file associated with your publishing template (the .opt file) and set the XSLT stylesheet created in the previous step with the com.oxygenxml.pdf.css.xsl.merged2html5 XSLT extension point:
    <publishing-template>
      ...
      <pdf>
        ...        
        <xslt>
          <extension
            id="com.oxygenxml.pdf.css.xsl.merged2html5"
            file="xslt/merged2html5Extension.xsl"/>
        </xslt>
  6. Edit the DITA Map PDF - based on HTML5 & CSS transformation scenario.
  7. In the Templates tab, click the Choose Custom Publishing Template link and select your template.
  8. Click OK to save the changes and run the transformation scenario.