Custom attribute not pushed in the XHTML map
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 105
- Joined: Thu Jan 20, 2022 12:36 pm
Custom attribute not pushed in the XHTML map
Hello,
I created a plugin to include a custom attribute in my topics.
Concretely, I needed to add a data-target-id to a p element.
My plugin and the associated dtd are now correctly recognized.
I would just like to get confirmation, in addition to the ent file used for the attribute plus the topic dtd customization, if I need to modify another file to make OT able to process and include the attribute in an XHTML source.
Here is the plugin if anyone would like to check it out. It's very simple.

I created a plugin to include a custom attribute in my topics.
Concretely, I needed to add a data-target-id to a p element.
My plugin and the associated dtd are now correctly recognized.
image.png
However, when publishing a test page, I noticed that the new attribute isn't processed in HTML.I would just like to get confirmation, in addition to the ent file used for the attribute plus the topic dtd customization, if I need to modify another file to make OT able to process and include the attribute in an XHTML source.
Here is the plugin if anyone would like to check it out. It's very simple.
com.gbv.collapse.zip
Thanks for any feedback or tips 
You do not have the required permissions to view the files attached to this post.
------
Gaspard
Gaspard
-
- Posts: 922
- Joined: Thu May 02, 2019 2:32 pm
Re: Custom attribute not pushed in the XHTML map
Post by chrispitude »
Try creating a "passthrough.ditaval" file like this:
then reference this during publishing:
and you should get the attribute passed through to the output:
Note that the DITAVAL "passthrough" appends "data-" to the attribute, so you might want to remove it from your attribute specialization.
I can't take credit for this one. Radu reminded me of this passthrough mechanism a couple weeks ago for something else, and so I happened to remember it for your question.
Code: Select all
<val>
<prop action="passthrough" att="data-target-id"/>
</val>
Code: Select all
dita -i test.dita -f html5 -o out -filter passthrough.ditaval
Code: Select all
<p class="p topic/p ft-expanding-block-link" data-data-target-id="test-koko"></p>
I can't take credit for this one. Radu reminded me of this passthrough mechanism a couple weeks ago for something else, and so I happened to remember it for your question.

-
- Posts: 105
- Joined: Thu Jan 20, 2022 12:36 pm
Re: Custom attribute not pushed in the XHTML map
Oh that's excellent! Thank you so much Chris for this workaround.
I continued working on it yesterday and I understood that I needed to add an extension in my plugin.xml with
Then, I edited the dita2htmlImpl.xsl to support my custom attribute. But, wow, that makes such a work just to add a single attribute in the XHTML publication.
I definitely prefer your solution!
I continued working on it yesterday and I understood that I needed to add an extension in my plugin.xml with
Code: Select all
<feature extension="dita.xsl.xhtml" value="./xsl/collapse.xsl"/>
I definitely prefer your solution!
------
Gaspard
Gaspard
-
- Posts: 105
- Joined: Thu Jan 20, 2022 12:36 pm
Re: Custom attribute not pushed in the XHTML map
Hi again!
There's something I don't get though. When I apply the integrator.xml after my changes and check the dita2html-base.xsl file to see if the xsl override file is correctly imported, I noticed the xsl override wasn't precisely targeted.
Here is how the path is inserted:
instead of:
If I manually edit the path, that works perfectly. However, each time I'll integrate the OT, it's likely the path will be updated with a wrong value.
I wonder why it isn't correctly targeted.
There's something I don't get though. When I apply the integrator.xml after my changes and check the dita2html-base.xsl file to see if the xsl override file is correctly imported, I noticed the xsl override wasn't precisely targeted.
Here is how the path is inserted:
Code: Select all
<xsl:import xmlns:dita="http://dita-ot.sourceforge.net" href="../../../../../../../../../../../xsl/collapse-min.xsl"/>
Code: Select all
<xsl:import href="plugin:com.gbv.collapse:xsl/collapse.xsl"/>
I wonder why it isn't correctly targeted.
------
Gaspard
Gaspard
-
- Posts: 922
- Joined: Thu May 02, 2019 2:32 pm
Re: Custom attribute not pushed in the XHTML map
Post by chrispitude »
Can you attach a .zip of the latest version of your plugin, and I'll see if it happens here too?
-
- Posts: 105
- Joined: Thu Jan 20, 2022 12:36 pm
Re: Custom attribute not pushed in the XHTML map
Sure!
Here it is attached.
I'm curious to see if you'd have the same behavior.
Here it is attached.
I'm curious to see if you'd have the same behavior.
com.gbv.collapse.zip
You do not have the required permissions to view the files attached to this post.
------
Gaspard
Gaspard
-
- Posts: 922
- Joined: Thu May 02, 2019 2:32 pm
Re: Custom attribute not pushed in the XHTML map
Post by chrispitude »
Yes, I get the same behavior.
In plugin.xml, can you try using file= for your file references and see if it works for you?
In plugin.xml, can you try using file= for your file references and see if it works for you?
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<plugin id="com.gbv.collapse">
<feature extension="dita.specialization.catalog.relative" file="catalog.xml"/>
<feature extension="dita.xsl.xhtml" file="./xsl/collapse-min.xsl"/>
</plugin>
-
- Posts: 105
- Joined: Thu Jan 20, 2022 12:36 pm
Re: Custom attribute not pushed in the XHTML map
Ok, I'm back with a minor issue.
I use the following xsl snippets to manage my custom attribute
However, I notice that the is not processed.
If I declare:
it will pass in the transformation.
Another interesting fact if I add a namespace:
The result will display:
How strange is that? Why the name is conflicting with the process?
I use the following xsl snippets to manage my custom attribute
Code: Select all
<!-- Set data-target-id only -->
<xsl:template name="setdataTargetId">
<xsl:if test="@data-target-id">
<xsl:call-template name="setdataTargetIdattr">
<xsl:with-param name="dataTargetIdvalue" select="@data-target-id"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- Set the dataTargetID attr -->
<xsl:template name="setdataTargetIdattr">
<xsl:param name="dataTargetIdvalue"/>
<xsl:attribute name="data-target-id"
select="dita-ot:get-prefixed-id($dataTargetIdvalue/parent::*, $dataTargetIdvalue)"/>
</xsl:template>
Code: Select all
<xsl:attribute name="data-target-id"
If I declare:
Code: Select all
<xsl:attribute name="dataa-target-id"
it will pass in the transformation.
Another interesting fact if I add a namespace:
Code: Select all
<xsl:attribute name="data-target-id" namespace="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
Code: Select all
<p xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot" class="p ft-expanding-block-link" dita-ot:data-target-id="testingHere">Link to click</p>
------
Gaspard
Gaspard
-
- Posts: 9438
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Custom attribute not pushed in the XHTML map
Hi,
That's kind of intentional, you are publishing DITA to XHTML, that XHTML needs to be valid according to the XHTML specification which did not allow data-* attributes on elements.
So the DITA Open Toolkit's XHTML plugin has a template in the stylesheet "DITA-OT3.x/plugins/org.dita.xhtml/xsl/dita2html-util.xsl" which strips all HTML5 attributes:
If you would publish DITA to HTML5, the filter would not apply and allow data- attributes to make it through.
Regards,
Radu
That's kind of intentional, you are publishing DITA to XHTML, that XHTML needs to be valid according to the XHTML specification which did not allow data-* attributes on elements.
So the DITA Open Toolkit's XHTML plugin has a template in the stylesheet "DITA-OT3.x/plugins/org.dita.xhtml/xsl/dita2html-util.xsl" which strips all HTML5 attributes:
Code: Select all
<xsl:template match="@*[starts-with(name(), 'data-')]" mode="remove-html5" priority="10"/>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 105
- Joined: Thu Jan 20, 2022 12:36 pm
Re: Custom attribute not pushed in the XHTML map
Ok, I understand. Thanks for pointing that out. For now, I just changed the nature of the string in the utils xsl.
I have a correct rendering of the attribute.
Yet, I wonder if there's any way to remove the p attribute class as shown below:
<p class="p ft-expanding-block-link" data-target-id="test-koko">
I checked in and I have tried to deactivate it in the declaration of the attributes.
I have a correct rendering of the attribute.
Yet, I wonder if there's any way to remove the p attribute class as shown below:
<p class="p ft-expanding-block-link" data-target-id="test-koko">
I checked in
Code: Select all
org.oasis-open.dita.v1_3/base/dtd/commonElements.mod
image.png
But I got errors and I don't think it is possible to get rid of this class.You do not have the required permissions to view the files attached to this post.
------
Gaspard
Gaspard
-
- Posts: 9438
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Custom attribute not pushed in the XHTML map
Hi,
Is there a reason in particular you do not want that part of the @class attribute value to be present there? Does it impede rendering the HTML in the browser in any way?
Modifying the DITA DTD is the wrong way to go, editing tools like Oxygen rely on the DTD and on default @class attribute values to properly identify elements, the publishing engine also does. Also the DTD is given by the DITA specification committee, once you modify the DTD officially you are no longer working with DITA XML documents.
If you edit in Oxygen the transformation scenario you are using to publish, in the Parameters list there should be a parameter named "args.xhtml.classattr" which should remove that fragment from all class attributes in the generated HTML docs.
https://www.dita-ot.org/dev/parameters/ ... .classattr
Regards,
Radu
Is there a reason in particular you do not want that part of the @class attribute value to be present there? Does it impede rendering the HTML in the browser in any way?
Modifying the DITA DTD is the wrong way to go, editing tools like Oxygen rely on the DTD and on default @class attribute values to properly identify elements, the publishing engine also does. Also the DTD is given by the DITA specification committee, once you modify the DTD officially you are no longer working with DITA XML documents.
If you edit in Oxygen the transformation scenario you are using to publish, in the Parameters list there should be a parameter named "args.xhtml.classattr" which should remove that fragment from all class attributes in the generated HTML docs.
https://www.dita-ot.org/dev/parameters/ ... .classattr
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 105
- Joined: Thu Jan 20, 2022 12:36 pm
Re: Custom attribute not pushed in the XHTML map
Oh, yes, Radu, you are definitely right.
However, the reason why I have been looking for this option is that I am forced to make the generation compatible with a script I have no control over. And as for the moment, before giving feedback to the developers who integrated the javascript function into the core of their product, I would like to make sure that my plugin is fully operational.
While testing with handwritten HTML, I found that the "<p class="p" was disrupting the function to operate.
This can be handled later, but the latencies of working with developers being more complex and important than for me, on my side, directly producing a working test content.
So I will test the class.attrs parameter in my publication.
Thanks a lot
However, the reason why I have been looking for this option is that I am forced to make the generation compatible with a script I have no control over. And as for the moment, before giving feedback to the developers who integrated the javascript function into the core of their product, I would like to make sure that my plugin is fully operational.
While testing with handwritten HTML, I found that the "<p class="p" was disrupting the function to operate.
This can be handled later, but the latencies of working with developers being more complex and important than for me, on my side, directly producing a working test content.
So I will test the class.attrs parameter in my publication.
Thanks a lot

------
Gaspard
Gaspard
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