1<?xml version="1.0" encoding="UTF-8" ?>
2<!--
3	This is an XML Schema description of the format
4	output by MediaWiki's Special:Export system.
5
6	Version 0.2 adds optional basic file upload info support,
7	which is used by our OAI export/import submodule.
8
9	Version 0.3 adds some site configuration information such
10	as a list of defined namespaces.
11
12	Version 0.4 adds per-revision delete flags, log exports,
13	discussion threading data, a per-page redirect flag, and
14	per-namespace capitalization.
15
16	Version 0.5 adds byte count per revision.
17
18	Version 0.6 adds a separate namespace tag, and resolves the
19	redirect target and adds a separate sha1 tag for each revision.
20
21	Version 0.7 adds a unique identity constraint for both page and
22	revision identifiers. See also bug 4220.
23	Fix type for <ns> from "positiveInteger" to "nonNegativeInteger" to allow 0
24	Moves <logitem> to its right location.
25	Add parentid to revision.
26	Fix type for <id> within <contributor> to "nonNegativeInteger"
27
28	The canonical URL to the schema document is:
29	http://www.mediawiki.org/xml/export-0.7.xsd
30
31	Use the namespace:
32	http://www.mediawiki.org/xml/export-0.7/
33-->
34<schema xmlns="http://www.w3.org/2001/XMLSchema"
35		xmlns:mw="http://www.mediawiki.org/xml/export-0.7/"
36		targetNamespace="http://www.mediawiki.org/xml/export-0.7/"
37		elementFormDefault="qualified">
38
39	<annotation>
40		<documentation xml:lang="en">
41			MediaWiki's page export format
42		</documentation>
43	</annotation>
44
45	<!-- Need this to reference xml:lang -->
46	<import namespace="http://www.w3.org/XML/1998/namespace"
47			schemaLocation="http://www.w3.org/2001/xml.xsd" />
48
49	<!-- Our root element -->
50	<element name="mediawiki" type="mw:MediaWikiType">
51		<!-- Page ID contraint, see bug 4220 -->
52		<unique name="PageIDConstraint">
53			<selector xpath="mw:page" />
54			<field xpath="mw:id" />
55		</unique>
56		<!-- Revision ID contraint, see bug 4220 -->
57		<unique name="RevIDConstraint">
58			<selector xpath="mw:page/mw:revision" />
59			<field xpath="mw:id" />
60		</unique>
61	</element>
62
63	<complexType name="MediaWikiType">
64		<sequence>
65			<element name="siteinfo" type="mw:SiteInfoType"
66					 minOccurs="0" maxOccurs="1" />
67			<element name="page" type="mw:PageType"
68					 minOccurs="0" maxOccurs="unbounded" />
69			<element name="logitem" type="mw:LogItemType"
70					 minOccurs="0" maxOccurs="unbounded" />
71		</sequence>
72		<attribute name="version" type="string" use="required" />
73		<attribute ref="xml:lang" use="required" />
74	</complexType>
75
76	<complexType name="SiteInfoType">
77		<sequence>
78			<element name="sitename" type="string" minOccurs="0" />
79			<element name="base" type="anyURI" minOccurs="0" />
80			<element name="generator" type="string" minOccurs="0" />
81			<element name="case" type="mw:CaseType" minOccurs="0" />
82			<element name="namespaces" type="mw:NamespacesType" minOccurs="0" />
83		</sequence>
84	</complexType>
85
86	<simpleType name="CaseType">
87		<restriction base="NMTOKEN">
88			<!-- Cannot have two titles differing only by case of first letter. -->
89			<!-- Default behavior through 1.5, $wgCapitalLinks = true -->
90			<enumeration value="first-letter" />
91
92			<!-- Complete title is case-sensitive -->
93			<!-- Behavior when $wgCapitalLinks = false -->
94			<enumeration value="case-sensitive" />
95
96			<!-- Cannot have non-case senstitive titles eg [[FOO]] == [[Foo]] -->
97			<!-- Not yet implemented as of MediaWiki 1.18 -->
98			<enumeration value="case-insensitive" />
99		</restriction>
100	</simpleType>
101
102	<simpleType name="DeletedFlagType">
103		<restriction base="NMTOKEN">
104			<enumeration value="deleted" />
105		</restriction>
106	</simpleType>
107
108	<complexType name="NamespacesType">
109		<sequence>
110			<element name="namespace" type="mw:NamespaceType"
111					 minOccurs="0" maxOccurs="unbounded" />
112		</sequence>
113	</complexType>
114
115	<complexType name="NamespaceType">
116		<simpleContent>
117			<extension base="string">
118				<attribute name="key" type="integer" />
119				<attribute name="case" type="mw:CaseType" />
120			</extension>
121		</simpleContent>
122	</complexType>
123
124	<complexType name="RedirectType">
125		<simpleContent>
126			<extension base="string">
127				<attribute name="title" type="string" />
128			</extension>
129		</simpleContent>
130	</complexType>
131
132	<complexType name="PageType">
133		<sequence>
134			<!-- Title in text form. (Using spaces, not underscores; with namespace ) -->
135			<element name="title" type="string" />
136
137			<!-- Namespace in canonical form -->
138			<element name="ns" type="nonNegativeInteger" />
139
140			<!-- optional page ID number -->
141			<element name="id" type="positiveInteger" />
142
143			<!-- flag if the current revision is a redirect -->
144			<element name="redirect" type="mw:RedirectType" minOccurs="0" maxOccurs="1" />
145
146			<!-- comma-separated list of string tokens, if present -->
147			<element name="restrictions" type="string" minOccurs="0" />
148
149			<!-- Zero or more sets of revision or upload data -->
150			<choice minOccurs="0" maxOccurs="unbounded">
151				<element name="revision" type="mw:RevisionType" />
152				<element name="upload" type="mw:UploadType" />
153			</choice>
154
155			<!-- Zero or One sets of discussion threading data -->
156			<element name="discussionthreadinginfo" minOccurs="0" maxOccurs="1" type="mw:DiscussionThreadingInfo" />
157		</sequence>
158	</complexType>
159
160	<complexType name="RevisionType">
161		<sequence>
162			<element name="id" type="positiveInteger" />
163			<element name="parentid" type="positiveInteger" minOccurs="0" />
164			<element name="timestamp" type="dateTime" />
165			<element name="contributor" type="mw:ContributorType" />
166			<element name="minor" minOccurs="0" maxOccurs="1" />
167			<element name="comment" type="mw:CommentType" minOccurs="0" maxOccurs="1" />
168			<element name="sha1" type="string" />
169			<element name="text" type="mw:TextType" />
170		</sequence>
171	</complexType>
172
173	<complexType name="LogItemType">
174		<sequence>
175			<element name="id" type="positiveInteger" />
176			<element name="timestamp" type="dateTime" />
177			<element name="contributor" type="mw:ContributorType" />
178			<element name="comment" type="mw:CommentType" minOccurs="0" />
179			<element name="type" type="string" />
180			<element name="action" type="string" />
181			<element name="text" type="mw:LogTextType" minOccurs="0" maxOccurs="1" />
182			<element name="logtitle" type="string" minOccurs="0" maxOccurs="1" />
183			<element name="params" type="mw:LogParamsType" minOccurs="0" maxOccurs="1" />
184		</sequence>
185	</complexType>
186
187	<complexType name="CommentType">
188		<simpleContent>
189			<extension base="string">
190				<!-- This allows deleted=deleted on non-empty elements, but XSD is not omnipotent -->
191				<attribute name="deleted" use="optional" type="mw:DeletedFlagType" />
192			</extension>
193		</simpleContent>
194	</complexType>
195
196	<complexType name="TextType">
197		<simpleContent>
198			<extension base="string">
199				<attribute ref="xml:space" use="optional" default="preserve" />
200				<!-- This allows deleted=deleted on non-empty elements, but XSD is not omnipotent -->
201				<attribute name="deleted" use="optional" type="mw:DeletedFlagType" />
202				<!-- This isn't a good idea; we should be using "ID" instead of "NMTOKEN" -->
203				<!-- However, "NMTOKEN" is strictest definition that is both compatible with existing -->
204				<!-- usage ([0-9]+) and with the "ID" type. -->
205				<attribute name="id" type="NMTOKEN" />
206				<attribute name="bytes" use="optional" type="nonNegativeInteger" />
207			</extension>
208		</simpleContent>
209	</complexType>
210
211	<complexType name="LogTextType">
212		<simpleContent>
213			<extension base="string">
214				<!-- This allows deleted=deleted on non-empty elements, but XSD is not omnipotent -->
215				<attribute name="deleted" use="optional" type="mw:DeletedFlagType" />
216			</extension>
217		</simpleContent>
218	</complexType>
219
220	<complexType name="LogParamsType">
221		<simpleContent>
222			<extension base="string">
223				<attribute ref="xml:space" use="optional" default="preserve" />
224			</extension>
225		</simpleContent>
226	</complexType>
227
228	<complexType name="ContributorType">
229		<sequence>
230			<element name="username" type="string" minOccurs="0" />
231			<element name="id" type="nonNegativeInteger" minOccurs="0" />
232
233			<element name="ip" type="string" minOccurs="0" />
234		</sequence>
235		<!-- This allows deleted=deleted on non-empty elements, but XSD is not omnipotent -->
236		<attribute name="deleted" use="optional" type="mw:DeletedFlagType" />
237	</complexType>
238
239	<complexType name="UploadType">
240		<sequence>
241			<!-- Revision-style data... -->
242			<element name="timestamp" type="dateTime" />
243			<element name="contributor" type="mw:ContributorType" />
244			<element name="comment" type="string" minOccurs="0" />
245
246			<!-- Filename. (Using underscores, not spaces. No 'File:' namespace marker.) -->
247			<element name="filename" type="string" />
248
249			<!-- URI at which this resource can be obtained -->
250			<element name="src" type="anyURI" />
251
252			<element name="size" type="positiveInteger" />
253
254			<!-- TODO: add other metadata fields -->
255		</sequence>
256	</complexType>
257
258	<!-- Discussion threading data for LiquidThreads -->
259	<complexType name="DiscussionThreadingInfo">
260		<sequence>
261			<element name="ThreadSubject" type="string" />
262			<element name="ThreadParent" type="positiveInteger" />
263			<element name="ThreadAncestor" type="positiveInteger" />
264			<element name="ThreadPage" type="string" />
265			<element name="ThreadID" type="positiveInteger" />
266			<element name="ThreadAuthor" type="string" />
267			<element name="ThreadEditStatus" type="string" />
268			<element name="ThreadType" type="string" />
269		</sequence>
270	</complexType>
271
272</schema>
273