xsl-list
[Top] [All Lists]

Re: [xsl] Attributes disappear in XHTML output

2019-08-30 10:31:28
This is great, Gerrit, it fixed my problem. Also thanks to Martin for looking at this.

The DITA Open Toolkit had a template that removed my data-* attributes. Unfortunately it did not work to try to override this behavior in the best-practice DITA OT plugin way, so I just commented it out in the default OT code in this file:

dita-ot-3.3.2\plugins\org.dita.xhtml\xsl\dita2xhtml-util.xsl

I'll comment on the bug you mention and maybe the OT guys will fix this.

Mark

On 8/30/2019 12:24 AM, Imsieke, Gerrit, le-tex gerrit(_dot_)imsieke(_at_)le-tex(_dot_)de wrote:
Hi Mark,

There’s this comment by Radu on Github: https://github.com/dita-ot/dita-ot/issues/2955#issuecomment-388341287

So if you have an importing stylesheet (which I assume you have), you can try to override the default behavior like this:

<xsl:template match="@*[starts-with(name(), 'data-')]" mode="add-xhtml-ns">
  <xsl:copy/>
</xsl:template>

– Gerrit


On 30.08.2019 08:47, Mark Giffin m1879(_at_)earthlink(_dot_)net wrote:
When I do the following simple XHTML output, I can get any attribute I want in the XHTML output:

XML input:
<x>
   <p>Here is my text.</p>
</x>

XSLT:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
     xmlns:xs="http://www.w3.org/2001/XMLSchema";
     exclude-result-prefixes="xs"
     version="2.0">
     <xsl:output method="xml" encoding="utf-8" indent="yes"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";
         doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
     />
     <xsl:template match="/">
         <html> <body>
                 <span class="myclass" data-toggle="tooltip" data-placement="bottom">
                     <xsl:apply-templates/>
                 </span>
             </body></html>
     </xsl:template>
</xsl:stylesheet>

But when I run XHTML output with the DITA Open Toolkit v.3.3.2 using this:

       <span class="myclass" data-toggle="tooltip" data-placement="bottom">
         <xsl:apply-templates select="." mode="output-term">
           <xsl:with-param name="displaytext" select="normalize-space($displaytext)"/>
         </xsl:apply-templates>
       </span>

only the @class attribute appears in the output. The data-* attributes are dropped. I've tried using <xsl:attribute> instead of literal text, same result. What would cause this?

Thanks,
Mark


--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>