Skip to content

Commit

Permalink
schema: updates for 37C3
Browse files Browse the repository at this point in the history
  • Loading branch information
saerdnaer committed Dec 17, 2023
1 parent 1c95264 commit 89a4a34
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 18 deletions.
5 changes: 5 additions & 0 deletions validator/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

# Test validation schemas against some example files

./xsd/validate_schedule_xml.sh https://api.events.ccc.de/congress/2023/schedule.xml
79 changes: 61 additions & 18 deletions validator/xsd/schedule.xml.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,25 @@
<xs:element type="xs:string" name="version"/>
<xs:element name="conference">
<xs:complexType>
<xs:all>
<xs:element type="xs:string" name="title"/>
<xs:element type="acronym" name="acronym"/>

<xs:element type="dateOrDateTimeTZ" name="start" minOccurs="0"/>
<xs:element type="dateOrDateTimeTZ" name="end" minOccurs="0"/>
<xs:element type="xs:integer" name="days" minOccurs="0"/>
<xs:element type="duration" name="timeslot_duration" minOccurs="0"/>
<xs:element type="httpURI" name="base_url" minOccurs="0"/>
<xs:element type="xs:string" name="time_zone_name" minOccurs="0" maxOccurs="1"/>
</xs:all>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element type="xs:string" name="title" maxOccurs="1"/>
<xs:element type="acronym" name="acronym" maxOccurs="1"/>

<xs:element type="dateOrDateTimeTZ" name="start" minOccurs="0" maxOccurs="1"/>
<xs:element type="dateOrDateTimeTZ" name="end" minOccurs="0" maxOccurs="1"/>
<xs:element type="xs:integer" name="days" minOccurs="0" maxOccurs="1"/>
<xs:element type="duration" name="timeslot_duration" minOccurs="0"/>
<xs:element type="httpURI" name="base_url" minOccurs="0" maxOccurs="1"/>
<xs:element type="httpURI" name="logo" minOccurs="0" maxOccurs="1"/>

This comment has been minimized.

Copy link
@rixx

rixx Jan 8, 2024

Would've been nice to know about changes like this ahead of time. This change means that pretalx doesn't pass the schedule.xsd validator anymore, as it used to have an empty <logo></logo> tag for proposals without a logo, which is now disallowed on account of httpURI not matching an empty string.

<xs:element type="httpURI" name="url" minOccurs="0" maxOccurs="1"/>
<xs:element type="xs:string" name="time_zone_name" minOccurs="0" maxOccurs="1"/>
<xs:element type="color" name="color" minOccurs="0"/>

<xs:element type="track" name="track" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>

</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element type="day" name="day" maxOccurs="unbounded"/>
Expand Down Expand Up @@ -79,10 +87,10 @@
<xs:element type="start" name="start"/>
<xs:element type="duration" name="duration"/>
<xs:element type="xs:string" name="abstract"/>
<xs:element type="slug" name="slug"/>
<xs:element type="voc-slug" name="slug"/>
<xs:element type="xs:string" name="track"/>

<xs:element type="xs:string" name="logo" minOccurs="0"/>
<!-- logo is the path or URL to an image, we use httpURI as type here as apps prefer full URLs now -->
<xs:element type="httpURI" name="logo" minOccurs="0"/>
<xs:element type="persons" name="persons" minOccurs="0"/>
<xs:element type="xs:string" name="language" minOccurs="0"/>
<xs:element type="xs:string" name="description" minOccurs="0"/>
Expand Down Expand Up @@ -130,13 +138,19 @@
<xs:pattern value="[a-z0-9_-]{4,}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="slug">

<xs:simpleType name="voc-slug">
<xs:restriction base="xs:string">
<xs:pattern value="[a-z0-9_]{4,}-[0-9]{1,6}-[a-z0-9\-_]{4,}"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="slug">
<xs:restriction base="xs:string">
<xs:pattern value="[a-z0-9-]{2,}"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="httpURI">
<xs:restriction base="xs:anyURI">
<xs:pattern value="https?://.*"/>
Expand All @@ -149,6 +163,13 @@
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="hexColor">
<xs:restriction base="xs:string">
<!-- Pattern for hexadecimal color code: # followed by exactly 6 hexadecimal digits, prefered in lower case -->

This comment has been minimized.

Copy link
@rixx

rixx Jan 8, 2024

The comment says "preferred in lower case", but the pattern only matches lower case, so upper-case isn't accepted at all?

<xs:pattern value="#[0-9a-f]{6}"/>
</xs:restriction>
</xs:simpleType>

<xs:complexType name="recording">
<xs:all>
<xs:element type="xs:string" name="license"/>
Expand All @@ -163,8 +184,9 @@
<xs:element name="person" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="string-nonempty">
<xs:attribute type="xs:positiveInteger" name="id"/>
<xs:extension base="xs:string">
<xs:attribute type="xs:positiveInteger" name="id" />
<xs:attribute type="uuid" name="guid"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
Expand Down Expand Up @@ -199,4 +221,25 @@
</xs:element>
</xs:sequence>
</xs:complexType>

<xs:complexType name="track">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="name" use="required"/>
<xs:attribute type="hexColor" name="color" use="optional"/>
<xs:attribute type="slug" name="slug" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:complexType name="color">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="hexColor" name="primary" use="required"/>
<xs:attribute type="hexColor" name="background" use="optional"/>
<xs:anyAttribute processContents="lax"/> <!-- Allows for additional, unspecified attributes -->
</xs:extension>
</xs:simpleContent>
</xs:complexType>

</xs:schema>

0 comments on commit 89a4a34

Please sign in to comment.