Add unique constraints in XSD

This commit is contained in:
~lucidiot 2022-05-25 16:53:03 +02:00 committed by Lucidiot
parent 1453dc32c8
commit 80556cacd7
Signed by: lucidiot
GPG Key ID: 3358C1CA6906FB8D
1 changed files with 50 additions and 6 deletions

View File

@ -1,5 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://tilde.town/~lucidiot/itsb/itsb.xsd" version="1.0" elementFormDefault="qualified" xmlns="http://tilde.town/~lucidiot/itsb/itsb.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:schema
targetNamespace="http://tilde.town/~lucidiot/itsb/itsb.xsd"
version="1.0"
elementFormDefault="qualified"
xmlns="http://tilde.town/~lucidiot/itsb/itsb.xsd"
xmlns:itsb="http://tilde.town/~lucidiot/itsb/itsb.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:complexType name="itsbURL">
<xs:simpleContent>
<xs:extension base="xs:anyURI">
@ -142,7 +149,6 @@
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<!-- TODO: Make HTTP header names unique per request -->
<xs:attribute name="name" type="xs:string" use="required" />
</xs:extension>
</xs:simpleContent>
@ -217,7 +223,6 @@
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:anyURI">
<!-- TODO: Make namespace prefixes unique in each call to json2xml -->
<xs:attribute name="prefix" type="xs:string" use="optional" default="">
<xs:annotation>
<xs:documentation>
@ -232,10 +237,21 @@
</xs:sequence>
<xs:attribute name="short-empty" type="xs:boolean" use="optional" default="false">
<xs:annotation>
<xs:documentation><![CDATA[Shorten empty elements to <tag/> instead of <tag></tag>.]]></xs:documentation>
<xs:documentation>
<![CDATA[Shorten empty elements to <tag/> instead of <tag></tag>.]]>
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
<xs:unique name="xmlNamespaces">
<xs:annotation>
<xs:documentation>
XML namespace prefixes should be unique in each json2xml element.
</xs:documentation>
</xs:annotation>
<xs:selector xpath="itsb:namespace" />
<xs:field xpath="@prefix" />
</xs:unique>
</xs:element>
<xs:element name="jq">
<xs:complexType>
@ -249,7 +265,6 @@
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<!-- TODO: Make argument names unique per call -->
<xs:attribute name="name" type="xs:string" use="required" />
</xs:extension>
</xs:simpleContent>
@ -271,6 +286,15 @@
</xs:annotation>
</xs:attribute>
</xs:complexType>
<xs:unique name="jqArgs">
<xs:annotation>
<xs:documentation>
Argument names sent to jq should be unique.
</xs:documentation>
</xs:annotation>
<xs:selector xpath="itsb:arg" />
<xs:field xpath="@name" />
</xs:unique>
</xs:element>
<xs:element name="shell">
<xs:annotation>
@ -281,7 +305,6 @@
</xs:element>
</xs:choice>
<xs:element name="output" type="xs:string">
<!-- TODO: Make output files unique globally -->
<xs:annotation>
<xs:documentation>
Path to the resulting feed, relative to the /feeds/ directory.
@ -339,6 +362,18 @@
</xs:sequence>
<xs:attribute name="id" type="xs:ID" use="required" />
</xs:complexType>
<xs:unique name="uniqueFeedAttributes">
<xs:annotation>
<xs:documentation>
The language, type and format combination of each feed must be unique within each source.
Due to constraints defined by the XML Schema 1.0 specification, feeds without a type or using the default format cannot be checked by this constraint.
</xs:documentation>
</xs:annotation>
<xs:selector xpath="itsb:feed" />
<xs:field xpath="@lang" />
<xs:field xpath="@type" />
<xs:field xpath="@format" />
</xs:unique>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string">
@ -352,5 +387,14 @@
</xs:sequence>
<xs:attribute name="version" use="required" fixed="1.0" />
</xs:complexType>
<xs:unique name="uniqueOutputs">
<xs:annotation>
<xs:documentation>
Output file paths should be unique across the whole document.
</xs:documentation>
</xs:annotation>
<xs:selector xpath=".//itsb:output" />
<xs:field xpath="." />
</xs:unique>
</xs:element>
</xs:schema>