Kaizou actions

The actions supported by Kaizou are listed below.

<set-attr> action

The <set-attr> action allows you to set an attribute on the nodes specified using <xpath>. It contains two children used to specify:

  • the <name> of the attribute,
  • the <value> of the attribute.

Below is a sample set-attr action that sets the src attribute of an img (of course you must have properly selected the image node using the <xpath> tag):

<set-attr>
<name>src</pattern>
<value>http://www.example.com/image.gif</substitution>
</set-attr>

<regexp-data> action

The <regexp-data> action allows you to modify the text data of text nodes specified using <xpath>. This action uses the Regexp syntax to express text replacements. The action has two children used to specify:

  • the regexp <pattern>,
  • the regexp <substitution>.

Note: Patterns capture is supported, meaning that you can capture some data by specifying parenthesis in <pattern> and use them in <substitution> using the special $1 to $9 variables.

Below is a sample regexp-data action that replaces Linus Thorwald by Linus “Linux” Thorwald (if you find it silly, well … it’s just an example !):

<regexp-data>
<pattern>/(linus) (thorwald)/gi</pattern>
<substitution>$1 "Linux" $2</substitution>
</regexp-data>

You can find here a good introduction to regexps.

<comment> action

The <comment> action allows you to define a comment on a part of a text data. This action uses the Regexp syntax to select the text to comment. It contains two children used to specify:

  • the text <pattern> to comment,
  • the comment <message>.

Below is a sample comment action that reminds you of a famous Linus Torwalds quote.

<comment>
<pattern>/linus torwalds/gi</pattern>
<message>Software is like sex: it is better when it is free.</message>
</comment>

<img-over> action

The <img-over> action allows you to insert an overlay image in a document. You can specify the image size and its position, relative to the node targeted by the <xpath> expression specified in the parent transformation. It contains the following children:

  • the image URL (<src>),
  • the image horizontal offset from the insertion node (<xpos>),
  • the image vertical offset from the insertion node (<ypos>),
  • the image <width>,
  • the image <height>.

Please note that the image <src> is the only mandatory parameter.
Below is a sample img-over action.

<img-over>
<src>chrome://kaizou/content/resources/overlays/moustache.png</src>
<xpos>100</xpos>
<ypos>100</ypos>

</img-over>

<inner-html> action

The <inner-html> action allows you to modify the HTML code inside the node targeted by the <xpath> expression specified in the parent transformation. It contains the following children:

  • the embedded <html>. 

Note: The html code to insert must be provided as a CDATA section.

Below is a sample inner-html action.

<inner-html>
<html><![CDATA[
<strong>Some text in bold</strong>]]>
</html>
</inner-html>

<insert-node> action  

The <insert-node> action allows you to insert a new HTML node inside the node targeted by the <xpath> expression specified in the parent transformation. It contains the following attributes and children:

  • a mandatory “name” attrribute specifying the node name,
  • an optional “after” boolean attribute specifying the insertion mode (defaults to false), 
  • the embedded <html>. 

Note: The html code to insert must be provided as a CDATA section.

<insert-node after=”true” name=”div” >
<html><![CDATA[
<strong>Some text in bold</strong>]]></html>

</insert-node>

Future extensions

Kaizou may support in the future:

  • … any idea ?