Override sidetoc.xsl aria-label
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 150
- Joined: Fri Apr 24, 2015 12:28 pm
Override sidetoc.xsl aria-label
Hello,
We have set our focus on making our webhelp responsive output as accessible as possible.
I've noticed that in some XSL files, some aria-labels haven't been localized yet.
Tried to add them myself and failed.
I've only got to the point that at least our customized strings-en-us.xml file is used, but the other strings-xx-xx files are not used.
It looks like the processing loses the language part somewhere, and I don't know why.
Normally, I would have only tunneled the i18n_context parameter - which worked in my other XSLs - but this time, I needed to import the functions.xsl file (the visible import is only a quick fix. I know it should be done otherwise.) and redefine the webhelp.language and i18n_context variables as was done elsewhere in the com.oxygenxml.webhelp.responsive plug-in. Otherwise, only the label defined in <xsl:otherwise> was used.
I've also redefined the variable to insert the label.home string, but to no avail.
What have I done wrong?
Best,
Christina
We have set our focus on making our webhelp responsive output as accessible as possible.
I've noticed that in some XSL files, some aria-labels haven't been localized yet.
Tried to add them myself and failed.

I've only got to the point that at least our customized strings-en-us.xml file is used, but the other strings-xx-xx files are not used.
It looks like the processing loses the language part somewhere, and I don't know why.
Normally, I would have only tunneled the i18n_context parameter - which worked in my other XSLs - but this time, I needed to import the functions.xsl file (the visible import is only a quick fix. I know it should be done otherwise.) and redefine the webhelp.language and i18n_context variables as was done elsewhere in the com.oxygenxml.webhelp.responsive plug-in. Otherwise, only the label defined in <xsl:otherwise> was used.
I've also redefined the variable to insert the label.home string, but to no avail.
Code: Select all
<?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"
xmlns:toc="http://www.oxygenxml.com/ns/webhelp/toc" xmlns="http://www.w3.org/1999/xhtml"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:st="http://www.oxygenxml.com/ns/webhelp/side-toc"
xmlns:oxygen="http://www.oxygenxml.com/functions"
exclude-result-prefixes="xs toc st xhtml" version="2.0">
<xsl:import href="../../com.oxygenxml.webhelp.responsive/xsl/util/functions.xsl"/>
<xsl:variable name="webhelp_language" select="oxygen:getParameter('webhelp.language')"/>
<xsl:variable name="i18n_context">
<i18n_context>
<xsl:attribute name="xml:lang" select="$webhelp_language"/>
<xsl:attribute name="lang" select="$webhelp_language"/>
<xsl:attribute name="dir" select="oxygen:getParameter('webhelp.page.direction')"/>
</i18n_context>
</xsl:variable>
<xsl:template match="xhtml:ul" mode="toc-accessibility">
<xsl:copy>
<xsl:variable name="isRoot" as="xs:boolean" select="count(parent::*) = 0"/>
<xsl:attribute name="role">
<xsl:choose>
<xsl:when test="$isRoot">
<xsl:value-of>tree</xsl:value-of>
</xsl:when>
<xsl:otherwise>
<xsl:value-of>group</xsl:value-of>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates select="@*" mode="toc-accessibility"/>
<xsl:if test="$isRoot">
<xsl:attribute name="aria-label">
<xsl:choose>
<xsl:when test="exists($i18n_context)">
<xsl:for-each select="$i18n_context[1]">
<xsl:call-template name="getWebhelpString">
<xsl:with-param name="stringName" select="'label.home'"/>
</xsl:call-template>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>Table of Contents</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<span class="expand-button-action-labels">
<span id="{$expandActionID}" aria-label="Expand"/>
<span id="{$collapseActionID}" aria-label="Collapse"/>
<span id="{$pendingActionID}" aria-label="Pending"/>
</span>
</xsl:if>
<xsl:apply-templates select="node()" mode="toc-accessibility"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Best,
Christina
oXygen XML Editor 25.1 build 2023070306
DITA OT 3.7.4
DITA OT 3.7.4
-
- Site Admin
- Posts: 275
- Joined: Thu Dec 24, 2009 11:21 am
Re: Override sidetoc.xsl aria-label
Hello Christina,
The issue you are facing is because the oxygen:getParameter() function does not work properly.
To fix it, first you have to declare the following parameters in your stylesheet:
Next, you have to import the functions.xsl stylesheet (as you have already noticed). To correctly import it you need to add the following import declaration:
Now the oxygen:getParameter() should work as expected.
In addition to this, in order for the getWebhelpString template to correctly localize the strings it should be called as follows:
Please nothe the /* in the for-each select clause.
Below you can find the modified stylesheet (I added some log messages to test that it works properly):
In my Publishing Template I have linked the above stylesheet on the com.oxygenxml.webhelp.xsl.createNavLinks XSLT Extension Point:
Regards,
Alin
The issue you are facing is because the oxygen:getParameter() function does not work properly.
To fix it, first you have to declare the following parameters in your stylesheet:
Code: Select all
<xsl:param name="TEMP_DIR_URL"/>
<xsl:param name="WEBHELP_PARAMETERS_URL" select="concat($TEMP_DIR_URL, 'props.xml')"></xsl:param>
Code: Select all
<xsl:import href="plugin:com.oxygenxml.webhelp.responsive:xsl/util/functions.xsl"/>
Now the oxygen:getParameter() should work as expected.
In addition to this, in order for the getWebhelpString template to correctly localize the strings it should be called as follows:
Code: Select all
<xsl:for-each select="$i18n_context[1]/*">
<xsl:call-template name="getWebhelpString">
<xsl:with-param name="stringName" select="'label.home'"/>
</xsl:call-template>
</xsl:for-each>
Below you can find the modified stylesheet (I added some log messages to test that it works properly):
Code: Select all
<?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"
xmlns:toc="http://www.oxygenxml.com/ns/webhelp/toc" xmlns="http://www.w3.org/1999/xhtml"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:st="http://www.oxygenxml.com/ns/webhelp/side-toc"
xmlns:oxygen="http://www.oxygenxml.com/functions"
exclude-result-prefixes="xs toc st xhtml" version="2.0">
<xsl:param name="TEMP_DIR_URL"/>
<xsl:param name="WEBHELP_PARAMETERS_URL" select="concat($TEMP_DIR_URL, 'props.xml')"></xsl:param>
<!-- <xsl:import href="../../com.oxygenxml.webhelp.responsive/xsl/util/functions.xsl"/>-->
<xsl:import href="plugin:com.oxygenxml.webhelp.responsive:xsl/util/functions.xsl"/>
<xsl:variable name="webhelp_language" select="oxygen:getParameter('webhelp.language')"/>
<xsl:variable name="i18n_context">
<i18n_context>
<xsl:attribute name="xml:lang" select="$webhelp_language"/>
<xsl:attribute name="lang" select="$webhelp_language"/>
<xsl:attribute name="dir" select="oxygen:getParameter('webhelp.page.direction')"/>
</i18n_context>
</xsl:variable>
<xsl:template match="xhtml:ul" mode="toc-accessibility">
<xsl:message> --------------- TEMP_DIR_URL: <xsl:value-of select="$TEMP_DIR_URL"/></xsl:message>
<xsl:message> --------------- WEBHELP_PARAMETERS_URL: <xsl:value-of select="$WEBHELP_PARAMETERS_URL"/></xsl:message>
<xsl:message> --------------- WH LANG: <xsl:value-of select="oxygen:getParameter('webhelp.language')"/></xsl:message>
<xsl:message> Search i18n:
<xsl:for-each select="$i18n_context[1]/*">
<xsl:call-template name="getWebhelpString">
<xsl:with-param name="stringName" select="'webhelp.search'"/>
</xsl:call-template>
</xsl:for-each>
</xsl:message>
<xsl:copy>
<xsl:variable name="isRoot" as="xs:boolean" select="count(parent::*) = 0"/>
<xsl:attribute name="role">
<xsl:choose>
<xsl:when test="$isRoot">
<xsl:value-of>tree</xsl:value-of>
</xsl:when>
<xsl:otherwise>
<xsl:value-of>group</xsl:value-of>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates select="@*" mode="toc-accessibility"/>
<xsl:if test="$isRoot">
<xsl:attribute name="aria-label">
<xsl:choose>
<xsl:when test="exists($i18n_context)">
<xsl:for-each select="$i18n_context[1]">
<xsl:call-template name="getWebhelpString">
<xsl:with-param name="stringName" select="'label.home'"/>
</xsl:call-template>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>Table of Contents</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<span class="expand-button-action-labels">
<span id="{$expandActionID}" aria-label="Expand"/>
<span id="{$collapseActionID}" aria-label="Collapse"/>
<span id="{$pendingActionID}" aria-label="Pending"/>
</span>
</xsl:if>
<xsl:apply-templates select="node()" mode="toc-accessibility"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
In my Publishing Template I have linked the above stylesheet on the com.oxygenxml.webhelp.xsl.createNavLinks XSLT Extension Point:
Code: Select all
<xslt>
<extension file="xsl/toc-ext.xsl" id="com.oxygenxml.webhelp.xsl.createNavLinks"/>
</xslt>
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 150
- Joined: Fri Apr 24, 2015 12:28 pm
Re: Override sidetoc.xsl aria-label
Hi Alin,
This works like a charm. Thank you so much for this detailed description! This helps me a lot.
I did not have the slightest idea what to do to make the oxygen:getParameter() function work.
Best regards,
Christina
This works like a charm. Thank you so much for this detailed description! This helps me a lot.
I did not have the slightest idea what to do to make the oxygen:getParameter() function work.
Best regards,
Christina
oXygen XML Editor 25.1 build 2023070306
DITA OT 3.7.4
DITA OT 3.7.4
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