summaryrefslogtreecommitdiff
blob: a153f5cadd4e2818c56f21f77bdfa55610f35630 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?xml version='1.0' encoding='UTF-8'?>

<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>
	<!-- top-level variants -->
	<xs:element name='pkgmetadata' type='pkgMetadataType'/>
	<xs:element name='catmetadata' type='catMetadataType'/>

	<!-- global elements -->
	<xs:complexType name='pkgMetadataType'>
		<xs:choice minOccurs='0' maxOccurs='unbounded'>
			<xs:element name='longdescription' type='longDescType'/>
			<xs:element name='maintainer' type='maintainerType'/>
			<xs:element name='natural-name' type='xs:token'/>
			<xs:element name='slots' type='slotsType'/>
			<xs:element name='upstream' type='upstreamType'/>
			<xs:element name='use' type='useType'/>
		</xs:choice>
	</xs:complexType>

	<xs:complexType name='catMetadataType'>
		<xs:choice minOccurs='0' maxOccurs='unbounded'>
			<xs:element name='longdescription' type='longDescType'/>
		</xs:choice>
	</xs:complexType>

	<!-- the huge <upstream/> structure -->
	<xs:complexType name='upstreamType'>
		<xs:choice minOccurs='0' maxOccurs='unbounded'>
			<xs:element name='maintainer' type='upstreamMaintainerType'/>
			<xs:element name='changelog' type='urlType'/>
			<xs:element name='doc' type='upstreamDocType'/>
			<xs:element name='bugs-to' type='urlType'/>
			<xs:element name='remote-id' type='upstreamRemoteIdType'/>
		</xs:choice>
	</xs:complexType>

	<!-- maintainer in two variants -->
	<xs:complexType name='maintainerType'>
		<xs:all>
			<xs:element name='email' type='emailType'
				minOccurs='1'/>
			<xs:element name='name' type='xs:token'
				minOccurs='0'/>
			<xs:element name='description' type='maintainerDescType'
				minOccurs='0'/>
		</xs:all>
		<xs:attribute name='type' type='maintainerTypeAttrType'
			use='required'/>
		<xs:attribute name='restrict' type='restrictAttrType'/>
	</xs:complexType>

	<xs:simpleType name='maintainerTypeAttrType'>
		<xs:restriction base='xs:token'>
			<xs:enumeration value='person'/>
			<xs:enumeration value='project'/>
		</xs:restriction>
	</xs:simpleType>

	<xs:complexType name='upstreamMaintainerType'>
		<xs:all>
			<xs:element name='email' type='emailType'
				minOccurs='1'/>
			<xs:element name='name' type='xs:token'
				minOccurs='0'/>
			<xs:element name='description' type='xs:token'
				minOccurs='0'/>
		</xs:all>
		<xs:attribute name='type' type='maintainerTypeAttrType'/>
		<xs:attribute name='status' type='upstreamMaintainerStatusAttrType'
			default='unknown'/>
	</xs:complexType>

	<xs:simpleType name='upstreamMaintainerStatusAttrType'>
		<xs:restriction base='xs:token'>
			<xs:enumeration value='active'/>
			<xs:enumeration value='inactive'/>
			<xs:enumeration value='unknown'/>
		</xs:restriction>
	</xs:simpleType>

	<xs:complexType name='maintainerDescType'>
		<xs:simpleContent>
			<xs:extension base="xs:token">
				<xs:attribute name='lang' type='langAttrType' default='C'/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>

	<!-- long description -->
	<xs:complexType name='longDescType' mixed='true'>
		<xs:choice minOccurs='0' maxOccurs='unbounded'>
			<xs:element name='pkg' type='pkgType'/>
			<!-- XXX: do we allow <cat/> in pkgmetadata, and the other
				 way around? -->
			<xs:element name='cat' type='catType'/>
		</xs:choice>
		<xs:attribute name='lang' type='langAttrType' default='C'/>
		<xs:attribute name='restrict' type='restrictAttrType'/>
	</xs:complexType>

	<!-- slots -->
	<xs:complexType name='slotsType'>
		<!-- TODO: any order? -->
		<xs:sequence>
			<xs:element name='slot' type='slotType'
				minOccurs='0' maxOccurs='unbounded'/>
			<xs:element name='subslots' type='xs:token'
				minOccurs='0' maxOccurs='1'/>
		</xs:sequence>
		<xs:attribute name='lang' type='langAttrType' default='C'/>
	</xs:complexType>

	<xs:complexType name='slotType'>
		<xs:simpleContent>
			<xs:extension base="xs:token">
				<xs:attribute name='name' type='slotNameAttrType'
					use='required'/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>

	<xs:simpleType name='slotNameAttrType'>
		<xs:restriction base='xs:token'>
			<!-- PMS 3.1.3 Slot Names -->
			<xs:pattern value="[A-Za-z0-9_][A-Za-z0-9+_.-]*"/>
		</xs:restriction>
	</xs:simpleType>

	<!-- use flags -->
	<xs:complexType name='useType'>
		<xs:choice minOccurs='0' maxOccurs='unbounded'>
			<xs:element name='flag' type='flagType'/>
		</xs:choice>
		<xs:attribute name='lang' type='langAttrType' default='C'/>
	</xs:complexType>

	<xs:complexType name='flagType' mixed='true'>
		<xs:choice minOccurs='0' maxOccurs='unbounded'>
			<xs:element name='cat' type='catType'/>
			<xs:element name='pkg' type='pkgType'/>
		</xs:choice>
		<xs:attribute name='name' type='flagNameAttrType'
			use='required'/>
		<xs:attribute name='restrict' type='restrictAttrType'/>
	</xs:complexType>

	<xs:simpleType name='flagNameAttrType'>
		<xs:restriction base='xs:token'>
			<!-- PMS 3.1.4 USE Flag Names -->
			<xs:pattern value="[A-Za-z0-9][A-Za-z0-9+_@-]*"/>
		</xs:restriction>
	</xs:simpleType>

	<!-- upstream-specific types -->
	<xs:complexType name='upstreamDocType'>
		<xs:simpleContent>
			<xs:extension base="urlType">
				<xs:attribute name='lang' type='langAttrType' default='C'/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>

	<xs:complexType name='upstreamRemoteIdType'>
		<xs:simpleContent>
			<xs:extension base="xs:token">
				<xs:attribute name='type' type='upstreamRemoteIdTypeAttrType'
					use='required'/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>

	<xs:simpleType name='upstreamRemoteIdTypeAttrType'>
		<xs:restriction base='xs:token'>
			<xs:enumeration value='bitbucket'/>
			<xs:enumeration value='cpan'/>
			<xs:enumeration value='cpan-module'/>
			<xs:enumeration value='cpe'/>
			<xs:enumeration value='cran'/>
			<xs:enumeration value='ctan'/>
			<xs:enumeration value='freecode'/>
			<xs:enumeration value='freshmeat'/>
			<xs:enumeration value='github'/>
			<xs:enumeration value='gitlab'/>
			<xs:enumeration value='gitorious'/>
			<xs:enumeration value='google-code'/>
			<xs:enumeration value='launchpad'/>
			<xs:enumeration value='pear'/>
			<xs:enumeration value='pecl'/>
			<xs:enumeration value='pypi'/>
			<xs:enumeration value='rubyforge'/>
			<xs:enumeration value='rubygems'/>
			<xs:enumeration value='sourceforge'/>
			<xs:enumeration value='sourceforge-jp'/>
			<xs:enumeration value='vim'/>
		</xs:restriction>
	</xs:simpleType>

	<!-- creepy mixed-text types -->
	<xs:simpleType name='catType'>
		<xs:restriction base='xs:token'>
			<!-- PMS 3.1.1 Category Names -->
			<xs:pattern value="[A-Za-z0-9_][A-Za-z0-9+_.-]*"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name='pkgType'>
		<xs:restriction base='xs:token'>
			<!-- PMS 3.1.1 Category Names + 3.1.2 Package Names -->
			<!-- note: this does not enforce the 'anything matching
				 the version syntax' requirement -->
			<xs:pattern
				value="[A-Za-z0-9_][A-Za-z0-9+_.-]*/[A-Za-z0-9_][A-Za-z0-9+_-]*"/>
		</xs:restriction>
	</xs:simpleType>

	<!-- common attributes -->
	<xs:simpleType name='langAttrType'>
		<xs:restriction base='xs:token'/>
	</xs:simpleType>

	<xs:simpleType name='restrictAttrType'>
		<xs:restriction base='xs:token'/>
	</xs:simpleType>

	<!-- generic types -->
	<xs:simpleType name='emailType'>
		<xs:restriction base='xs:token'>
			<!-- minimal safe regex -->
			<xs:pattern value="[^@]+@[^.]+\..+"/>
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name='urlType'>
		<xs:restriction base='xs:token'>
			<!-- TODO: something better? -->
			<xs:pattern value="(mailto:[^@]+@[^.]+\..+|https?://.+)"/>
		</xs:restriction>
	</xs:simpleType>
</xs:schema>