How to change what is inserted for an element
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 26
- Joined: Thu Apr 26, 2012 5:36 pm
How to change what is inserted for an element
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!
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!
-
- Posts: 515
- Joined: Wed May 20, 2009 2:40 pm
Re: How to change what is inserted for an element
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:
into something like:
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
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;)*"
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)*)"
>
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
http://www.oxygenxml.com
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: How to change what is inserted for an element
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 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
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>
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
<oXygen/> XML Editor
http://www.oxygenxml.com
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