How to change what is inserted for an element

mattwolfe
Posts: 26

How to change what is inserted for an element

Thu Apr 26, 2012 5:42 pm

Hi all. Sorry if this is in the incorrect forum.

In our OT implementation, we need to have a <p> element inside a <stepresult> element (and some others, but I'll stick to <stepresult> for this question). Right now, when I insert a <stepresult>, I have to remember to also insert a <p> inside the <stepresult>. Is there a way to configure Oxygen so the <p> is automatically inserted along with the <stepresult>?

Incidentally, I do have a code template defined that will insert this, but there's no validation on the code template (meaning, I can pick it no matter where the cursor is located and no matter what type of topic I'm editing). Ideally, I would like to change the default behavior of inserting a <stepresult> so it includes a <p> element, thus using validation.

Is this possible? Thanks!
mihaela
Posts: 189

Re: How to change what is inserted for an element

Fri Apr 27, 2012 12:39 pm

Hi,

This type of restrictions must be imposed from schema associated with document type (in your case DITA).
For example, the DITA-OT schema specifies that the <p> element is optional in a <stepresult> context (see [DITA_OT_dir]/dtd/technicalContent/dtd/task.mod). So, to change the type of p child from optional to required you have to change the stepresult content declaration from:

Code: Select all

<!ENTITY % stepresult.content
                       "(%itemgroup.cnt;)*"

into something like:

Code: Select all

<!ENTITY % stepresult.content
                       "(p, (
                       dl|parml|
                       fig|syntaxdiagram|
                       imagemap|image|
                       lines|lq|
                       note|hazardstatement|
                       object|ol|
                       p|pre|codeblock|
                       msgblock|screen|
                       simpletable|sl|table
                       |ul|boolean|cite
                       |keyword|apiname|option|
                       parmname|cmdname|msgnum|
                       varname|wintitle|ph|
                       b|i|sup|sub|tt|u|
                       codeph|synph|filepath|
                       msgph|systemoutput|userinput|
                       menucascade|uicontrol|q
                       |term|abbreviated-form|
                       tm|xref|state|data|
                       data-about|foreign|unknown|
                       draft-comment|fn|indextermref|
                       indexterm|required-cleanup)*)"
>

After you make this modification, the <p> child will be automatically inserted in <stepresult> by the content completion in oXygen editor, in a DITA file.

Please note that changing directly the DITA-OT schema is not the best way to work because it is possible to loose this modifications on a future DITA-OT update. The best way to do is to create your DITA specialization that overrides the default element definition for <stepresult> from the DITA-OT.
You can read more about DITA Specialization Support on our online documentation:
http://www.oxygenxml.com/doc/ug-editor/ ... pport.html

Another possibility to impose the <p> child when inserting the <stepresult> element is to use the Author SDK:
http://www.oxygenxml.com/oxygen_sdk.htm ... horing_SDK
In this case, you can use a ro.sync.ecss.extensions.api.AuthorDocumentFilter to change the fragments that are inserted in the document.
Here is the javadoc for this API:
http://www.oxygenxml.com/InstData/Edito ... ilter.html
If you choose this way we can give you more details.

Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
mattwolfe
Posts: 26

Re: How to change what is inserted for an element

Fri Apr 27, 2012 6:41 pm

Thanks for you reply. That's a lot to digest. :-) I'll go over the information and see what I can do. Thanks!
Radu
Posts: 5757

Re: How to change what is inserted for an element

Mon Apr 30, 2012 12:12 pm

Hi Matt,

Indeed a code template gets presented in the content completion list no matter in which element the caret is placed.

There is another workaround which could work for you:
In the Document Type Association preferences page, edit the DITA document type.
In the Author tab you can define a new action for inserting a

Code: Select all

<stepresult><p/></stepresult>
fragment and set for the action an XPath expression for the places where you want the action to be active.
As an example you can look at the already defined insert.topic action.

Then in the Content Completion tab you have the possibility to add that new defined action to the content completion window and even to remove the "stepresult" entry provided by Oxygen by looking in the DTDs from the content completion window.

The content completion window will only show added actions if the XPath expression configured when editing the action is fulfilled.

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

Return to “DITA (Editing and Publishing DITA Content)”

Who is online

Users browsing this forum: No registered users and 2 guests