Skip to content

Commit

Permalink
Add "condition" Attribute to package_format3.xsd (#190)
Browse files Browse the repository at this point in the history
* XSD: Moving DependencyType into each package format.

* XSD: Add condition attribute to several elements in format3.

* Travis: Testing XSD validator.

* Travis: Fixing XSD validator.

* Modifications to xsdValid.py suggested by @dirk-thomas.
  • Loading branch information
Joshua Whitley authored and dirk-thomas committed Mar 27, 2019
1 parent 05185b6 commit 3a5300b
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 20 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ python:
# command to install dependencies
install:
- pip install docutils
- pip install xmlschema
# command to run tests
script:
- make
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ SUBDIRS=$(wildcard rep-????)

TARGETS=$(REPS:.rst=.html) rep-0000.html

all: rep-0000.rst $(TARGETS)
all: rep-0000.rst $(TARGETS) xsdvalid

$(TARGETS): rep2html.py

rep-0000.rst: $(REPS)
$(PYTHON) genrepindex.py .

xsdvalid:
$(PYTHON) xsdValid.py

clean:
-rm *.html
-rm rep-0000.rst
Expand Down
17 changes: 0 additions & 17 deletions xsd/package_common.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,6 @@
</xs:restriction>
</xs:simpleType>

<xs:complexType name="DependencyType">
<xs:simpleContent>
<xs:extension base="xs:token">
<!-- The dependency must have a version less then the specified limit. -->
<xs:attribute name="version_lt" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version less then or equal to the specified limit. -->
<xs:attribute name="version_lte" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version equal to the specified limit. -->
<xs:attribute name="version_eq" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version greater then or equal to the specified limit. -->
<xs:attribute name="version_gte" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version greater then the specified limit. -->
<xs:attribute name="version_gt" type="VersionLimitType" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:complexType name="ExportType">
<xs:sequence>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
Expand Down
18 changes: 18 additions & 0 deletions xsd/package_format1.xsd
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="package_common.xsd"/>

<xs:complexType name="DependencyType">
<xs:simpleContent>
<xs:extension base="xs:token">
<!-- The dependency must have a version less then the specified limit. -->
<xs:attribute name="version_lt" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version less then or equal to the specified limit. -->
<xs:attribute name="version_lte" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version equal to the specified limit. -->
<xs:attribute name="version_eq" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version greater then or equal to the specified limit. -->
<xs:attribute name="version_gte" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version greater then the specified limit. -->
<xs:attribute name="version_gt" type="VersionLimitType" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:element name="package">
<xs:annotation>
<xs:documentation>
Expand Down
18 changes: 18 additions & 0 deletions xsd/package_format2.xsd
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="package_common.xsd"/>

<xs:complexType name="DependencyType">
<xs:simpleContent>
<xs:extension base="xs:token">
<!-- The dependency must have a version less then the specified limit. -->
<xs:attribute name="version_lt" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version less then or equal to the specified limit. -->
<xs:attribute name="version_lte" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version equal to the specified limit. -->
<xs:attribute name="version_eq" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version greater then or equal to the specified limit. -->
<xs:attribute name="version_gte" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version greater then the specified limit. -->
<xs:attribute name="version_gt" type="VersionLimitType" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:element name="package">
<xs:annotation>
<xs:documentation>
Expand Down
42 changes: 40 additions & 2 deletions xsd/package_format3.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,44 @@
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="package_common.xsd"/>

<xs:complexType name="ConditionalType">
<xs:simpleContent>
<xs:extension base="xs:token">
<xs:attribute name="condition" use="optional">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:pattern value="[$A-Za-z0-9_\s&lt;&gt;=]*"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:complexType name="DependencyType">
<xs:simpleContent>
<xs:extension base="xs:token">
<!-- The dependency must have a version less then the specified limit. -->
<xs:attribute name="version_lt" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version less then or equal to the specified limit. -->
<xs:attribute name="version_lte" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version equal to the specified limit. -->
<xs:attribute name="version_eq" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version greater then or equal to the specified limit. -->
<xs:attribute name="version_gte" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version greater then the specified limit. -->
<xs:attribute name="version_gt" type="VersionLimitType" use="optional"/>
<xs:attribute name="condition" use="optional">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:pattern value="[$A-Za-z0-9_\s&lt;&gt;=]*"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:complexType name="VersionWithOptionalCompatibilityType">
<xs:simpleContent>
<xs:extension base="VersionType">
Expand Down Expand Up @@ -56,8 +94,8 @@
<xs:element type="DependencyType" name="replace"/>
</xs:choice>

<xs:element name="group_depend" type="xs:token" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="member_of_group" type="xs:token" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="group_depend" type="ConditionalType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="member_of_group" type="ConditionalType" minOccurs="0" maxOccurs="unbounded"/>

<xs:element name="export" type="ExportType" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
Expand Down
10 changes: 10 additions & 0 deletions xsdValid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/python

import xmlschema

format1 = xmlschema.XMLSchema('xsd/package_format1.xsd')
print("'xsd/package_format1.xsd' file is valid.")
format2 = xmlschema.XMLSchema('xsd/package_format2.xsd')
print("'xsd/package_format2.xsd' file is valid.")
format3 = xmlschema.XMLSchema('xsd/package_format3.xsd')
print("'xsd/package_format3.xsd' file is valid.")

0 comments on commit 3a5300b

Please sign in to comment.