Page 1 of 1

DL Widths / Replace with blocks

Posted: Wed Nov 25, 2015 7:07 pm
by RichH
Hi,
I am trying to use DL elements in my DITA and have the following:

Code: Select all


<dl>
<dlentry>
<dt>Lorem ipsum</dt>
<dd>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
invidunt</dd>
</dlentry>
<dlentry>
<dt>At vero</dt>
<dd>At vero eos et accusam et justo duo dolores et ea rebum</dd>
</dlentry>
</dl>
Using the standard Dita 1.8 engine with FOP, this is rendered as a table with the DT and DD in columns with 50% each.

Ideally, I would like the DL list rendered like this (but other solutions are acceptable):
Lorem ipsum
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
invidunt

At vero
At vero eos et accusam et justo duo dolores et ea rebum
So in my tables.xsl, I've replaced all table blocks with fo:blocks as shown here:

Code: Select all


   <!--Definition list-->
<xsl:template match="*[contains(@class, ' topic/dl ')]">
<fo:block xsl:use-attribute-sets="dl">
<xsl:call-template name="commonattributes"/>
<xsl:apply-templates select="*[contains(@class, ' topic/dlhead ')]"/>
<fo:block xsl:use-attribute-sets="dl__body">
<xsl:choose>
<xsl:when test="contains(@otherprops,'sortable')">
<xsl:apply-templates select="*[contains(@class, ' topic/dlentry ')]">
<xsl:sort select="opentopic-func:getSortString(normalize-space( opentopic-func:fetchValueableText(*[contains(@class, ' topic/dt ')]) ))" lang="{$locale}"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="*[contains(@class, ' topic/dlentry ')]"/>
</xsl:otherwise>
</xsl:choose>
</fo:block>
</fo:block>
</xsl:template>

<xsl:template match="*[contains(@class, ' topic/dl ')]/*[contains(@class, ' topic/dlhead ')]">
<fo:block xsl:use-attribute-sets="dl.dlhead">
<xsl:call-template name="commonattributes"/>
<fo:block xsl:use-attribute-sets="dl.dlhead__row">
<xsl:apply-templates/>
</fo:block>
</fo:block>
</xsl:template>

<xsl:template match="*[contains(@class, ' topic/dlhead ')]/*[contains(@class, ' topic/dthd ')]">
<fo:block xsl:use-attribute-sets="dlhead.dthd__cell">
<xsl:call-template name="commonattributes"/>
<fo:block xsl:use-attribute-sets="dlhead.dthd__content">
<xsl:apply-templates/>
</fo:block>
</fo:block>
</xsl:template>

<xsl:template match="*[contains(@class, ' topic/dlhead ')]/*[contains(@class, ' topic/ddhd ')]">
<fo:block xsl:use-attribute-sets="dlhead.ddhd__cell">
<xsl:call-template name="commonattributes"/>
<fo:block xsl:use-attribute-sets="dlhead.ddhd__content">
<xsl:apply-templates/>
</fo:block>
</fo:block>
</xsl:template>

<xsl:template match="*[contains(@class, ' topic/dlentry ')]">
<fo:block xsl:use-attribute-sets="dlentry">
<xsl:call-template name="commonattributes"/>
<fo:block xsl:use-attribute-sets="dlentry.dt">
<xsl:apply-templates select="*[contains(@class, ' topic/dt ')]"/>
</fo:block>
<fo:block xsl:use-attribute-sets="dlentry.dd">
<xsl:apply-templates select="*[contains(@class, ' topic/dd ')]"/>
</fo:block>
</fo:block>
</xsl:template>

<xsl:template match="*[contains(@class, ' topic/dt ')]">
<fo:block xsl:use-attribute-sets="dlentry.dt__content">
<xsl:call-template name="commonattributes"/>
<xsl:apply-templates/>
</fo:block>
</xsl:template>

<xsl:template match="*[contains(@class, ' topic/dd ')]">
<fo:block xsl:use-attribute-sets="dlentry.dd__content">
<xsl:call-template name="commonattributes"/>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
My list appears as above, but it is 100% wide and starts left of the above text. For example (... show indent)
.....Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat,
.....vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim
.....qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.

Lorem ipsum
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
invidunt

At vero
At vero eos et accusam et justo duo dolores et ea rebum

In my tables-attr.xsl, I've set the following:

Code: Select all


  <xsl:attribute-set name="dl">
<!--DL is a table-->
<xsl:attribute name="width">300pt</xsl:attribute>
<xsl:attribute name="start-indent">20pt</xsl:attribute>
<xsl:attribute name="space-before">5pt</xsl:attribute>
<xsl:attribute name="space-after">5pt</xsl:attribute>
<xsl:attribute name="color">blue</xsl:attribute>
</xsl:attribute-set>
But niether width nor start-indent have any effect. Only color:blue has any effect.

How can I either:
a) use DL as a table, but have dynamic column widths (I've read that this isn't possible with FOP
b) use DL as blocks, but set the width and have it indented with the surrounding text (like notes or tables)

Thanks
Rich

Re: DL Widths / Replace with blocks

Posted: Wed Nov 25, 2015 7:10 pm
by RichH
p.s., I forgot to write. I've looked at my topic.fo and the attributes are set:

Code: Select all


<fo:block color="blue" space-after="5pt" space-before="5pt" start-indent="20pt" table-layout="fixed" width="300pt">

Re: DL Widths / Replace with blocks

Posted: Thu Nov 26, 2015 12:41 pm
by RichH
Hi,
I found a solution by looking at the code here: https://github.com/dita-community/org.d ... -as-dl.xsl.

I stuck with my tables.xsl code as shown above where I replaced all the table references with fo:block. Then in my tables-attr.xsl I have

Code: Select all


  <xsl:attribute-set name="dl">
<!--DL is a table-->
<xsl:attribute name="space-before">5pt</xsl:attribute>
<xsl:attribute name="space-after">5pt</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="dl__body">
</xsl:attribute-set>

<xsl:attribute-set name="dl.dlhead">
</xsl:attribute-set>

<xsl:attribute-set name="dlentry">
</xsl:attribute-set>

<xsl:attribute-set name="dlentry.dt">
<xsl:attribute name="relative-align">baseline</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="dlentry.dt__content" use-attribute-sets="common.table.body.entry common.table.head.entry">
<xsl:attribute name="start-indent">from-parent(start-indent) + 0mm</xsl:attribute>
<xsl:attribute name="keep-with-next">always</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="dlentry.dd">
</xsl:attribute-set>

<xsl:attribute-set name="dlentry.dd__content" use-attribute-sets="common.table.body.entry">
<xsl:attribute name="start-indent">from-parent(start-indent) + 10pt</xsl:attribute>
</xsl:attribute-set>

<xsl:attribute-set name="dl.dlhead__row">
</xsl:attribute-set>

<xsl:attribute-set name="dlhead.dthd__cell">
</xsl:attribute-set>

<xsl:attribute-set name="dlhead.dthd__content" use-attribute-sets="common.table.body.entry common.table.head.entry">
</xsl:attribute-set>

<xsl:attribute-set name="dlhead.ddhd__cell">
</xsl:attribute-set>

<xsl:attribute-set name="dlhead.ddhd__content" use-attribute-sets="common.table.body.entry common.table.head.entry">
</xsl:attribute-set>
And that produces a nice DL list which is aligned with the parent, the DT is bold on its own line and the DD is indented on the line below the DT.

Hope this helps.
Rich

Re: DL Widths / Replace with blocks

Posted: Thu Nov 26, 2015 3:03 pm
by radu_pisoi
Hi,

Yes, the org.dita-community.pdf-dl-as-dl plugin overrides the default formatting for the dl element. This plugin is already included in the DITA-OT 1.8 distribution that comes bundled with oXygen.

If you use a custom DITA-OT, you can integrate this plugin with your custom DITA-OT instead of copying its stylesheests into a customization folder. I think that this option is recommended.

The next topic describes how to integrate a custom plugin in the current used DITA-OT from oXygen: Installing a Plugin in the DITA Open Toolkit. The DITA-OT distribution can be changed from the oXygen's DITA preferences page.

Re: DL Widths / Replace with blocks

Posted: Thu Nov 26, 2015 5:40 pm
by RichH
Hi,

using the net.sourceforge.dita4publishers.pdf-dl-as-dl plugin is best I agree. I have a PDF customization "systemguide", which uses "pdf2". How do I use the dl-as-dl plugin as well?

Do I just need to update my plugin.xml and add a <require> tag before/after the line "<require plugin="org.dita.pdf2"/>"

Thanks
Rich

Re: DL Widths / Replace with blocks

Posted: Fri Nov 27, 2015 11:22 am
by radu_pisoi
Hi,

No, it's not necessarily to make a dependency between the two plugins.

For instance, if both plugins contributes an XSLT stylesheet, the DITA-OT integrator will generate an xsl:import for each extension stylesheet in the main stylesheet.

I've tested with DITA-OT 1.8 that comes bundled with oXygen 17.1. After I've run the Integrator, the PDF generated with my custom PDF plugin includes the display customization for the dl element.

Re: DL Widths / Replace with blocks

Posted: Wed Dec 02, 2015 12:25 pm
by RichH
Hi,
I've lost the plot a little I'm afraid. My customized plugin includes the table.xsl and table_attr.xsl files which include the definitions for the DL elements. To use the definitions in the dl_as_dl plugin do I just delete all custzomized DL references? How do I include the dl_as_dl definitions and not the pdf2 definitions?

Thanks
Rich

Re: DL Widths / Replace with blocks

Posted: Wed Dec 02, 2015 5:48 pm
by radu_pisoi
Hi,
My customized plugin includes the table.xsl and table_attr.xsl files which include the definitions for the DL elements. To use the definitions in the dl_as_dl plugin do I just delete all custzomized DL references?
Yes, the templates from your customization plugin are more important and they can override any template from the default PDF stylesheet or any other plugin that extend it.
So, if you want to use the templates from the dl_as_dl plugin you have to comment all the templates from your plugin that override them.
How do I include the dl_as_dl definitions and not the pdf2 definitions?
For this task it's not necessarily to do any action. This is the default extension mechanism that allows a plugin to override some functionality from the plugin that it extends.