Wiki source code of Customizations for XAR Export Using URL Parameters
Last modified by Eleni Cojocariu-testing account on 2026/08/21 17:04
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | You can [[export content in XAR format>>documentation.xs.admin.exports.export-content-xar-format.WebHome]], but you can also trigger a XAR export by changing the URL of Pages. For example, replacing "/view/" with "/export/", and adding the parameter ##format=xar## will export the entire wiki: | ||
| 2 | |||
| 3 | {{code language="none"}}http://server/xwiki/bin/export/Space/Page?format=xar{{/code}}, where "Space" is considered to be the [[top-level Page>>doc:documentation.xs.user.base.page.nested-pages.relations.WebHome]] of a hierarchy. | ||
| 4 | |||
| 5 | The format of an export pattern is: | ||
| 6 | {{code language="none"}} | ||
| 7 | wikiid:pageFullNamePattern{{/code}} | ||
| 8 | |||
| 9 | * ##wikiid##: the name of the wiki from which to get the wiki Pages. It doesn't need to be specified if you're targeting Pages from the current wiki. | ||
| 10 | * ##pageFullNamePattern##: the full name pattern of the Page is based on an [[SQL "LIKE" comparator>>https://www.techonthenet.com/sql/like.php]]. Remember that the character % must be converted to %25 in a URL. | ||
| 11 | |||
| 12 | The URL parameters to customize the export: | ||
| 13 | |||
| 14 | |=Parameter|=Description|=Example | ||
| 15 | |##pages##|Specifies the Pages to include in the export, using a pattern that matches Page names. You can use multiple Pages parameters, each representing a Page pattern.|##&pages=Main.%25## (Exports all Pages from the Main space) | ||
| 16 | |##excludes##|Specifies the Pages to exclude from the export, using a pattern that matches Page names. Each ##excludes## parameter applies to the ##pages## parameter in the same position, so use an empty ##excludes## to keep the order when only a later ##pages## has exclusions. Several Pages excluded from the same ##pages## go into a **single** ##excludes## value, separated by ##%26##; a Page name that itself contains the ##&## character is encoded ##%2526##.|##&excludes=Main.Space1.%25## (Excludes the Pages under the Main.Space1 space) | ||
| 17 | |##filter##|Restricts the export to the Pages kept by an entity tree filter, named by its component hint. The hint to use is ##installedExtensionDocument##, which leaves out the Pages belonging to an installed [[Extension>>documentation.xs.admin.imports.extensions.WebHome]] that hold no nested content Pages, so that only the content of the wiki is exported. A filter counts as a selection on its own, and combined with ##pages## it applies to the patterns whose Page name is ##%25##.|##&filter=installedExtensionDocument## | ||
| 18 | |##name##|Specifies the name of the exported XAR file. If not specified, ##backup## is used for a whole-wiki export and ##export## for a partial one.|##&name=CustomExport.xar## | ||
| 19 | |##description##|Specifies the description of the XAR export, which can later be viewed when reimporting into an XWiki instance.|##&description=The offices of our company## | ||
| 20 | |##history##|Set to ##true## to also export the [[Page's history>>documentation.xs.user.base.page.view.history-tab.WebHome]].|##&history=true## | ||
| 21 | |##attachment_jrcs##|With ##history=true##, chooses the format of the [[attachment history>>documentation.xs.admin.exports.export-content-xar-format.format-specifications.document-xml.WebHome||anchor="HAttachments"]]. The default ##true## writes the deprecated JRCS ##versions## element, which an XWiki older than ##12.0## can read; ##false## writes the ##revisions## element instead, which is what the "Target XWiki version" setting of the [[Administration export>>documentation.xs.admin.exports.export-content-xar-format.WebHome]] sends.|##&attachment_jrcs=false## | ||
| 22 | |##backup##|Set to ##true## to mark the archive as a backup package, so that the XWiki Page [[author>>documentation.xs.user.base.page.authors.WebHome]] of each Page remains the same as when exported, when reimported into an XWiki instance.|##&backup=true## | ||
| 23 | |##author##|Specifies the author's name in the XAR export, which can later be viewed when reimporting into an XWiki instance.|##&author=John Smith## | ||
| 24 | |##licence##|Specifies the license for the XAR export, which can later be viewed when reimporting into an XWiki instance. The parameter uses the British spelling, matching the ##licence## element of the [[##package.xml## descriptor>>documentation.xs.admin.exports.export-content-xar-format.format-specifications.WebHome]]; the American spelling is ignored.|##&licence=GPL## | ||
| 25 | |##version##|Specifies the version of the export to the XAR.|##&version=1.0## | ||
| 26 | |||
| 27 | Examples of how to use the parameters: | ||
| 28 | |||
| 29 | * Exports all Pages in the current wiki:((( | ||
| 30 | {{code language="none"}} | ||
| 31 | http://server/xwiki/bin/export/Space/Page?format=xar&pages=%25.%25 | ||
| 32 | {{/code}} | ||
| 33 | ))) | ||
| 34 | * Exports the Pages ##Main.WebHome## and ##Blog.WebHome##:((( | ||
| 35 | {{code language="none"}} | ||
| 36 | http://server/xwiki/bin/export/Space/Page?format=xar&pages=Main.WebHome&pages=Blog.WebHome | ||
| 37 | {{/code}} | ||
| 38 | ))) | ||
| 39 | * Exports all Pages in the ##Main## space except Pages under ##Main.Space1## space, and all Pages under ##Other## space:((( | ||
| 40 | {{code language="none"}} | ||
| 41 | http://server/xwiki/bin/export/Space/Page?format=xar&pages=Main.%25&excludes=Main.Space1.%25&pages=Other.%25 | ||
| 42 | {{/code}} | ||
| 43 | ))) | ||
| 44 | * Exports all Pages in the ##subwiki:Main## space except a Page named ##subwiki:Main.Excluded&Other## and ##subwiki:Main.WebHome##. Both exclusions belong to the same ##pages## parameter, so they are one ##excludes## value joined by ##%26##, and the ##&## of the first Page name is encoded ##%2526##:((( | ||
| 45 | {{code language="none"}} | ||
| 46 | http://server/xwiki/bin/export/Space/Page?format=xar&pages=subwiki:Main.%25&excludes=subwiki%3AMain.Excluded%2526Other%26subwiki%3AMain.WebHome | ||
| 47 | {{/code}} | ||
| 48 | ))) | ||
| 49 | * Exports all Pages in the ##Main## space and all in the ##Other## space except ##Other.Excluded## (see the empty excludes for respecting the order):((( | ||
| 50 | {{code language="none"}} | ||
| 51 | http://server/xwiki/bin/export/Space/Page?format=xar&pages=Main.%25&excludes=&pages=Other.%25&excludes=Other.Excluded | ||
| 52 | {{/code}} | ||
| 53 | ))) | ||
| 54 | * Exports the whole wiki without the Pages that came with an installed Extension:((( | ||
| 55 | {{code language="none"}} | ||
| 56 | http://server/xwiki/bin/export/Space/Page?format=xar&filter=installedExtensionDocument | ||
| 57 | {{/code}} | ||
| 58 | ))) |