Customizing elements and attributes

Post here questions and problems related to editing and publishing DITA content.
SunilCP
Posts: 10
Joined: Wed Jan 04, 2023 8:44 am

Customizing elements and attributes

Post by SunilCP »

Hello All,
How do I customize the concept.dtd file?
I want my writers not to use certain elements. That particular element should not display in the list of elements that my writer can select.
For example, in the concept topic, <shortdesc> element should not be available for my writers to select and use.
Also, how to customize the attributes for any elements?
Any insights on how to control these?
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: Customizing elements and attributes

Post by chrispitude »

Hi Sunil,

You can configure a cc_config_ext.xml file as described here:

Configuring the Proposals for Elements and Attributes

then add an entry like this:

Code: Select all

<elementProposals rejectElements="shortdesc"/>
If you want a quick way to experiment with this, you can use the testcase provided here. It was made to test a different behavior, but it still provides an extended framework with a cc_config_ext.xml file that is ready for you to experiment with.
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Customizing elements and attributes

Post by Radu »

Hi,
There is also the possibility to create a DTD specialization plugin, there are some tutorials linked here, but it's something which takes time:
https://www.oxygenxml.com/doc/versions/ ... ation.html
Other than that, as Chris says, you can filter certain elements from being used directly from Oxygen with a framework customization, either with a content completion configuration file or by adding that element in a special list of elements which should be removed from the content completion:
https://blog.oxygenxml.com/topics/custo ... etion.html
About this:
Also, how to customize the attributes for any elements?
If you just want to control attribute values, you can do that with a content completion configuration file or with a Subject Scheme map:
https://blog.oxygenxml.com/topics/contr ... alues.html
If you want to add new attributes then you would need to create a DTD specialization plugin.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: Customizing elements and attributes

Post by chrispitude »

Hi Sunil,

If you are open to using a RelaxNG grammar instead of a DTD grammar, you could use make_dita_grammar.pl, located here:

chrispy-snps/DITA-plugin-utilities (github.com)

with an input file like this:

Code: Select all

<plugin directory="./com.mycompany.docshell" uri_prefix="com:mycompany:docshell">

 <attributedomain filename="paginateAttMod.rng" domain="paginate">
  <specialize attribute="paginate" from="base" model="(keep-with-next|keep-with-previous|top-of-page|keep-together|allow-breaks-inside)*"/>
 </attributedomain>

 <constraint filename="myConstraint.rng" domain="my-c">
  <include_domains>topic hi-d indexing-d sw-d pr-d ui-d ut-d mathml-d deliveryTarget paginate</include_domains>
  <allow domain="hi-d" elements="sup sub"/>
  <disallow elements="shortdesc vrm vrmlist"/>
</constraint>

 <topicshell filename="myGlossaryShell.rng">
  <title>My Glossary</title>
  <root_element>glossgroup</root_element>
  <include_domains>my-c glossgroup glossentry</include_domains>
 </topicshell>

 <topicshell filename="myTopicShell.rng">
  <title>My Topic</title>
  <root_element>topic</root_element>
  <include_domains>my-c</include_domains>
 </topicshell>

</plugin>
In the constraint module definition, the <disallow> element disallows the specified elements in the grammar. The <allow> element allows only certain elements from a domain, disallowing all other elements in that domain.

This example also specializes a @paginate attribute with certain predefined values.
Post Reply