XWiki - XWiki Syntax Guide 

Page / - last modified by superadmin on 2019/11/08 18:06 

XWiki Syntax Guide 
last modified by superadmin
on 2019/11/08 18:06

Table of Contents
XWiki Syntax 2.1: Programming

  
XWiki Syntax 2.1 » Programming
XWiki Syntax 2.1: Programming
•	General
•	Introduction
•	General Remarks
•	Other Syntaxes
•	Editing
•	Paragraphs
•	Headings
•	Text Formatting
•	Horizontal Line
•	Lists
•	Definition Lists
•	New Line/Line Breaks
•	Links
•	Tables
•	Images
•	Advanced
•	Verbatim
•	Quotations
•	Groups
•	Escapes
•	Parameters
•	Programming
•	Macros
•	HTML
•	Scripts

Macros
2.0 Macros
There is only one kind of macro in XWiki Syntax 2.1, which is called by the syntax: {{macroname param1="value1" ... paramN="valueN"}}...{{/macroname}}. For macros without content there's a short notation: {{macroname param1="value1" ... paramN="valueN"/}}
Feature | XWiki Syntax 2.1 | Result

Rendering Macro with a content

{{code language="java"}}
System.out.println("Hello World!");
{{/code}}

System.out.println("Hello World!");

Rendering Macro without content | {{include reference="Space.Page"/}} | The referenced page is included in the current page
Radeox macros cannot be used in XWiki Syntax 2.1. Thus they have been rewritten as Rendering macros.
For the full list of available macros check the Extensions wiki.
Macros in this wiki
help.macroList.id | help.macroList.name | help.macroList.category | help.macroList.description | help.macroList.visibility
toc | Table Of Contents | Navigation | Generates a Table Of Contents. | Global
iconPicker | Icon Picker | Development | Select an icon within the XWiki icon set. | Current Wiki
formula | Formula | Content | Displays a mathematical formula. | Global
wikimacrocontent | WikiMacro Content | Development | Display editable content of a wikimacro. | Global
async | Async | Content | Asynchronous and cached execution of wiki content. | Global
spaceindex | Space Index | Deprecated | Lists documents in a space. | Current Wiki
box | Box | Formatting | Draw a box around provided content. | Global
spaces | Spaces | Deprecated | Displays all the spaces in this wiki. | Current Wiki
error | Error Message | Formatting | Displays an error message note. | Global
warning | Warning Message | Formatting | Displays a warning message note. | Global
messageSender | Message Sender | Social | A control that allows users to enter messages that are handled by the MessageStream module. | Current Wiki
children | Children | Navigation | Displays a tree of children pages of the current page | Current Wiki
workspaces | Workspaces | Deprecated | Deprecated macro that should not be used, here for compatibility reason. Please use the "wikis" macro instead. | Current Wiki
display | Display | Content | Display other pages into the current page. | Global
translation | Translation | Content | Display a translation message. | Global
context | Context | Development | Executes content in the context of the passed document | Global
info | Info Message | Formatting | Displays an info message note. | Global
tree | Tree | Navigation | Displays a tree hierarchy defined by the macro content or the source parameter. | Current Wiki
rss | RSS | Content | Output latest feed entries from a RSS feed. | Global
success | Success Message | Formatting | Displays a success message note. | Global
documentTree | Document Tree | Navigation | Displays the tree of XWiki documents. | Current Wiki
template | Template | Development | Insert a template. | Global
notificationsAutoWatchPreferences | Notifications Auto Watch Preferences | Notifications | | Current Wiki
chart | Chart | Content | Displays a graphical chart generated from miscellaneous data sources | Global
container | Container | Layout | A macro to enclose multiple groups and add decoration, such as layout. | Global
notificationsEmailPreferences | Notifications Email Preferences | Notifications | Display the preferences of the current user about notification emails. | Current Wiki
tagcloud | Tag Cloud | Content | Displays the cloud of tags in this wiki or in the specified space, if any. | Current Wiki
activity | Activity (legacy) | Notifications | Provide a macro implemented with the Notifications Application to keep a backward compatibility with Activity Stream. | Current Wiki
python | Python | Development | Executes a python script. | Global
comment | Comment | Development | Allows putting comments in the source content. This macro doesn't output anything. | Global
html | HTML | Development | Inserts HTML or XHTML code into the page. | Global
content | Content | Content | Allows writing content in any wiki markup | Global
script | Script | Development | Execute script in provided script language. | Global
useravatar | User Avatar | Content | Allows displaying the avatar for a specific user. | Global
office | Office Document Viewer | Content | View office attachments (doc, ppt, xls, odt, odp, ods etc.) inside wiki pages without downloading or importing them. | Global
gallery | Gallery | Layout | Displays the images found in the provided content using a slide-show view. | Global
dashboard | Dashboard | Layout | A macro to define a dashboard. | Global
putFootnotes | Put Footnote | Content | Displays the footnotes defined so far. If missing, all footnotes are displayed by default at the end of the page. | Global
wikis | Wikis | Navigation | List all wikis | Current Wiki
attachmentSelector | Attachment Selector | Development | A control to be used for object properties of the current document that are supposed to contain the name of an attachment from the current (or target) document. Allows uploading new attachments, and deleting attachments from the target document.  If no target document is specified, the current document will be used. Object properties are only saved to the current document. | Current Wiki
notificationsApplicationsPreferences | Notifications Applications Preferences | Notifications | Display the preferences of the current user about notification applications. | Current Wiki
cache | Cache | Development | Caches content. | Global
menu | Menu | Navigation | Displays a menu created using simple wiki syntax (nested lists and links). | Global
documents | Documents | Content | Displays a list of documents in a Livetable | Current Wiki
notificationsFiltersPreferences | Notifications Filters Preferences | Notifications | Display the preferences of the current user about notification filters. | Current Wiki
velocity | Velocity | Development | Executes a Velocity script. | Global
wikimacroparameter | WikiMacro Parameter | Development | Display editable parameter of a wikimacro. | Global
groovy | Groovy | Development | Execute a groovy script. | Global
footnote | Footnote | Content | Generates a footnote to display at the end of the page. | Global
code | Code | Formatting | Highlights code snippets of various programming languages | Global
id | Id | Navigation | Allows putting a reference/location in a page. In HTML for example this is called an Anchor. It allows pointing to that location, for example in links. | Global
include | Include | Content | Include other pages into the current page. | Global
HTML
2.0 HTML
In XWiki Syntax 2.1 HTML or XHTML must be entered by using the HTML macro.
XWiki Syntax 2.1 | Result
{{html}}<b>bold</b>{{/html}} | bold
In XWiki Syntax 2.1, by default the HTML macro does not understands XWiki Syntax (other macros included since it's XWiki Syntax too). To enable it, use {{html wiki="true"}} .
Scripts
2.0 Scripts
In XWiki Syntax 1.0 it was possible to enter Velocity scripts anywhere directly in the page. This lead to issues for example when the user was involuntarily entering Velocity content. It was also performance hungry for pages not requiring Velocity content. There were several other technical limitations. Thus in XWiki Syntax 2.1 Velocity scripts must be entered using the velocity macro. Same goes for entering Groovy scripts.
Feature | XWiki Syntax 2.1

Velocity script

{{velocity}}
#set ($var = "whatever")
{{/velocity}}

Groovy script

{{groovy}}
def var = "whatever"
{{/groovy}}