See Rendering Arhictecture to know more about what is an XDOM.

From Velocity:

{{velocity}}
#set ($xdom = $services.rendering.parse('hello world', 'xwiki/2.1'))
{{code}}
$services.rendering.render($xdom, 'event/1.0')
{{/code}}
{{/velocity}}

Generates:

beginDocument [[syntax]=[XWiki 2.1]]
beginParagraph
onWord [hello]
onSpace
onWord [world]
endParagraph
endDocument [[syntax]=[XWiki 2.1]]

From Groovy:

{{groovy}}
import org.xwiki.rendering.renderer.printer.*

def xdom = services.component.getInstance(org.xwiki.rendering.parser.Parser.class, 'xwiki/2.1').parse(new StringReader('hello world'))
def renderer = services.component.getInstance(org.xwiki.rendering.renderer.BlockRenderer.class, 'event/1.0')

def printer = new DefaultWikiPrinter()
renderer.render(xdom, printer)
out.println printer.toString()
{{/groovy}}

Note that the event/1.0 syntax is not bundled by default in XWiki/ You can install it in your wiki using the Extension Manager by using advanced search using the extension id org.xwiki.rendering:xwiki-rendering-syntax-event.

Once you've installed the event/1.0 syntax you can also view all the events for the current page by manually adding the following to the XWiki URL: ?outputSyntax=event and replace the view action by the get one. For example: http://localhost:8080/xwiki/bin/get/Sandbox/?outputSyntax=event

Example:

xdom.png

Tags:
Created by Vincent Massol on 2017/12/19
   

Get Connected