Format for Document XML

Last modified by Eleni Cojocariu on 2026/08/21 19:17

Reference

You can read the XML of a Page by exporting it and opening the archive with any tool that extracts ZIP files, or without exporting at all by adding the xpage=xml parameter to the URL of the Page.

Inside the archive the files follow the Page hierarchy, one directory per segment of the Page reference: the Page Sandbox.TestPage2 is stored as Sandbox/TestPage2.xml, and a Page Sandbox.Notes.Meeting would be stored as Sandbox/Notes/Meeting.xml. That layout is a convenience only: a parser ignores the path and reads the reference from the file itself.

The file below is the export of Sandbox Test Page 2, one of the test Pages of the Sandbox that every wiki ships, after an XClass with two properties, two XObjects of that XClass, a comment and one attachment in three versions were added to it. It therefore shows an attachment, a class and three object elements next to the elements every Page has, while the elements the tables below describe as written only when set are absent from it. The base64 content of the attachment is shortened, and an XML comment marks each of the three places where repeated or empty content was left out:

<?xml version='1.1' encoding='UTF-8'?>
<xwikidoc version="1.7" reference="Sandbox.TestPage2" locale="">
  <web>Sandbox</web>
  <name>TestPage2</name>
  <language/>
  <defaultLanguage>en</defaultLanguage>
  <translation>0</translation>
  <creator>XWiki.superadmin</creator>
  <creationDate>1785161867000</creationDate>
  <parent>Sandbox.WebHome</parent>
  <author>XWiki.Admin</author>
  <originalMetadataAuthor>XWiki.Admin</originalMetadataAuthor>
  <contentAuthor>XWiki.superadmin</contentAuthor>
  <date>1787324218000</date>
  <contentUpdateDate>1785161867000</contentUpdateDate>
  <version>16.1</version>
  <title>Sandbox Test Page 2</title>
  <comment/>
  <minorEdit>false</minorEdit>
  <syntaxId>xwiki/2.1</syntaxId>
  <hidden>false</hidden>
  <content>Click on **"Edit"** and modify the contents of this page, then click on **"Save &amp; View"** to see how they look like on your page!

= Here's some dummy text to show you what the page looks like =

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</content>
  <attachment>
    <filename>XWikiLogo.png</filename>
    <mimetype>image/png</mimetype>
    <charset>UTF-8</charset>
    <author>XWiki.Admin</author>
    <date>1787319032000</date>
    <version>1.3</version>
    <comment/>
    <content>iVBORw0KGgoAAAANSUhEUgAAAIgAAACFCAYAAACAJLCMAAAFNUlEQVR4Xu2dsY3rRhRF1YDB3A…</content>
    <filesize>1390</filesize>
  </attachment>
  <class>
    <name>Sandbox.TestPage2</name>
    <customClass/>
    <customMapping/>
    <defaultViewSheet/>
    <defaultEditSheet/>
    <defaultWeb/>
    <nameField/>
    <validationScript/>
    <dueDate>
      <dateFormat>dd/MM/yyyy HH:mm:ss</dateFormat>
      <disabled>0</disabled>
      <emptyIsToday>1</emptyIsToday>
      <name>dueDate</name>
      <number>2</number>
      <picker>1</picker>
      <prettyName>dueDate</prettyName>
      <size>20</size>
      <unmodifiable>0</unmodifiable>
      <classType>com.xpn.xwiki.objects.classes.DateClass</classType>
    </dueDate>
    <label>
      <disabled>0</disabled>
      <name>label</name>
      <number>1</number>
      <prettyName>label</prettyName>
      <size>30</size>
      <unmodifiable>0</unmodifiable>
      <classType>com.xpn.xwiki.objects.classes.StringClass</classType>
    </label>
  </class>
  <object>
    <name>Sandbox.TestPage2</name>
    <number>0</number>
    <className>Sandbox.TestPage2</className>
    <guid>86b1f0aa-ad8e-4f54-b692-13fffbd7ba90</guid>
    <class>
      <name>Sandbox.TestPage2</name>
      <customClass/>
      <customMapping/>
      <defaultViewSheet/>
      <defaultEditSheet/>
      <defaultWeb/>
      <nameField/>
      <validationScript/>
      <dueDate>
        <dateFormat>dd/MM/yyyy HH:mm:ss</dateFormat>
        <disabled>0</disabled>
        <emptyIsToday>1</emptyIsToday>
        <name>dueDate</name>
        <number>2</number>
        <picker>1</picker>
        <prettyName>dueDate</prettyName>
        <size>20</size>
        <unmodifiable>0</unmodifiable>
        <classType>com.xpn.xwiki.objects.classes.DateClass</classType>
      </dueDate>
      <label>
        <disabled>0</disabled>
        <name>label</name>
        <number>1</number>
        <prettyName>label</prettyName>
        <size>30</size>
        <unmodifiable>0</unmodifiable>
        <classType>com.xpn.xwiki.objects.classes.StringClass</classType>
      </label>
    </class>
    <property type="Date">
      <dueDate>2026-01-15 00:00:00.0</dueDate>
    </property>
    <property type="String">
      <label>Test object</label>
    </property>
  </object>
  <object>
    <name>Sandbox.TestPage2</name>
    <number>1</number>
    <className>Sandbox.TestPage2</className>
    <guid>575fd5eb-58ba-428b-a93b-b7564d39e84d</guid>
    <class>
      <!-- the same copy of the Sandbox.TestPage2 XClass as above, elided here -->
    </class>
    <property type="Date">
      <dueDate>2026-02-01 00:00:00.0</dueDate>
    </property>
    <property type="String">
      <label>Second test object</label>
    </property>
  </object>
  <object>
    <name>Sandbox.TestPage2</name>
    <number>0</number>
    <className>XWiki.XWikiComments</className>
    <guid>d43c7554-1735-44ca-8b2f-e7390c259e21</guid>
    <class>
      <!-- the definition of XWiki.XWikiComments, elided here -->
    </class>
    <property type="LargeString">
      <author>XWiki.Admin</author>
    </property>
    <property type="LargeString">
      <comment>Handy for testing, thanks!</comment>
    </property>
    <property type="Date">
      <date>2026-08-21 12:00:00.0</date>
    </property>
    <property type="Integer">
      <replyto/>
    </property>
    <!-- the seven remaining properties of the comment, all empty -->
  </object>
</xwikidoc>

Format Versions

The version attribute of the root element names the version of the format, which changes whenever the set of elements does. Reading it tells you what an older archive can and cannot contain:

FormatWritten sinceChange
1.7XWiki 18.2.0The type attribute on an XObject property, which keeps the value readable when its XClass is gone.
1.6XWiki 16.10.0The enforceRequiredRights element.
1.5XWiki 14.0The originalMetadataAuthor element.
1.4XWiki 12.0The revisions element for attachment history, which allows streaming and deduplication, in place of the JRCS versions element.
1.3XWiki 9.0XML 1.1 instead of XML 1.0.
1.2XWiki 7.2Nested spaces: the reference and locale attributes, which deprecate the web, name and language elements.
1.1XWiki 6.2The version attribute itself, plus a change of element order and indentation.

An archive with no version attribute is in format 1.0.

Root Element

Attribute of xwikidocDescription
versionThe version of the format the file follows.
referenceThe full reference of the Page.
localeThe locale of the Page, as defined by the Java locale specifications, and empty for the default locale.

Document Elements

ElementDescription
webDeprecated in favor of the reference attribute: the space of the Page. Ignored when reference is set.
nameDeprecated in favor of the reference attribute: the name of the Page. Ignored when reference is set.
languageDeprecated in favor of the locale attribute: the locale of the Page.
defaultLanguageThe locale the Page's own content is written in, the one its translations translate.
translation1 when the file holds a translation of the Page, 0 when it holds the Page itself.
creatorThe user who created the Page.
creationDateWhen the Page was created.
parentThe parent of the Page in the legacy parent and child relationship, written only when one is set. It has nothing to do with where the Page sits in the Page hierarchy.
authorThe user who holds the responsibility, in terms of rights, for everything in the Page except its content.
originalMetadataAuthorThe user who triggered the save without holding that responsibility, which is what happens when saving needs no edit right, as when a comment is added.
contentAuthorThe last user who changed the content of the Page. This is the author whose rights are checked when the content runs a script.
dateWhen the Page was last modified.
contentUpdateDateWhen the content of the Page was last modified.
versionThe version of the Page.
titleThe title of the Page.
commentThe comment attached to the last version of the Page.
minorEdittrue when the last change was a minor version.
syntaxIdThe identifier of the syntax the content is written in, for example xwiki/2.1.
hiddenWhether the Page is hidden.
contentThe content of the Page, in the syntax named by syntaxId.
renderedcontentThe content rendered as HTML. Present only when the export was asked for it, which the standard XAR export does not do.
versionsThe history of the Page, as a serialized com.xpn.xwiki.doc.rcs.XWikiRCSArchive Java object. Present only when the Page was exported with its history.
enforceRequiredRightstrue when the required rights of the Page are enforced. Written only in that case, so that archives stay importable into instances older than the flag.
validationScriptThe script executed when the Page is validated on save, written only when one is set.
customClassThe Java class used in place of the standard one to represent the Page in scripts, written only when one is set.
defaultTemplateA legacy element naming a template Page, kept for backward compatibility and written only when it is set.
attachment, class, objectOne attachment per attached file, one class when the Page defines an XClass, and one object per XObject the Page holds. Their own elements are described below.

Attachments

An attachment element carries the current file, and the versions that came before it when the Page was exported with its history. The attachment of the Page above, exported that way, has three versions: an image, the same image uploaded again, and the different image that replaced it.

  <attachment>
    <filename>XWikiLogo.png</filename>
    <mimetype>image/png</mimetype>
    <charset>UTF-8</charset>
    <author>XWiki.Admin</author>
    <date>1787319032000</date>
    <version>1.3</version>
    <comment/>
    <content>iVBORw0KGgoAAAANSUhEUgAAAIgAAACFCAYAAACAJLCMAAAFNUlEQVR4Xu2dsY3rRhRF1YDB3A…</content>
    <filesize>1390</filesize>
    <revisions>
      <revision>
        <author>XWiki.Admin</author>
        <date>1787319032000</date>
        <version>1.1</version>
        <comment/>
        <content>iVBORw0KGgoAAAANSUhEUgAAAFAAAAAyCAYAAADLLVz8AAAABmJLR0QA/wD/AP+gvaeTAAAACX…</content>
        <filesize>2018</filesize>
      </revision>
      <revision>
        <author>XWiki.Admin</author>
        <date>1787319032000</date>
        <version>1.2</version>
        <comment/>
        <contentAlias>1.1</contentAlias>
        <filesize>2018</filesize>
      </revision>
      <revision>
        <author>XWiki.Admin</author>
        <date>1787319032000</date>
        <version>1.3</version>
        <comment/>
        <contentAlias/>
        <filesize>1390</filesize>
      </revision>
    </revisions>
  </attachment>
ElementDescription
filenameThe name of the file.
mimetypeThe MIME type of the file, as expressed by RFC 6838.
charsetThe charset of the file, as expressed in the HTTP Content-Type header.
authorThe user who uploaded this version of the file.
dateWhen this version was uploaded.
versionThe version of the attachment.
commentThe comment attached to this version.
contentThe binary content, serialized in base64.
filesizeThe size of the content in bytes.
revisionsOne revision element per version of the attachment, oldest first, each carrying that version's author, date, version, comment, content and filesize. A revision repeats none of filename, mimetype and charset, which describe the attachment rather than one of its versions.
contentAliasWritten inside a revision in place of content when that revision's bytes are already in the archive: the version holding them, or empty when they are the current attachment's own. This is what keeps a repeatedly saved attachment from being serialized several times.
versionsDeprecated in favor of revisions: the history of the attachment as a JRCS archive dump. It is what an export whose target version is below 12.0 writes in place of revisions.

XClass Definition

The class element is present when the Page defines an XClass. Its fixed elements come first, and every element after them is one property of the XClass.

ElementDescription
nameThe reference of the Page the XClass is attached to, which is also the name of the XClass.
customClassThe Java class used in place of the standard one to represent the XObjects of this XClass.
customMappingThe Hibernate mapping storing the XObjects of this XClass in their own database table instead of the generic object tables.
validationScriptThe script executed to validate an XObject of this XClass before it is saved.
defaultViewSheet, defaultEditSheet, defaultWeb, nameFieldLegacy elements, kept for backward compatibility and left empty by the XClasses XWiki ships.
One element per property, named after itThe definition of that property. classType names the Java class implementing its type, and the other elements are the fields of the property: name, number, prettyName, disabled and unmodifiable on every type, plus the fields of that type in particular, as with the dateFormat, emptyIsToday and picker of the Date property above.

XObjects

There is one object element per XObject the Page holds. The example above holds three: two XObjects of the XClass the Page itself defines, told apart by their number, and one comment, whose XClass is defined by another Page and is therefore copied into the archive.

ElementDescription
nameThe reference of the Page the XObject belongs to.
numberThe index of the XObject among the ones of the same XClass on that Page, starting at 0.
classNameThe reference of the XClass the XObject is an instance of.
guidThe unique identifier of the XObject.
classA copy of the XClass definition as it was when the archive was written, with the same elements as the class element above. It is what makes an XObject readable even when the Page defining its XClass is not in the archive.
propertyOne per property value. Its single child element is named after the property and holds the value. Its type attribute names the property type, which is what allows the value to be read when the XClass is missing altogether.

FAQ

How are Page dates stored in the XML?

Every date is the number of milliseconds elapsed since January 1, 1970, 00:00:00 (GMT). The value 1700000000000, for instance, is November 14, 2023, 22:13:20 (GMT).

How is a translation of a Page represented?

Each translation has its own XML file, named after the Page plus its locale, as in the Sandbox/TestPage2.de.xml entry holding the German translation of the Page above, because the wiki stores it as a separate Page.

How can I tell from the XML whether a Page is terminal?

The name element is WebHome for a non-terminal Page and the name of the Page itself for a terminal one, and the last segment of the reference attribute says the same.

Related

Get Connected