Page 1 of 1

outputclass-based content completion

Posted: Tue Sep 28, 2021 8:38 pm
by fjeneau
We have a client that has transitioned from a custom schema to DITA. They are using oXygen 23.1.

Their content has a particular order to it -- an example might be <section><intro/><body/><conclusion/></section>.

They would want to maintain that order in DITA like:

Code: Select all

<section outputclass="about">
	<title>About</title>
	<sectiondiv outputclass="intro">
		<p outputclass="something">....</p>
	</sectiondiv>
	<sectiondiv outputclass="body">
		<p outputclass="somethingElse">...</p>
	</sectiondiv>
	<sectiondiv outputclass="conclusion">
		<p outputclass="maybeSomethingElse">...</p>
	</sectiondiv>
There are potentially 200 different outputclasses.

They relied on the content-completion handler quite a bit in their old schema. I want to make that work for them with DITA, but I don't see a way to configure what they would need in cc_config.xml.

A few examples of what I would want to do are:

Code: Select all

<!-- attempting to specify particular outputclasses on an element in the insertElements attribute -->
<elementProposals path="section" insertElements="title sectiondiv sectiondiv[@outputclass='intro']......."/>
<elementProposals path="section[@outputclass='about']/sectiondiv[@outputclass='intro']" insertElements="p[@outputclass='something']"/>
or

Code: Select all

<!-- attempting to use an alias here -->
<elementProposals path="section[@outputclass='about']" insertElements="Intro"/>
or

Code: Select all

<!-- attempting to 'alias' an element with a particular outputclass -->
<render element="sectiondiv[@outputclass='intro']" as="Intro"/>
I'm pretty sure cc_config.xml will not let me do these things. Do you have any suggestions on how to customize the ccHandler without having to write 200 different actions (pointing to the same AuthorOperation but passing a custom name as a parameter) and adding them here:
image.png

Re: outputclass-based content completion

Posted: Thu Sep 30, 2021 12:50 pm
by alex_jitianu
Hello,

Unfortunately, the cc_config.xml can't express all these relationships. This one, for example:

Code: Select all

<elementProposals path="section[@outputclass='about']/sectiondiv[@outputclass='intro']" insertElements="p[@outputclass='something']"/>
can be expressed as:

Code: Select all

<elementProposals path="section[@outputclass='about']/sectiondiv[@outputclass='intro']" insertElements="p"/>
<elementProposals path="section[@outputclass='about']/sectiondiv[@outputclass='intro']/p">
    <insertAttribute name="outputclass" value="something"/>
</elementProposals>
But for others, like the one below, we can't differentiate between the sectiondiv children because the @path attribute is a limited XPath.

Code: Select all

<elementProposals path="section" insertElements="title sectiondiv sectiondiv[@outputclass='intro']......."/>
Things would have been easier for a specialization, I imagine. If we had elements named Conclusion or Intro then the cc_config.xml file could have been used to express these relationships.

Some possible approaches:

1. Using external author actions and framework script

Author actions can now reside in dedicated files, each file representing an action. You can have a script of your own, perhaps an XSLT, that generates all these 200 actions.

Afterwards, you create a framework extension script that extends the built-in DITA framework and customizes the content completion. Again, you can use a script to generate this framework extension script.

2. Use our Java-based API to customize content completion

You can configure content completion through the API. You have access there to the entire elements context so you can decide what fragment to create. The SDFElement from the sample code is present in the oxygen-sample-framework from the Oxygen SDK. Use its addGuessElement(CIElement) method to create the fragment structure. If you need more help with this, just let me know and I can create a sample code.

Best regards,
Alex

Re: outputclass-based content completion

Posted: Tue Oct 05, 2021 2:06 pm
by chrispitude
Hi fjeneau,

We do something similar to this, but we use DITA specialization. Using the following utility:

https://github.com/chrispy-snps/DITA-plugin-utilities

we specialize a variety of elements from <bodydiv>:

Code: Select all

<specialize elements="returns-section arguments-section short-description usageerrors-section command-group-section example-section example-subsection shortcut-section library-section gui-section license-section syntax-section syntax-default description-section whatnext-section shortdesc-section datatypes-section" from="bodydiv"/>
Now we can reference these specialized elements in the cc_config.xml file. (We specialized from <bodydiv> instead of <section>, but I suspect either could work as their valid locations are similar.)

These specialized elements get automatic subtitles prepended to them. In the Oxygen editor, we use CSS to add the subtitles:

Code: Select all

@media oxygen {  /* add section subtitles in editor */
    *[class ~= "snps-d/description-section"]::before {
        display: block;
        content: "Description";
        font-weight: bold;
    }
    ...
}
For publishing, we have an HTML5 plugin that similarly adds the titles in the transformation output.

Is element specialization an option for you? If so, I could give you an example file to plug into the utility to create a plugin for experimentation.