Insert Fragment depending of the XML tree
Oxygen general issues.
-
- Posts: 52
- Joined: Thu Dec 15, 2011 7:56 pm
Insert Fragment depending of the XML tree
Hi,
That's it, Eclipse is loaded with the sdk and I'm ready to develop !
I use the operation :
ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation
To insert an XML fragment.
The point is, I have different cases depending the place of the caret in the XML tree.
Example :
Is the operation the good one in this case ?
How can I get the position of my caret in the java class ?
Thank you for your help.
Vincent.
That's it, Eclipse is loaded with the sdk and I'm ready to develop !

I use the operation :
ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation
To insert an XML fragment.
The point is, I have different cases depending the place of the caret in the XML tree.
Example :
Code: Select all
<level1>
<level2>
<level3><my_fragment /></level3>
</level2>
</level1>
- If my caret has a level3 element as parent, I want my_fragment to be inserted inside the current level3.
- If my caret has a level2 element as parent, I want to create a level3 element (as a last child of the current level2) and insert my_fragment in it.
- If my caret has a level1 element as parent, I want to create a level2 element (as a last child of the current level1) with a level3 inside and I want to insert my_fragment in this level3.
Is the operation the good one in this case ?
How can I get the position of my caret in the java class ?
Thank you for your help.
Vincent.
-
- Posts: 515
- Joined: Wed May 20, 2009 2:40 pm
Re: Insert Fragment depending of the XML tree
Hi Vincent,
A solution is to create a single Author action with multiple operations (one operation for each insertion case). You can do this directly from the Document Type Options page, without any other SDK implementation.
To add a new operation use the + button placed in the bottom of the Operations section in the Actions dialog.
For each operation you can define the ro.sync.ecss.extensions.api.AuthorOperation that is invoked (in your case ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation), its arguments and the XPath expression that must be met for this operation to be executed.
Here are the XPath expression and Fragment argument of each operation:
Fragment argument:
Fragment argument:
Fragment argument:
Another solution (that implies a SDK extension) is to use a single operation for your action that uses your custom implementation of ro.sync.ecss.extensions.api.AuthorOperation. In this AuthorOperation you must detect the current context element and insert the corresponding fragment. Please let me know if you want to approach this solution and need more information.
Best regards,
Mihaela
A solution is to create a single Author action with multiple operations (one operation for each insertion case). You can do this directly from the Document Type Options page, without any other SDK implementation.
To add a new operation use the + button placed in the bottom of the Operations section in the Actions dialog.
For each operation you can define the ro.sync.ecss.extensions.api.AuthorOperation that is invoked (in your case ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation), its arguments and the XPath expression that must be met for this operation to be executed.
Here are the XPath expression and Fragment argument of each operation:
XPAth:If my caret has a level3 element as parent, I want my_fragment to be inserted inside the current level3.
Code: Select all
self::level3
Code: Select all
<my_fragment/>
XPAth:If my caret has a level2 element as parent, I want to create a level3 element (as a last child of the current level2) and insert my_fragment in it.
Code: Select all
self::level2
Code: Select all
<level3><my_fragment/></level3>
XPAth:If my caret has a level1 element as parent, I want to create a level2 element (as a last child of the current level1) with a level3 inside and I want to insert my_fragment in this level3.
Code: Select all
self::level1
Code: Select all
<level2><level3><my_fragment/></level3></level2>
Best regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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