Ordered list - two different sets of attributes

Post here questions and problems related to editing and publishing DITA content.
justyna_i
Posts: 33
Joined: Mon Oct 08, 2018 12:16 pm

Ordered list - two different sets of attributes

Post by justyna_i »

Hello,

in my document I have several ordered lists and some of them need to have bigger spaces between <li> items.

How can this be achieved?
I am using pdf XSL-FO plugin based on dita-ot pdf out of the box.

regards,
Justyna
Radu
Posts: 8992
Joined: Fri Jul 09, 2004 5:18 pm

Re: Ordered list - two different sets of attributes

Post by Radu »

Hi Justyna,

Over the last years we created a dedicated team in Oxygen for publishing and customizing PDF using CSS so officially we do not support anymore customization questions about the old approach of using XSL-FO. With CSS what you want is quite simple to achieve with a selector like this for example:

Code: Select all

ol > li {
    margin-top:10px;
}
A couple of suggestions for the XSL-FO based PDF generation:
- There is a book named "DITA for Print" by Leight White which covers lots of aspects of PDF (XSL-FO based) customization.
- Do you already have a PDF customization folder or plugin set up? You would need some knowledge of XSLT to customize the PDF publishing:
https://www.oxygenxml.com/doc/versions/ ... ation.html
The generation of the XSL-FO lists from DITA lists takes place in the stylesheet "OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT3.x/plugins/org.dita.pdf2/xsl/fo/lists.xsl"
It has templates which match for example list items inside DITA <ol> elements:

Code: Select all

<xsl:template match="*[contains(@class, ' topic/ol ')]/*[contains(@class, ' topic/li ')]">
and attribute sets like "ol.li" are used. This particular attribute set is defined in "OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT3.x/plugins/org.dita.pdf2/cfg/fo/attrs/lists-attr.xsl" and looks like this:

Code: Select all

    <xsl:attribute-set name="ol.li">
        <xsl:attribute name="space-after">1.5pt</xsl:attribute>
        <xsl:attribute name="space-before">1.5pt</xsl:attribute>
        <xsl:attribute name="relative-align">baseline</xsl:attribute>
    </xsl:attribute-set>
So a customization could provide other values for the spaces before and after a list item.
If you want this only for specific <ol> elements you could set an "outputclass="custom"" attribute on it and then in the XSLT try to increase the spaces only if the <ol> has a certain value for the outputclass attribute.
- You could also try to register and ask around on the public DITA Users List: https://dita-users.groups.io/g/main

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
justyna_i
Posts: 33
Joined: Mon Oct 08, 2018 12:16 pm

Re: Ordered list - two different sets of attributes

Post by justyna_i »

If you want this only for specific <ol> elements you could set an "outputclass="custom"" attribute on it and then in the XSLT try to increase the spaces only if the <ol> has a certain value for the outputclass attribute.
This is what I want to achieve but I don't have enough knowledge to implement it.
I do have the Dita for print book, I have custom plugin set up fully and I was able to find all the .xsl files needed but I think I am missing something,

I understand I should check this lists.xls file more in detail and modify those:

Code: Select all

<xsl:template match="*[contains(@class, ' topic/ol ')]/*[contains(@class, ' topic/li ')]">
I am just not sure how.

P.S. So is the XSL-FO nowadays "an old approach"? Are companies moving away from it and implement CSS styles?
Radu
Posts: 8992
Joined: Fri Jul 09, 2004 5:18 pm

Re: Ordered list - two different sets of attributes

Post by Radu »

Hi,

For example the template could maybe be changed something like this by a PDF customization:

Code: Select all

   <xsl:template match="*[contains(@class, ' topic/ol ')]/*[contains(@class, ' topic/li ')]">
        <xsl:variable name="depth" select="count(ancestor::*[contains(@class, ' topic/ol ')])"/>
        <xsl:variable name="format">
          <xsl:call-template name="getVariable">
            <xsl:with-param name="id" select="concat('Ordered List Format ', $depth)"/>
          </xsl:call-template>
        </xsl:variable>
        <fo:list-item xsl:use-attribute-sets="ol.li">
            <xsl:call-template name="commonattributes"/>
            <fo:list-item-label xsl:use-attribute-sets="ol.li__label">
                  <xsl:if test="parent::ol[@outputclass='increased-spaces']">
                  <xsl:attribute name="space-after">10pt</xsl:attribute>
                </xsl:if>
                <fo:block xsl:use-attribute-sets="ol.li__label__content">
                    <xsl:call-template name="getVariable">
                        <xsl:with-param name="id" select="concat('Ordered List Number ', $depth)"/>
                        <xsl:with-param name="params" as="element()*">
                           <number>
                               <xsl:number format="{$format}"/>
                           </number>
                        </xsl:with-param>
                    </xsl:call-template>
                </fo:block>
            </fo:list-item-label>
            <fo:list-item-body xsl:use-attribute-sets="ol.li__body">
                <fo:block xsl:use-attribute-sets="ol.li__content">
                    <xsl:apply-templates/>
                </fo:block>
            </fo:list-item-body>
        </fo:list-item>
    </xsl:template>
So this extra check:

Code: Select all

            <xsl:if test="parent::ol[@outputclass='increased-spaces']">
                <xsl:attribute name="space-after">10pt</xsl:attribute>
            </xsl:if>
should add a larger space-after attribute value if the list item is inside an "ol" element with the attribute "outputclass='increased-spaces'".

About this remark:
P.S. So is the XSL-FO nowadays "an old approach"? Are companies moving away from it and implement CSS styles?
To perform XSL-FO based PDF customizations you need good knowledge of XSLT and XSL-FO. Both standards although useful are not mainstream so from what I've encountered companies end up hiring a consultant to create customizations and then at some point the consultant leaves and the technical writer becomes in charge of further understanding and maintaining the PDF customization but they have little knowledge of both XSLT and XSL-FO. And it's not the tech writer's fault, although an useful standard I think very few people in the world can say they have very good knowledge of XSL-FO and I think most of those people worked on the XSL-FO standard.

CSS is well known by more people, any web developer in a company can create some CSS rules, it also has a special standard named pagination for controlling page dimensions and orientation:
https://www.oxygenxml.com/doc/versions/ ... _size.html
It can also be debugged in a web browser: https://www.oxygenxml.com/doc/versions/ ... ng_the_css
We even added an online CSS styles builder: https://styles.oxygenxml.com/
So by investing these years in the CSS-based PDF publishing (which is free to use from inside Oxygen) we wanted to lower the threshold necessary for someone to create, understand and maintain a PDF customization.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
justyna_i
Posts: 33
Joined: Mon Oct 08, 2018 12:16 pm

Re: Ordered list - two different sets of attributes

Post by justyna_i »

Thank you for quick help!

I will check this solution as soon as I have a bit more extra time (deadlines! :) )

Whereas the XSLT and XSL-FO, you are absolutely right. Not many people have good knowledge about it and it does require a bit deeper understanding of the code than CSS. I am not sure what is the best solution if all our custom made plugins are done with XSLT and XSL-FO, it would surely require some resources to create new pdf plugins in CSS.
Post Reply