Class TransformOperation
- java.lang.Object
-
- ro.sync.ecss.extensions.commons.operations.TransformOperation
-
- All Implemented Interfaces:
AuthorOperation
,Extension
- Direct Known Subclasses:
XQueryOperation
,XSLTOperation
@API(type=EXTENDABLE, src=PUBLIC) public abstract class TransformOperation extends java.lang.Object implements AuthorOperation
An implementation of an operation to apply a script (XSLT or XQuery) on a element and replacing it with the result of the transformation or inserting the result in the document.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ACTION_AT_CARET
The name of the operation action indicating that the transformation result should be inserted at the caret position.static java.lang.String
ACTION_INSERT_AFTER
The name of the operation action indicating that the transformation result should be inserted after the target node.static java.lang.String
ACTION_INSERT_AS_FIRST_CHILD
The name of the operation action indicating that the transformation result should be inserted as the first child of the target node.static java.lang.String
ACTION_INSERT_AS_LAST_CHILD
The name of the operation action indicating that the transformation result should be inserted as the last child of the target node.static java.lang.String
ACTION_INSERT_BEFORE
The name of the operation action indicating that the transformation result should be inserted before the target node.static java.lang.String
ACTION_REPLACE
The name of the operation action indicating a replace of the target node with the result of the transformation.protected java.lang.String
ARGUMENT_SCRIPT
The XSLT or XQuery script.static java.lang.String
ARGUMENT_SCRIPT_PARAMETERS
External parameters argument.static java.lang.String
CARET_POSITION_AFTER
Constant for the caret position indicating that the caret should be positioned just after the inserted fragment.static java.lang.String
CARET_POSITION_BEFORE
Constant for the caret position indicating that the caret should be positioned just before the inserted fragment.static java.lang.String
CARET_POSITION_EDITABLE
Constant for the caret position indicating that the caret should be positioned just at the start of the inserted fragment, in the first editable position.static java.lang.String
CARET_POSITION_END
Constant for the caret position indicating that the caret should be positioned just at the end of the inserted fragment, inside that fragment.static java.lang.String
CARET_POSITION_PRESERVE
Constant for the caret position indicating that the same caret position offset should be preserved.static java.lang.String
CARET_POSITION_START
Constant for the caret position indicating that the caret should be positioned just at the start of the inserted fragment, inside that fragment.static java.lang.String
CURRENT_ELEMENT_LOCATION
The name of a parameter containing the location path of the current element inside the source element.-
Fields inherited from interface ro.sync.ecss.extensions.api.AuthorOperation
NAMESPACE_ARGUMENT, NAMESPACE_ARGUMENT_DESCRIPTOR, SCHEMA_AWARE_ARGUMENT, SCHEMA_AWARE_ARGUMENT_DESCRIPTOR
-
-
Constructor Summary
Constructors Constructor Description TransformOperation()
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean
canTreatAsScript(java.lang.String script)
protected abstract javax.xml.transform.Transformer
createTransformer(AuthorAccess authorAccess, javax.xml.transform.Source scriptSrc)
Creates a Transformer from a given script.protected javax.xml.transform.Transformer
createTransformer(AuthorAccess authorAccess, javax.xml.transform.Source scriptSrc, ro.sync.ecss.extensions.commons.operations.ElementLocationPath location)
Creates a Transformer from a given script.void
doOperation(AuthorAccess authorAccess, ArgumentsMap args)
Applies the transformation and executes the specified action with the result.ArgumentDescriptor[]
getArguments()
java.lang.String
getDescription()
-
-
-
Field Detail
-
CURRENT_ELEMENT_LOCATION
public static final java.lang.String CURRENT_ELEMENT_LOCATION
The name of a parameter containing the location path of the current element inside the source element. This can be accessed in the script to perform context sensitive actions.- See Also:
- Constant Field Values
-
ACTION_REPLACE
public static final java.lang.String ACTION_REPLACE
The name of the operation action indicating a replace of the target node with the result of the transformation.- See Also:
- Constant Field Values
-
ACTION_AT_CARET
public static final java.lang.String ACTION_AT_CARET
The name of the operation action indicating that the transformation result should be inserted at the caret position.- See Also:
- Constant Field Values
-
ACTION_INSERT_BEFORE
public static final java.lang.String ACTION_INSERT_BEFORE
The name of the operation action indicating that the transformation result should be inserted before the target node.- See Also:
- Constant Field Values
-
ACTION_INSERT_AFTER
public static final java.lang.String ACTION_INSERT_AFTER
The name of the operation action indicating that the transformation result should be inserted after the target node.- See Also:
- Constant Field Values
-
ACTION_INSERT_AS_FIRST_CHILD
public static final java.lang.String ACTION_INSERT_AS_FIRST_CHILD
The name of the operation action indicating that the transformation result should be inserted as the first child of the target node.- See Also:
- Constant Field Values
-
ACTION_INSERT_AS_LAST_CHILD
public static final java.lang.String ACTION_INSERT_AS_LAST_CHILD
The name of the operation action indicating that the transformation result should be inserted as the last child of the target node.- See Also:
- Constant Field Values
-
CARET_POSITION_PRESERVE
public static final java.lang.String CARET_POSITION_PRESERVE
Constant for the caret position indicating that the same caret position offset should be preserved.- See Also:
- Constant Field Values
-
CARET_POSITION_BEFORE
public static final java.lang.String CARET_POSITION_BEFORE
Constant for the caret position indicating that the caret should be positioned just before the inserted fragment.- See Also:
- Constant Field Values
-
CARET_POSITION_START
public static final java.lang.String CARET_POSITION_START
Constant for the caret position indicating that the caret should be positioned just at the start of the inserted fragment, inside that fragment.- See Also:
- Constant Field Values
-
CARET_POSITION_EDITABLE
public static final java.lang.String CARET_POSITION_EDITABLE
Constant for the caret position indicating that the caret should be positioned just at the start of the inserted fragment, in the first editable position.- See Also:
- Constant Field Values
-
CARET_POSITION_END
public static final java.lang.String CARET_POSITION_END
Constant for the caret position indicating that the caret should be positioned just at the end of the inserted fragment, inside that fragment.- See Also:
- Constant Field Values
-
CARET_POSITION_AFTER
public static final java.lang.String CARET_POSITION_AFTER
Constant for the caret position indicating that the caret should be positioned just after the inserted fragment.- See Also:
- Constant Field Values
-
ARGUMENT_SCRIPT
protected java.lang.String ARGUMENT_SCRIPT
The XSLT or XQuery script. The value isscript
.
-
ARGUMENT_SCRIPT_PARAMETERS
public static final java.lang.String ARGUMENT_SCRIPT_PARAMETERS
External parameters argument. Pairs key=value separated by comma or new line.- See Also:
- Constant Field Values
-
-
Method Detail
-
doOperation
public void doOperation(AuthorAccess authorAccess, ArgumentsMap args) throws AuthorOperationException
Applies the transformation and executes the specified action with the result.- Specified by:
doOperation
in interfaceAuthorOperation
- Parameters:
authorAccess
- The author access. Provides access to specific informations and actions for editor, document, workspace, tables, change tracking, utility a.s.o.args
- The map of arguments. All the arguments defined by methodAuthorOperation.getArguments()
must be present in the map of arguments.- Throws:
AuthorOperationException
- Thrown when the operation fails.- See Also:
AuthorOperation.doOperation(AuthorAccess, ArgumentsMap)
-
canTreatAsScript
protected boolean canTreatAsScript(java.lang.String script)
- Parameters:
script
- The value of the script parameter.- Returns:
true
if this is an actual script orfalse
if it isn't.
-
createTransformer
protected abstract javax.xml.transform.Transformer createTransformer(AuthorAccess authorAccess, javax.xml.transform.Source scriptSrc) throws javax.xml.transform.TransformerConfigurationException
Creates a Transformer from a given script.- Parameters:
authorAccess
- Access to different Author resources.scriptSrc
- The XSLT or XQuery script.- Returns:
- A JAXP Transformer that will perform the transformation defined in the given script.
- Throws:
javax.xml.transform.TransformerConfigurationException
-
createTransformer
protected javax.xml.transform.Transformer createTransformer(AuthorAccess authorAccess, javax.xml.transform.Source scriptSrc, ro.sync.ecss.extensions.commons.operations.ElementLocationPath location) throws javax.xml.transform.TransformerConfigurationException
Creates a Transformer from a given script.- Parameters:
authorAccess
- Access to different Author resources.scriptSrc
- The XSLT or XQuery script.location
- The location of the "current" element.- Returns:
- A JAXP Transformer that will perform the transformation defined in the given script.
- Throws:
javax.xml.transform.TransformerConfigurationException
-
getArguments
public ArgumentDescriptor[] getArguments()
- Specified by:
getArguments
in interfaceAuthorOperation
- Returns:
- An array of
ArgumentDescriptor
representing the arguments this operation uses. - See Also:
AuthorOperation.getArguments()
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescription
in interfaceExtension
- Returns:
- The description of the extension.
- See Also:
Extension.getDescription()
-
-