Custom Action XPath
Oxygen general issues.
Custom Action XPath
I've created an action using the InsertOrReplaceFragmentOperation. Whereby the user highlights a selection of text and marks up a link. However the schema contraints are that the <link/> tag cannot be nested.
So far I've not been able to work out the XPath to prevent the action from nesting the <link/> tag. I've used "self:para[not(descendant::link)]" but this doesn't work as a link may or may not be already present in the para.
So the question is how do I run the xpath on the selected text? Or do I need to write a custom action which extends the InsertOrReplaceFragmentOperation?
Code: Select all
<para>
The quick brown fox jumped over the <link>lazy</link> dog.
</para>
So the question is how do I run the xpath on the selected text? Or do I need to write a custom action which extends the InsertOrReplaceFragmentOperation?
Re: Custom Action XPath
Hi Neil,
The context for the XPath expression used to activate a certain action is the element at the caret position.
Such cases like detecting if the selection contains certain elements cannot be expressed using just an XPath expression.
You should probably try to set a very permissive XPath for the action like true() and then call a custom AuthorOperation implementation.
The source code for "ro.sync.ecss.extensions.commons.operations.InsertOrReplaceFragmentOperation" is quite simple and should be available in our Author SDK:
http://www.oxygenxml.com/oxygen_sdk.htm ... horing_SDK
Using the API you have the possibility to see how the selection spans, get the parent node for the selection start and end offsets using:
then get access to the child nodes of that parent node by using this method:
and see if the child nodes are links and are in the ranges of that selection.
The ro.sync.ecss.extensions.api.AuthorDocumentController also allows you to run XPaths on the Author nodes structure.
Regards,
Radu
The context for the XPath expression used to activate a certain action is the element at the caret position.
Such cases like detecting if the selection contains certain elements cannot be expressed using just an XPath expression.
You should probably try to set a very permissive XPath for the action like true() and then call a custom AuthorOperation implementation.
The source code for "ro.sync.ecss.extensions.commons.operations.InsertOrReplaceFragmentOperation" is quite simple and should be available in our Author SDK:
http://www.oxygenxml.com/oxygen_sdk.htm ... horing_SDK
Using the API you have the possibility to see how the selection spans, get the parent node for the selection start and end offsets using:
Code: Select all
ro.sync.ecss.extensions.api.AuthorDocumentController.getNodeAtOffset(int)
Code: Select all
ro.sync.ecss.extensions.api.node.AuthorParentNode.getContentNodes()
The ro.sync.ecss.extensions.api.AuthorDocumentController also allows you to run XPaths on the Author nodes structure.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
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