Wiki source code of Available Transformations

Last modified by Marius Dumitru Florea on 2026/02/16 11:37

Hide last authors
Manuel Smeria 10.2 1 Here's the list of available [[Transformations>>Architecture]] you can use:
Vincent Massol 1.1 2
Vincent Massol 2.1 3 {{toc/}}
4
Vincent Massol 11.3 5 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):
Vincent Massol 11.1 6
7 {{code language="none"}}
8 rendering.transformations = macro, icon
Vincent Massol 11.2 9 {{/code}}
Vincent Massol 11.1 10
Marius Dumitru Florea 13.1 11 {{version since="18.1.0RC1"}}
12 You can also configure the list of transformations to perform from the ##TransformationContext##, for a specific call to the ##TransformationManager##:
13
14 {{code language="java"}}
15 TransformationContext transformationContext = new TransformationContext();
16 transformationContext.setTransformationNames(Optional.of(List.of("macro", "icon")));
17 transformationManager.performTransformations(xdom, transformationContext);
18 {{/code}}
19 {{/version}}
20
Vincent Massol 6.1 21 = Macro Transformation =
22
Vincent Massol 12.2 23 See the [[Macro Transformation documentation>>extensions:Extension.RenderingMacroTransformation.WebHome]].
Vincent Massol 6.1 24
Vincent Massol 2.1 25 = Icon Transformation =
26
Vincent Massol 9.1 27 See the [[Icon Transformation documentation>>extensions:Extension.Icon Transformation]] to understand what this transformation does.
Vincent Massol 2.1 28
Manuel Smeria 10.2 29 Example of usage:
Vincent Massol 4.1 30
31 {{code language="java"}}
32 // Initialize Rendering components and allow getting instances
33 final EmbeddableComponentManager cm = new EmbeddableComponentManager();
34 cm.initialize(this.getClass().getClassLoader());
35
36 XDOM xdom = new XDOM(Arrays.<Block>asList(new ParagraphBlock(Arrays.asList((Block) new SpecialSymbolBlock(':'),
37 new SpecialSymbolBlock(')')))));
38
39 Transformation transformation = cm.lookup(Transformation.class, "icon");
40 TransformationContext txContext = new TransformationContext();
41 transformation.transform(xdom, txContext);
42
43 WikiPrinter printer = new DefaultWikiPrinter();
44 BlockRenderer renderer = cm.lookup(BlockRenderer.class, Syntax.XWIKI_2_0.toIdString());
45 renderer.render(xdom, printer);
46
47 String expected = "image:emoticon_smile";
48
49 Assert.assertEquals(expected, printer.toString());
50 {{/code}}
51
Vincent Massol 5.1 52 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+):
Vincent Massol 4.1 53
54 {{code language="java"}}
55 // Initialize Rendering components and allow getting instances
56 final EmbeddableComponentManager cm = new EmbeddableComponentManager();
57 cm.initialize(this.getClass().getClassLoader());
58
59 XDOM xdom = new XDOM(Arrays.<Block>asList(new ParagraphBlock(Arrays.asList((Block) new SpecialSymbolBlock(':'),
Vincent Massol 5.2 60 new SpecialSymbolBlock(':')))));
Vincent Massol 4.1 61
Vincent Massol 5.1 62 // Test adding a new Icon Mapping.
63 cm.lookup(IconTransformationConfiguration.class).addMapping("::", "something");
Vincent Massol 4.1 64
65 Transformation transformation = cm.lookup(Transformation.class, "icon");
66 TransformationContext txContext = new TransformationContext();
67 transformation.transform(xdom, txContext);
68
69 WikiPrinter printer = new DefaultWikiPrinter();
70 BlockRenderer renderer = cm.lookup(BlockRenderer.class, Syntax.XWIKI_2_0.toIdString());
71 renderer.render(xdom, printer);
72
Vincent Massol 5.2 73 String expected = "image:box";
Vincent Massol 4.1 74
75 Assert.assertEquals(expected, printer.toString());
76 {{/code}}
77
Vincent Massol 2.1 78 = WikiWord Transformation =
Vincent Massol 3.1 79
Vincent Massol 9.1 80 See the [[WikiWord Transformation documentation>>extensions:Extension.WikiWord Transformation]] to understand what this transformation does.
Vincent Massol 3.1 81
Manuel Smeria 10.2 82 Example of usage:
Vincent Massol 3.1 83
Vincent Massol 4.1 84 {{code language="java"}}
85 // Initialize Rendering components and allow getting instances
86 final EmbeddableComponentManager cm = new EmbeddableComponentManager();
87 cm.initialize(this.getClass().getClassLoader());
88
89 XDOM xdom = new XDOM(
90 Arrays.<Block>asList(new ParagraphBlock(Arrays.asList((Block) new WordBlock("WikiWord")))));
91
92 Transformation transformation = cm.lookup(Transformation.class, "wikiword");
93 TransformationContext txContext = new TransformationContext();
94 transformation.transform(xdom, txContext);
95
96 WikiPrinter printer = new DefaultWikiPrinter();
97 BlockRenderer renderer = cm.lookup(BlockRenderer.class, Syntax.XWIKI_2_0.toIdString());
98 renderer.render(xdom, printer);
99
100 String expected = "[[WikiWord]]";
101
102 Assert.assertEquals(expected, printer.toString());
103 {{/code}}
Vincent Massol 7.1 104
105 = LinkChecker Transformation =
106
Vincent Massol 10.1 107 See the [[Link Checker Transformation documentation>>extensions:Extension.Link Checker Transformation]] to understand what this transformation does and how to use it.
  • Powered by XWiki 18.4.6 - node1. Hosted and managed by XWiki SAS

Get Connected