Skip to content

Commit 3a5300b

Browse files
Joshua Whitleydirk-thomas
Joshua Whitley
authored andcommitted
Add "condition" Attribute to package_format3.xsd (ros-infrastructure#190)
* 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.
1 parent 05185b6 commit 3a5300b

7 files changed

+91
-20
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ python:
55
# command to install dependencies
66
install:
77
- pip install docutils
8+
- pip install xmlschema
89
# command to run tests
910
script:
1011
- make

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ SUBDIRS=$(wildcard rep-????)
1515

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

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

2020
$(TARGETS): rep2html.py
2121

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

25+
xsdvalid:
26+
$(PYTHON) xsdValid.py
27+
2528
clean:
2629
-rm *.html
2730
-rm rep-0000.rst

xsd/package_common.xsd

-17
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,6 @@
8181
</xs:restriction>
8282
</xs:simpleType>
8383

84-
<xs:complexType name="DependencyType">
85-
<xs:simpleContent>
86-
<xs:extension base="xs:token">
87-
<!-- The dependency must have a version less then the specified limit. -->
88-
<xs:attribute name="version_lt" type="VersionLimitType" use="optional"/>
89-
<!-- The dependency must have a version less then or equal to the specified limit. -->
90-
<xs:attribute name="version_lte" type="VersionLimitType" use="optional"/>
91-
<!-- The dependency must have a version equal to the specified limit. -->
92-
<xs:attribute name="version_eq" type="VersionLimitType" use="optional"/>
93-
<!-- The dependency must have a version greater then or equal to the specified limit. -->
94-
<xs:attribute name="version_gte" type="VersionLimitType" use="optional"/>
95-
<!-- The dependency must have a version greater then the specified limit. -->
96-
<xs:attribute name="version_gt" type="VersionLimitType" use="optional"/>
97-
</xs:extension>
98-
</xs:simpleContent>
99-
</xs:complexType>
100-
10184
<xs:complexType name="ExportType">
10285
<xs:sequence>
10386
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>

xsd/package_format1.xsd

+18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
33
<xs:include schemaLocation="package_common.xsd"/>
4+
5+
<xs:complexType name="DependencyType">
6+
<xs:simpleContent>
7+
<xs:extension base="xs:token">
8+
<!-- The dependency must have a version less then the specified limit. -->
9+
<xs:attribute name="version_lt" type="VersionLimitType" use="optional"/>
10+
<!-- The dependency must have a version less then or equal to the specified limit. -->
11+
<xs:attribute name="version_lte" type="VersionLimitType" use="optional"/>
12+
<!-- The dependency must have a version equal to the specified limit. -->
13+
<xs:attribute name="version_eq" type="VersionLimitType" use="optional"/>
14+
<!-- The dependency must have a version greater then or equal to the specified limit. -->
15+
<xs:attribute name="version_gte" type="VersionLimitType" use="optional"/>
16+
<!-- The dependency must have a version greater then the specified limit. -->
17+
<xs:attribute name="version_gt" type="VersionLimitType" use="optional"/>
18+
</xs:extension>
19+
</xs:simpleContent>
20+
</xs:complexType>
21+
422
<xs:element name="package">
523
<xs:annotation>
624
<xs:documentation>

xsd/package_format2.xsd

+18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
33
<xs:include schemaLocation="package_common.xsd"/>
4+
5+
<xs:complexType name="DependencyType">
6+
<xs:simpleContent>
7+
<xs:extension base="xs:token">
8+
<!-- The dependency must have a version less then the specified limit. -->
9+
<xs:attribute name="version_lt" type="VersionLimitType" use="optional"/>
10+
<!-- The dependency must have a version less then or equal to the specified limit. -->
11+
<xs:attribute name="version_lte" type="VersionLimitType" use="optional"/>
12+
<!-- The dependency must have a version equal to the specified limit. -->
13+
<xs:attribute name="version_eq" type="VersionLimitType" use="optional"/>
14+
<!-- The dependency must have a version greater then or equal to the specified limit. -->
15+
<xs:attribute name="version_gte" type="VersionLimitType" use="optional"/>
16+
<!-- The dependency must have a version greater then the specified limit. -->
17+
<xs:attribute name="version_gt" type="VersionLimitType" use="optional"/>
18+
</xs:extension>
19+
</xs:simpleContent>
20+
</xs:complexType>
21+
422
<xs:element name="package">
523
<xs:annotation>
624
<xs:documentation>

xsd/package_format3.xsd

+40-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,44 @@
22
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
33
<xs:include schemaLocation="package_common.xsd"/>
44

5+
<xs:complexType name="ConditionalType">
6+
<xs:simpleContent>
7+
<xs:extension base="xs:token">
8+
<xs:attribute name="condition" use="optional">
9+
<xs:simpleType>
10+
<xs:restriction base="xs:token">
11+
<xs:pattern value="[$A-Za-z0-9_\s&lt;&gt;=]*"/>
12+
</xs:restriction>
13+
</xs:simpleType>
14+
</xs:attribute>
15+
</xs:extension>
16+
</xs:simpleContent>
17+
</xs:complexType>
18+
19+
<xs:complexType name="DependencyType">
20+
<xs:simpleContent>
21+
<xs:extension base="xs:token">
22+
<!-- The dependency must have a version less then the specified limit. -->
23+
<xs:attribute name="version_lt" type="VersionLimitType" use="optional"/>
24+
<!-- The dependency must have a version less then or equal to the specified limit. -->
25+
<xs:attribute name="version_lte" type="VersionLimitType" use="optional"/>
26+
<!-- The dependency must have a version equal to the specified limit. -->
27+
<xs:attribute name="version_eq" type="VersionLimitType" use="optional"/>
28+
<!-- The dependency must have a version greater then or equal to the specified limit. -->
29+
<xs:attribute name="version_gte" type="VersionLimitType" use="optional"/>
30+
<!-- The dependency must have a version greater then the specified limit. -->
31+
<xs:attribute name="version_gt" type="VersionLimitType" use="optional"/>
32+
<xs:attribute name="condition" use="optional">
33+
<xs:simpleType>
34+
<xs:restriction base="xs:token">
35+
<xs:pattern value="[$A-Za-z0-9_\s&lt;&gt;=]*"/>
36+
</xs:restriction>
37+
</xs:simpleType>
38+
</xs:attribute>
39+
</xs:extension>
40+
</xs:simpleContent>
41+
</xs:complexType>
42+
543
<xs:complexType name="VersionWithOptionalCompatibilityType">
644
<xs:simpleContent>
745
<xs:extension base="VersionType">
@@ -56,8 +94,8 @@
5694
<xs:element type="DependencyType" name="replace"/>
5795
</xs:choice>
5896

59-
<xs:element name="group_depend" type="xs:token" minOccurs="0" maxOccurs="unbounded"/>
60-
<xs:element name="member_of_group" type="xs:token" minOccurs="0" maxOccurs="unbounded"/>
97+
<xs:element name="group_depend" type="ConditionalType" minOccurs="0" maxOccurs="unbounded"/>
98+
<xs:element name="member_of_group" type="ConditionalType" minOccurs="0" maxOccurs="unbounded"/>
6199

62100
<xs:element name="export" type="ExportType" minOccurs="0" maxOccurs="1"/>
63101
</xs:sequence>

xsdValid.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/python
2+
3+
import xmlschema
4+
5+
format1 = xmlschema.XMLSchema('xsd/package_format1.xsd')
6+
print("'xsd/package_format1.xsd' file is valid.")
7+
format2 = xmlschema.XMLSchema('xsd/package_format2.xsd')
8+
print("'xsd/package_format2.xsd' file is valid.")
9+
format3 = xmlschema.XMLSchema('xsd/package_format3.xsd')
10+
print("'xsd/package_format3.xsd' file is valid.")

0 commit comments

Comments
 (0)