Wrap DITA Simple Lists
Description
Preserve <sl> elements as <div>s in generated HTML.
Method
Making this happen requires two things:
<sl> element location preserved during conversion from DITA to WIF
Placeholders converted from WIF to <div> elements in the target HTML output
DITA to WIF
The first requirement can be accomplished by creating an override to the DITA styles configuration file:
Formats\Adapters\xml\scripts\dita\default.wwconfig
We add a new style rule for ' topic/sl ' elements with the @markopen and @markclose attributes:
<!-- Mark open/close on simple lists --> <!-- --> <Style match="//*[contains(@class, ' topic/sl ')]"> <xsl:variable name="VarName" select="'Simple List Container'" /> <wwditaconfig:Head name="{$VarName}" markopen="{$VarName} Open" markclose="{$VarName} Close" /> </Style>
This will preserve the location of the start/end of the <sl> container element.
WIF to HTML
With the start and end locations recorded in WIF, we can now customize content.xsl to emit the open/close <div> element pair in our HTML output. To do this, we will need to escape the markup for each div tag so that it conforms to XML/XSL coding.
Therefore, <div> will be encoded as <div>.
Using a wwtransform:super customization, the entire content.xsl override for HTML becomes:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wwmode="urn:WebWorks-Engine-Mode" xmlns:wwdoc="urn:WebWorks-Document-Schema" xmlns:wwsplits="urn:WebWorks-Engine-Splits-Schema" xmlns:wwproject="urn:WebWorks-Publish-Project" xmlns:wwlog="urn:WebWorks-XSLT-Extension-Log" xmlns:wwprojext="urn:WebWorks-XSLT-Extension-Project" xmlns:wwexsldoc="urn:WebWorks-XSLT-Extension-Document" exclude-result-prefixes="xsl wwmode wwdoc wwproject wwlog wwprojext wwexsldoc" > <xsl:import href="wwtransform:super" /> <xsl:template match="wwdoc:Paragraph[@stylename = 'Simple List Container Open']" mode="wwmode:content"> <wwexsldoc:Text disable-output-escaping="yes"> <xsl:text><div class="simple_list" style="border: solid black 1px ; background-color: #C0C0FF"></xsl:text> </wwexsldoc:Text> </xsl:template> <xsl:template match="wwdoc:Paragraph[@stylename = 'Simple List Container Close']" mode="wwmode:content"> <wwexsldoc:Text disable-output-escaping="yes"> <xsl:text></div></xsl:text> </wwexsldoc:Text> </xsl:template> </xsl:stylesheet>
Example
Sample project which implements the above customizations is attached as Simple Lists.zip.