Webhelp hazard statement XSLT extension point
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 55
- Joined: Tue Mar 13, 2018 6:07 pm
Webhelp hazard statement XSLT extension point
Post by steinbacherGE »
We use a custom Webhelp extension point that overrides the HTML5 XSL template for hazardstatement.
"C:\DITA-OT3.x\plugins\org.dita.html5\xsl\hazard-d.xsl"
Our extension includes the whole HTML5 hazardstatement table from hazard-d.xsl. We've copied the template from this file and modified the use of symbols and borders. We also added conditional statements to differentiate 2 different hazard statement styles that are controlled by a parameter.
The latest Webhelp release v23.1 now includes its own extension of this template.
"C:\DITA-OT3.x\plugins\com.oxygenxml.webhelp.responsive\xsl\dita2webhelp\html5-pdf-webhelp\html5-hazard.xsl"
But the new Webhelp extension breaks into different parts:
Is there a way to call our extension of the HTML5 hazard-d.xsl instead of the original one?
Or should we extend the new html5-hazard.xsl templates instead?
"C:\DITA-OT3.x\plugins\org.dita.html5\xsl\hazard-d.xsl"
Our extension includes the whole HTML5 hazardstatement table from hazard-d.xsl. We've copied the template from this file and modified the use of symbols and borders. We also added conditional statements to differentiate 2 different hazard statement styles that are controlled by a parameter.
The latest Webhelp release v23.1 now includes its own extension of this template.
"C:\DITA-OT3.x\plugins\com.oxygenxml.webhelp.responsive\xsl\dita2webhelp\html5-pdf-webhelp\html5-hazard.xsl"
But the new Webhelp extension breaks into different parts:
- Call original template from org.dita.html5/xsl/hazard-d.xsl.
- Add hazard type to class attribute.
- Add hazard header in a thead element and define colgroup.
- Add hazard content into a tbody element.
Is there a way to call our extension of the HTML5 hazard-d.xsl instead of the original one?
Or should we extend the new html5-hazard.xsl templates instead?
-
- Posts: 665
- Joined: Wed Oct 16, 2019 3:47 pm
Re: Webhelp hazard statement XSLT extension point
Post by julien_lacour »
Hello,
An easy way to integrate your plugin together with our is to use the following workflow:
Julien
An easy way to integrate your plugin together with our is to use the following workflow:
- Use a template to match the same element as the default from hazard-d.xsl/html5-hazard.xsl and use a variable and the next-match call to save the returned fragment.
This fragment contains modifications for both hazard-d.xsl and html5-hazard.xsl (html5-hazard.xsl calls hazard-d.xsl on the same manner using next-match and a variable).
Code: Select all
<xsl:template match="*[contains(@class,' hazard-d/hazardstatement ')]"> <xsl:variable name="nm"> <xsl:next-match/> </xsl:variable> <xsl:apply-templates select="$nm" mode="custom"/> </xsl:template>
- Create a copy-template ("ct" in Oxygen autocompletion) that copies the fragment using your custom mode.
Code: Select all
<xsl:template match="node() | @*" mode="custom"> <xsl:copy> <xsl:apply-templates select="node() | @*" mode="#current"/> </xsl:copy> </xsl:template>
- Add you custom templates, don't forget the mode.
Like this you will have modifications from both style-sheets.
Code: Select all
<!-- Add your custom templates. --> <xsl:template match="table" mode="custom"> ... </xsl:template> <xsl:template match="td" mode="custom"> ... </xsl:template> ...
Julien
-
- Posts: 55
- Joined: Tue Mar 13, 2018 6:07 pm
Re: Webhelp hazard statement XSLT extension point
Post by steinbacherGE »
Thank you for the explanation and the workflow.
Our custom table template wraps the content that is inside the <th> element with a <span> element.
This allows us to apply a custom style to just the span element that contains the hazardstatement symbol and type.
Any suggestions on how to add a <span> element inside the <th> element?
Thanks,
Leroy
Our custom table template wraps the content that is inside the <th> element with a <span> element.
Code: Select all
<th colspan="2" class="hazardstatement--danger">
<span>
<svg >..</svg> DANGER
</span>
</th>
image.png
I tried the following template, but it adds an empty span element at the end of the table instead of inside the <th> element. Code: Select all
<!-- Add your custom templates. -->
<xsl:template match="th" mode="custom">
<span>
<xsl:copy-of select="."/>
</span>
</xsl:template>
Thanks,
Leroy
You do not have the required permissions to view the files attached to this post.
-
- Posts: 665
- Joined: Wed Oct 16, 2019 3:47 pm
Re: Webhelp hazard statement XSLT extension point
Post by julien_lacour »
Hello,
Your template cannot work because the <span> will be generated before the <th> element which is not valid in a table.
This is the result of your template:
You need first to generate the <th> (with its attributes), emit the <span> and copy all its children (with <xsl:apply-templates/>):
Regards,
Julien
Your template cannot work because the <span> will be generated before the <th> element which is not valid in a table.
This is the result of your template:
Code: Select all
<span>
<th colspan="2" class="hazardstatement--danger">
<svg xmlns="http://www.w3.org/2000/svg" class="hazardsymbol" version="1.1" height="1em" viewBox="0 0 600 525">
...
</svg>
DANGER
</th>
</span>
Code: Select all
<xsl:template match="th" mode="custom">
<th>
<xsl:copy-of select="@*"/>
<span>
<xsl:apply-templates/>
</span>
</th>
</xsl:template>
Julien
-
- Posts: 55
- Joined: Tue Mar 13, 2018 6:07 pm
Re: Webhelp hazard statement XSLT extension point
Post by steinbacherGE »
Thanks Julien!
Your suggestion works as expected.
Your suggestion works as expected.

Return to “DITA (Editing and Publishing DITA Content)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service