Inconsistent table structure after applying an XSLT on title element
Posted: Sat Aug 13, 2022 10:51 pm
Hello!
I'm currently working on a plugin that replaces the values of outputclass attributes for different elements in a dita source.
The XSLT itself works as expected when I test it solely, but once I integrate it in my plugin with a feature extension="dita.xsl.html5" and launch an HTML5 transformation, I got strange results in the structure of the table.
As shown here, the display seems correct (besides the border) and the content is ordered. I don't get why the structure of the table is not respected. Would you have any idea?
First, here is the XSLT used:
I'm currently working on a plugin that replaces the values of outputclass attributes for different elements in a dita source.
The XSLT itself works as expected when I test it solely, but once I integrate it in my plugin with a feature extension="dita.xsl.html5" and launch an HTML5 transformation, I got strange results in the structure of the table.
As shown here, the display seems correct (besides the border) and the content is ordered. I don't get why the structure of the table is not respected. Would you have any idea?
First, here is the XSLT used:
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:xd="http://www.oxygenxml.com/ns/doc/xsl"
exclude-result-prefixes="xs xd"
version="2.0">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:param name="t-link" select="'ft-expanding-block-link'"/>
<xsl:param name="t-block" select="'ft-expanding-block'"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[@outputclass='collapse-folded']">
<xsl:variable name="id-value" select="@id"/>
<xsl:element name="{name()}">
<xsl:copy-of select="@*[name()!='outputclass']"/>
<xsl:attribute name="class">
<xsl:value-of select="$t-block"/>
</xsl:attribute>
<xsl:if test="title">
<xsl:element name="span">
<xsl:attribute name="class"><xsl:value-of select="$t-link"/></xsl:attribute>
<xsl:attribute name="data-target-id"><xsl:value-of select="$id-value"/></xsl:attribute>
<xsl:value-of select="title"/>
</xsl:element>
</xsl:if>
<xsl:copy-of select="node()[name()!='title']"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>