Support DITA 1.3 rotate attribute

axhxu
Posts: 33
Joined: Thu Aug 27, 2015 9:28 pm

Support DITA 1.3 rotate attribute

Post by axhxu » Mon Jan 13, 2020 10:06 pm

Hi,
I am trying to add support to the Responsive webhelp for the dita 1.3 attribute @rotate for table cells.

I am trying to figure out how to add to the generated cell class if @rotate='1'.

Current generated element looks like:

Code: Select all

<th class="entry colsep-1 rowsep-1" id="rod1578579338781__table_v4s_1l2_p2b__entry__1"><div><span>Rotate Heading 1 with a really really long heading</span></div></th>
What I need is:

Code: Select all

<th class="entry rotate colsep-1 rowsep-1" id="rod1578579338781__table_v4s_1l2_p2b__entry__1"><div><span>Rotate Heading 1 with a really really long heading</span></div></th>
I think I need to override this template in table.xsl?:

Code: Select all

  <xsl:template match="@align | @valign | @colsep | @rowsep" mode="css-class">
    <xsl:sequence select="dita-ot:css-class((), .)"/>
  </xsl:template>
Or would I need to create an override based on the css-class.xsl templates?

Note I have already added and override for table entry in my customDita2webhelp.xsl:

Code: Select all

'<!-- IPTS-1165 -->
    <xsl:template match="*[contains(@class, ' topic/entry ')]" mode="table:entry">
        <xsl:apply-templates select="." mode="table:common"/>
        <xsl:apply-templates select="." mode="headers"/>
        <xsl:apply-templates select="@morerows, @dita-ot:morecols"/>
        <xsl:variable name="checkforText">
            <xsl:value-of select="./text()"/>
        </xsl:variable>
        <!--IPTS-1254; changed from if to choose -->
        
        <xsl:choose>
            <!--IPTS-1525 -->
            <xsl:when test="normalize-space(string($checkforText)) != '' and @rotate !='1'">
                <p class="p"><xsl:apply-templates/></p>
            </xsl:when>
            <!--IPTS-1525 -->
            <xsl:when test="@rotate ='1'">
                <div><span><xsl:apply-templates/></span></div>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates/>
            </xsl:otherwise>
        </xsl:choose>
       
    </xsl:template>
I can apply changes to the generated cell content based on the @rotate value. So I am looking how to add the the class generation process for cells.

Thanks
Arron

Radu
Posts: 6922
Joined: Fri Jul 09, 2004 5:18 pm

Re: Support DITA 1.3 rotate attribute

Post by Radu » Wed Feb 05, 2020 2:54 pm

Hi Aaron,

Sorry for the delay.
There is this XSLT stylesheet "OXYGEN_INSTALL_DIR\frameworks\dita\DITA-OT3.x\plugins\org.dita.html5\xsl\css-class.xsl" which has an xslt template like this:

Code: Select all

  <xsl:template match="*" mode="css-class" priority="100">
maybe you can try to overwrite it in your customization and change the definition of the "class" variable to also include some mention of the rotation attribute value, something like:

Code: Select all

<xsl:variable name="class" as="xs:string*">
      <xsl:if test="$outputclass">
        <xsl:sequence select="data($outputclass)"/>
      </xsl:if>
      <xsl:next-match/>
      <xsl:if test="@rotate">
        <xsl:sequence select="concat('rotate', @rotate)"/>
      </xsl:if>
    </xsl:variable>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

axhxu
Posts: 33
Joined: Thu Aug 27, 2015 9:28 pm

Re: Support DITA 1.3 rotate attribute

Post by axhxu » Tue Mar 10, 2020 5:51 pm

Thanks that worked I added the following to my customDita2webhelp.xsl:

Code: Select all

 <xsl:template match="*[contains(@rotate,'1')]" mode="css-class" priority="120">
        <xsl:param name="default-output-class"/>
        
        <xsl:variable name="outputclass" as="attribute(class)?">
            <xsl:apply-templates select="." mode="set-output-class">
                <xsl:with-param name="default" select="$default-output-class"/>
            </xsl:apply-templates>
        </xsl:variable>
        
        <xsl:variable name="class" as="xs:string*">
            <!--xsl:if test="$outputclass">
                <xsl:sequence select="data($outputclass)"/>
            </xsl:if-->
            <xsl:next-match/>
            <xsl:if test="@rotate">
                <xsl:sequence select="'rotate'"/>
            </xsl:if>
        </xsl:variable>
        
        <xsl:if test="exists($class)">
            <xsl:attribute name="class" select="$class"/>
        </xsl:if>
    </xsl:template>
I had to comment out the test for outputclass otherwise I ended up with "entry entry...." in the class.

Post Reply