XWiki Enterprise 8.4.4 Documentation » Programming Overview » XWiki Rendering Macros in Java Overview

XWiki Rendering Macros in Java Overview

XWiki Rendering Macros in Java are created using the XWiki Rendering architecture and Java. In order to implement a Java macro you will need to write 2 classes:

  • One that representing the allowed parameters, including mandatory parameters, default values, parameter descriptions. An instance of this class will be automatically populated when the user calls the macro in wiki syntax.
  • Another one that is the macro itself and implements the Macro interface.

The XWiki Rendering Architecture can be summarized by the image below:

XWikiRenderingArchitecture.png 

The Parser parses a text input like "xwiki/2.0" syntax or HTML and generates an XDOM object. This object is an Abstract Syntax Tree which represents the input into structured blocks.

The Renderer takes an XDOM as input and generates an output like "xwiki/2.0" syntax, XHTML or PDF. 

The Transformation takes an XDOM as input and generates a modified one. The available Transformations are:

The Macro Transformation searches for all macro blocks inside the XDOM object and replaces them with blocks generated by various macros. For each macro block found, the Macro Transformation verifies whether there is a corresponding macro registered for it and for the target syntax. Macros can be registered for all syntaxes or only for a given syntax. Finally, macros are sorted by priority and executed one by one by replacing the macro block with the list of blocks generated by the macro. The process is repeated until there are no more macro blocks left in the XDOM.

The steps to follow for creating and deploying an XWiki Rendering macro in Java are detailed here.

Java Macros Bundled with XWiki Enterprise

per page of Page
The environment prevents the table from loading data.
 
Page

Search this space