Manipulating XML in text mode
Posted: Fri Nov 06, 2020 12:04 am
Hi,
I am trying to figure out how I could write a plugin action for the text mode which would manipulate some elements or attributes. As far as I can see, the sample plugins in the SDK only demonstrate string manipulation for the text mode (e.g. capitalizing).
The "TextDocumentController" which can be used on "WSXMLTextEditorPage" only has a method for inserting an XML fragment.
Suppose I would like to insert an attribute on a certain element which is already present in the document. Could i use the "evaluateXPath" method on "WSXMLTextEditorPage" to return the element I want to manipulate? The method returns an array of java.lang.Object. Does this mean that in case the items returned by "evaluateXPath" are XML element nodes, I could then manipulate them "in place" as instances of something like "org.w3c.dom.Element"?
Would something like this be the way to go or are there other ways in the API to manipulate XML nodes in text mode?
I am a bloody beginner in the Oxygen SDK, so sorry if I am asking something which is perhaps obvious.
Best wishes,
Jakub
I am trying to figure out how I could write a plugin action for the text mode which would manipulate some elements or attributes. As far as I can see, the sample plugins in the SDK only demonstrate string manipulation for the text mode (e.g. capitalizing).
The "TextDocumentController" which can be used on "WSXMLTextEditorPage" only has a method for inserting an XML fragment.
Suppose I would like to insert an attribute on a certain element which is already present in the document. Could i use the "evaluateXPath" method on "WSXMLTextEditorPage" to return the element I want to manipulate? The method returns an array of java.lang.Object. Does this mean that in case the items returned by "evaluateXPath" are XML element nodes, I could then manipulate them "in place" as instances of something like "org.w3c.dom.Element"?
Would something like this be the way to go or are there other ways in the API to manipulate XML nodes in text mode?
I am a bloody beginner in the Oxygen SDK, so sorry if I am asking something which is perhaps obvious.
Best wishes,
Jakub