summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2016-03-18 17:57:58 +0100
committerMichał Górny <mgorny@gentoo.org>2016-03-18 17:57:58 +0100
commit4488657da13f1a621363876cbf9106ecda7c8751 (patch)
tree631a2baaa7e779525a2757e703897558c7c5f2df
parentmetadata: Revert "Allow multiple <doc/> elements with the same language" (diff)
downloadxml-schema-4488657da13f1a621363876cbf9106ecda7c8751.tar.gz
xml-schema-4488657da13f1a621363876cbf9106ecda7c8751.tar.bz2
xml-schema-4488657da13f1a621363876cbf9106ecda7c8751.zip
metadata: Add complete uniqueness & anti-repetition constraints
-rw-r--r--metadata.xsd40
1 files changed, 37 insertions, 3 deletions
diff --git a/metadata.xsd b/metadata.xsd
index c6aa61a..6ecaa25 100644
--- a/metadata.xsd
+++ b/metadata.xsd
@@ -20,6 +20,10 @@
<xs:selector xpath='slots'/>
<xs:field xpath='@lang'/>
</xs:unique>
+ <xs:unique name='upstreamSingleConstraint'>
+ <xs:selector xpath='upstream'/>
+ <xs:field xpath='@fake-only-once'/>
+ </xs:unique>
<xs:unique name='useUniquityConstraint'>
<xs:selector xpath='use'/>
<xs:field xpath='@lang'/>
@@ -50,6 +54,20 @@
</xs:unique>
</xs:element>
<xs:element name='upstream' type='upstreamType'>
+ <xs:unique name='bugsToSingleConstraint'>
+ <xs:selector xpath='bugs-to'/>
+ <xs:field xpath='@fake-only-once'/>
+ </xs:unique>
+ <xs:unique name='changelogSingleConstraint'>
+ <xs:selector xpath='changelog'/>
+ <xs:field xpath='@fake-only-once'/>
+ </xs:unique>
+ <!-- prevent accidentally repeating the same remote -->
+ <xs:unique name='upstreamRemoteIdRepetitionConstraint'>
+ <xs:selector xpath='remote-id'/>
+ <xs:field xpath='@type'/>
+ <xs:field xpath='.'/>
+ </xs:unique>
<xs:unique name='upstreamDocUniquityConstraint'>
<xs:selector xpath='doc'/>
<xs:field xpath='@lang'/>
@@ -74,12 +92,19 @@
<!-- 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='maintainer' type='upstreamMaintainerType'>
+ <xs:unique name='upstreamMaintainerUniquityConstraint'>
+ <xs:selector xpath='maintainer'/>
+ <xs:field xpath='name'/>
+ </xs:unique>
+ </xs:element>
+ <xs:element name='changelog' type='urlOnceType'/>
<xs:element name='doc' type='upstreamDocType'/>
- <xs:element name='bugs-to' type='urlType'/>
+ <xs:element name='bugs-to' type='urlOnceType'/>
<xs:element name='remote-id' type='upstreamRemoteIdType'/>
</xs:choice>
+ <xs:attribute name='fake-only-once'
+ fixed='there can be at most one &lt;upstream/&gt; element'/>
</xs:complexType>
<!-- maintainer in two variants -->
@@ -514,4 +539,13 @@
<xs:pattern value="(mailto:[^@]+@[^.]+\..+|https?://.+)"/>
</xs:restriction>
</xs:simpleType>
+
+ <xs:complexType name='urlOnceType'>
+ <xs:simpleContent>
+ <xs:extension base="urlType">
+ <xs:attribute name='fake-only-once'
+ fixed='there can be at most one element of this type'/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
</xs:schema>