Content completion for specialized table row

Post here questions and problems related to oXygen frameworks/document types.
jeff_hooker
Posts: 10
Joined: Tue Jun 11, 2019 9:01 pm

Content completion for specialized table row

Post by jeff_hooker » Sat Aug 24, 2019 12:59 am

Hi folks,

First question; is there a guide to the schema for your framework files? When I google element names I come up dry; even when I search your site for information about elements I come up dry.

Second, I'm trying to create a content completion template for a specialized table row. This is what I've done. The reg-reference element in the specialized DTD takes the place of the row element, and the tbody element is replaced by a reg-references element.

Code: Select all

<actionMode>
	<field name="xpathCondition">
		<String>ancestor-or-self::node()[self::*contains(@class," firmware-d/reg-reference ")]]</String>
		</field>
	<field name="argValues">
	<serializableOrderedMap>
	<entry>
			<String>insertLocation</String>
			<String>ancestor-or-self::*[contains(@class," firmware-d/reg-reference ")][1]</String>
			</entry>
			<entry>
			<String>insertPosition</String>
			<String>After</String>
			</entry>	
			<entry>
				<String>fragment</String>
				<String>	
						&lt;reg-reference>
						&lt;reg-address> &lt;/reg-address>
						&lt;reg-size> &lt;reg-size>
						&lt;reg-name>Name&lt;/reg-name>
						&lt;reg-details>
						&lt;p/>
						&lt;/reg-details>	
						&lt;/reg-reference>
				</String>
			</entry>
		</serializableOrderedMap>
	</field>
	<field name="operationID">										<String>ro.sync.ecss.extensions.commons.table.operations.cals.InsertSingleRowOperation</String>
</field>
</actionMode>
My DTD requires one of either a p, ol, or ul in the <reg-details> element and so I'm trying to force a <p> element. So far, the addition is being ignored. I'm just extrapolating what I think the actionMode element should look like by reading the rest of the .framework files, because I can't find where this format is documented.

Thanks,
Jeff.

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

Re: Content completion for specialized table row

Post by Radu » Mon Aug 26, 2019 9:52 am

Hi Jeff,
First question; is there a guide to the schema for your framework files? When I google element names I come up dry; even when I search your site for information about elements I come up dry.
Do you mean specific documentation for each DITA element?
The DITA 1.3 specification is also available on the Oxygen XML web site along with quick references for all DITA elements:

https://www.oxygenxml.com/dita/1.3/spec ... rence.html

Also in the Author visual editing mode if you press F2 when the caret is inside a DITA element you will have a tooltip window showing documentation and links to the specification.
Second, I'm trying to create a content completion template for a specialized table row. This is what I've done. The reg-reference element in the specialized DTD takes the place of the row element, and the tbody element is replaced by a reg-references element.
I will assume you created a DITA DTD specialization and Oxygen uses it when you open the DITA topic, for example if a "reg-references" element is already inserted in the document Oxygen does not report validation errors for it.
What you want is not achievable by defining a custom Author action because actions need to be triggered but you want some kind of content to be automatically inserted when the "reg-references" element is inserted.
Instead, we have a separate "cc_config.xml" file in the DITA framework ("OXYGEN_INSTALL_DIR\frameworks\dita\resources") in which you can define the possible elements which should be automatically inserted when a parent element is inserted:

https://www.oxygenxml.com/doc/versions/ ... g_elements

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

jeff_hooker
Posts: 10
Joined: Tue Jun 11, 2019 9:01 pm

Re: Content completion for specialized table row

Post by jeff_hooker » Mon Aug 26, 2019 7:17 pm

Thanks Radu,

For the record, I was asking about documentation for the elements of your framework files (actionMode, serializableOrderedMap, etc.) not DITA. There's lots of help available for DITA.

Cheers,
Jeff.

jeff_hooker
Posts: 10
Joined: Tue Jun 11, 2019 9:01 pm

Re: Content completion for specialized table row

Post by jeff_hooker » Tue Aug 27, 2019 12:34 am

Ok, so let's try this again.

Currently, Author does recognize and validate my specializations. However, when I try to use the Add Row command, Author responds by by adding a whole new tbody element at the bottom of the table and adding a conventional CALS row within it.

From poking around in the .framework file, it looks like these functions are controlled by actionmode elements, so I appended a "not" statement to the actionmode element for inserting a new row after a row in order to exclude my specialized rows:

Code: Select all

<actionMode>
													<field name="xpathCondition">
														<String>ancestor-or-self::node()[self::*[contains(@class," topic/row ") or contains(@class," topic/strow ") or contains(@class, " topic/sthead ")]][1][self::*[contains(@class," topic/row ")]][not(self::*[contains(@class, "firmware-d/reg-reference")] or self::*[contains(@class, "struct-d/dword")] or self::*[contains(@class, "software-d/field")] or self::*[contains(@class, "struct-d/include")] or self::*[contains(@class, "firmtest-d/test")] or self::*[contains(@class, "m-software-d/register-reference")])]</String>
													</field>
													<field name="argValues">
														<serializableOrderedMap>
															<entry>
																<String>insertLocation</String>
																<String>ancestor-or-self::*[contains(@class," topic/row ")][1]</String>
															</entry>
															<entry>
																<String>insertPosition</String>
																<String>After</String>
															</entry>
														</serializableOrderedMap>
													</field>
													<field name="operationID">
														<String>ro.sync.ecss.extensions.commons.table.operations.cals.InsertSingleRowOperation</String>
													</field>
												</actionMode>
And then I tried to write an actionmode element that would apply to one of my specializations:

Code: Select all

<actionMode>
													<field name="xpathCondition">
														<String>ancestor-or-self::node()[self::*[contains(@class," firmware-d/reg-reference ")]]</String>
													</field>
													<field name="argValues">
														<serializableOrderedMap>
															<entry>
																<String>insertLocation</String>
																<String>ancestor-or-self::node()[*[contains(@class," firmware-d/reg-reference ")]][1]</String>
															</entry>
															<entry>
																<String>insertPosition</String>
																<String>After</String>
															</entry>	
															<entry>
																<String>fragment</String>
																<String>	
																	&lt;reg-reference>
																	&lt;reg-address> &lt;/reg-address>
																	&lt;reg-size> &lt;reg-size>
																	&lt;reg-name>Name&lt;/reg-name>
																	&lt;/reg-details>
																	&lt;/reg-reference>
																</String>
															</entry>
														</serializableOrderedMap>
													</field>
														<field name="operationID">
														<String>ro.sync.ecss.extensions.commons.table.operations.cals.InsertSingleRowOperation</String>
													</field>
												</actionMode>
However, Author's behavior remains unchanged.

Looking at the actionmode elements, it is pretty clear that the xpathcondition field is used to identify the target nodes, and the operationID field element is used to call the java function, however, the syntax available to me in between remains a bit of a mystery.

Is there a relationship between the fields in the actionmode element and parameters of the java class being called (https://www.oxygenxml.com/InstData/Edit ... ation.html)?

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

Re: Content completion for specialized table row

Post by Radu » Tue Aug 27, 2019 8:58 am

Hi Jeff,

About this remark:
For the record, I was asking about documentation for the elements of your framework files (actionMode, serializableOrderedMap, etc.)
This is just an XML format in which we serialize the framework configuration objects, we usually expect that the ".framework" file be modified through our user's interface, by editing the framework in the "Document Type Association" preferences page. This is why we do not document the serialization format.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

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

Re: Content completion for specialized table row

Post by Radu » Tue Aug 27, 2019 2:03 pm

Hi Jeff,

Coming back to your table specializations:

If in the Oxygen Preferences->"Document Type Associations" page you edit your DITA framework configuration, in the Author->Actions tab there is the "insert.table.row.below" action definition. The action definition has about 5 xpath activation modes, in each mode it calls a Java operation. You can add your own activation modes for your own table structure.
The "ro.sync.ecss.extensions.dita.topic.table.cals.InsertSingleRowOperation" Java operation works well for CALS tables which have certain names for rows and cells but for your specific specializations you will probably need to create your own "CustomInsertSingleRowOperation" which overrides from the super class the "getRowElementName" and "getCellElementName" methods and return the proper names for your table specialization.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

jeff_hooker
Posts: 10
Joined: Tue Jun 11, 2019 9:01 pm

Re: Content completion for specialized table row

Post by jeff_hooker » Tue Sep 03, 2019 8:07 pm

Ok, so just make sure I'm not misunderstanding this, it sounds like you're saying that the only way to add the "add row" feature to my table specializations in Oxygen is to literally write my own custom Java classes and add them to the configuration. Correct?

I can do that, but it seems intense for something as ordinary as dealing with a dita specialization. I'm surprised that there's not a generalized class that just adds whatever the DTD says is valid or plugs in a fragment template.

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

Re: Content completion for specialized table row

Post by Radu » Wed Sep 04, 2019 1:57 pm

Hi Jeff,

Looking upper in this thread, I found this previously unanswered question:
Is there a relationship between the fields in the actionmode element and parameters of the java class being called
No, there is not. An action can have multiple action modes, each action mode has an activation XPath expression and an Author operation which can be invoked with certain parameters.
When you press the action button on the toolbar, Oxygen looks in the list of action modes defined inside the Author action for the first action mode for which the XPath activation expression evaluates as positive. When found, it invokes for that action mode the corresponding author operation with the parameters you have set.
I'm surprised that there's not a generalized class that just adds whatever the DTD says is valid or plugs in a fragment template.
There are two table types which can be inserted in a DITA topic: CALS and simple table. I will assume yours is a CALS table specialization, if it's a simple table specialization I will need to look again into this as it calls a distinct operation.
The action with ID "insert.table.row.below" is the one called by default when you invoke the toolbar action for inserting a table row. When the caret is placed inside an existing table the action will call the existing "ro.sync.ecss.extensions.dita.topic.table.cals.InsertSingleRowOperation" Java operation. This operation by default looks if the cursor is placed inside a table row and if it is, it will duplicate that table row along with its cells (with empty content) and then insert the table row. So if the cursor is inside an existing table cell and you use the action you should get a row with your specialization names inserted.
If the cursor is not an existing table row, the action will create a new table row with the name <row> and with the cells named <entry>. Indeed we should work more to make this behavior more specialization friendly or at least add parameters to control the row and cell names, I added an issue for it.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply