Available Transformations

Last modified by Vincent Massol on 2014/05/26 11:07

Here's the list of available Transformations you can use:

To configure the list of Transformations to execute in your wiki, edit your xwiki.properties file and look for the rendering.transformations configuration key. The default value is (which means you have the Macro Transformation and the Icon Transformation enabled by default in your wiki):

rendering.transformations = macro, icon

Macro Transformation

See Architecture.

Icon Transformation

See the Icon Transformation documentation to understand what this transformation does.

Example of usage:

// Initialize Rendering components and allow getting instances
final EmbeddableComponentManager cm = new EmbeddableComponentManager();
cm.initialize(this.getClass().getClassLoader());

XDOM xdom = new XDOM(Arrays.<Block>asList(new ParagraphBlock(Arrays.asList((Block) new SpecialSymbolBlock(':'),
   new SpecialSymbolBlock(')')))));

Transformation transformation = cm.lookup(Transformation.class, "icon");
TransformationContext txContext = new TransformationContext();
transformation.transform(xdom, txContext);

WikiPrinter printer = new DefaultWikiPrinter();
BlockRenderer renderer = cm.lookup(BlockRenderer.class, Syntax.XWIKI_2_0.toIdString());
renderer.render(xdom, printer);

String expected = "image:emoticon_smile";

Assert.assertEquals(expected, printer.toString());

It's also possible to configure new emoticons or override existing ones by getting the IconTransformationConfiguration component as shown below (works on XWiki Rendering 3.3M1+):

// Initialize Rendering components and allow getting instances
final EmbeddableComponentManager cm = new EmbeddableComponentManager();
cm.initialize(this.getClass().getClassLoader());

XDOM xdom = new XDOM(Arrays.<Block>asList(new ParagraphBlock(Arrays.asList((Block) new SpecialSymbolBlock(':'),
   new SpecialSymbolBlock(':')))));

// Test adding a new Icon Mapping.
cm.lookup(IconTransformationConfiguration.class).addMapping("::", "something");

Transformation transformation = cm.lookup(Transformation.class, "icon");
TransformationContext txContext = new TransformationContext();
transformation.transform(xdom, txContext);

WikiPrinter printer = new DefaultWikiPrinter();
BlockRenderer renderer = cm.lookup(BlockRenderer.class, Syntax.XWIKI_2_0.toIdString());
renderer.render(xdom, printer);

String expected = "image:box";

Assert.assertEquals(expected, printer.toString());

WikiWord Transformation

See the WikiWord Transformation documentation to understand what this transformation does.

Example of usage:

// Initialize Rendering components and allow getting instances
final EmbeddableComponentManager cm = new EmbeddableComponentManager();
cm.initialize(this.getClass().getClassLoader());

 XDOM xdom = new XDOM(
    Arrays.<Block>asList(new ParagraphBlock(Arrays.asList((Block) new WordBlock("WikiWord")))));

 Transformation transformation = cm.lookup(Transformation.class, "wikiword");
 TransformationContext txContext = new TransformationContext();
 transformation.transform(xdom, txContext);

 WikiPrinter printer = new DefaultWikiPrinter();
 BlockRenderer renderer = cm.lookup(BlockRenderer.class, Syntax.XWIKI_2_0.toIdString());
 renderer.render(xdom, printer);

 String expected = "[[WikiWord]]";

 Assert.assertEquals(expected, printer.toString());

LinkChecker Transformation

See the Link Checker Transformation documentation to understand what this transformation does and how to use it.

Tags:
Created by Vincent Massol on 2011/10/13 20:52
    
  • Powered by XWiki 8.4.4-node2. Hosted and managed by XWiki SAS

Get Connected