[oXygen-user] Custom action to process a document and update an element?

George Cristian Bina george at oxygenxml.com
Thu Nov 21 00:13:38 CST 2013


Hi Eliot,

We can have this only in Author mode. There are requests to provide 
similar support for custom actions as we have in Author also for the 
Text editing mode and we are considering this for the future.

We have a "Relax NG" document type, in [oXygen]/frameworks/relaxng that 
you can edit from Options->Preferences -- Document Type Associations -- 
Relax NG. There you can edit the Relax NG framework and go to the Author 
tab then select the Actions subtab and define a custom action that will 
be active if the current node is a "define" element with a "name" 
attribute equal to "domains-atts", that means the XPath expression that 
activates the operation should be
   *:define[@name='domains-atts']
and then use the XSLTOperation configured as follows:

sourceLocation - the root element: /*

insertLocation - the current element, that will be the define with a 
name equals to domains-atts

script -

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="2.0">
   <xsl:import href="scripts/updateDomainsAttribute.xsl"/>
</xsl:stylesheet>

action - Replace

Then add in [oXygen]/frameworks/relaxng/scripts the 
updateDomainsAttribute.xsl that takes as input the schema and it should 
output the domains-att pattern. When the action is executed this pattern 
will replace the existing pattern from the schema.

Now, you need to make the action available, and you can add it to the 
toolbar, to the menu, to the contextual menu, to the content completion 
proposals or to appear inline in the editor. The first except the last 
option see the Menu, Contextual Menu, Toolbar and Content Completion 
tabs in the edit framework dialog, immediately after the Actions tab 
that you used to setup the custom action. For making the action 
available inline you need to edit the 
frameworks/relaxng/relaxng-main.css to add a rule that will match this 
pattern and then use  :before or :after to add in the content property a 
button control linked to the action you defined

content: oxy_button(actionID, 'updateDomainsAtt');

If you follow this and encounter issues I will be happy to help.

Best Regards,
George
--
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

On 11/20/13, 7:05 AM, Eliot Kimber wrote:
> For the DITA RelaxNG support that will be in DITA 1.3 I want to implement
> an action that can be applied to RNG document type shell grammars that
> looks at each referenced module, gets its domains attribute contribution
> (which will be in a specific subelement within the referenced module, and
> add it to the right place in the shell (a pattern named “domains-att”).
>
> This is of course easy to do with XSLT.
>
> My question: what’s the best way to set this up in Oxygen so that I can
> just do an “update domains attribute” action when editing a document type
> shell schema?
>
> Thanks,
>
> Eliot
>


More information about the oXygen-user mailing list