Closed suyashkumar closed 1 month ago
I've opened a draft PR which adds this automatic validation in #21. Of course, it seems we have some existing XMLs which do not validate.
You can see what the github action outputs here: https://github.com/cqframework/cql-tests/actions/runs/9164545728/job/25196067658?pr=21
Also copied below:
✅ CqlNullologicalOperatorsTest.xml is valid
✅ CqlAggregateTest.xml is valid
✅ CqlDateTimeOperatorsTest.xml is valid
✅ CqlAggregateFunctionsTest.xml is valid
✅ CqlLogicalOperatorsTest.xml is valid
❌ CqlTypesTest.xml is NOT valid:
failed validating <Element '{http://hl7.org/fhirpath/tests}group' at 0x7d141f8a2840> with XsdGroup(model='sequence', occurs=[1, 1]):
Reason: The content of element '{http://hl7.org/fhirpath/tests}group' is not complete. Tag '{http://hl7.org/fhirpath/tests}test' expected.
Schema component:
<xs:complexType xmlns:xs="http://www.w3.org/2001/XMLSchema" name="Group">
<xs:sequence>
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>Notes about the test group.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="test" type="Test" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="name" type="xs:string">
<xs:annotation>
<xs:documentation>The name of the test group. This should be a computer-friendly name and must be unique within the test suite.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="version" type="xs:string">
<xs:annotation>
<xs:documentation>The version of FHIRPath in which the features being tested were introduced. This should correspond to a published or planned published version of FHIRPath.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="description" type="xs:string">
...
...
</xs:complexType>
Instance type: <class 'xml.etree.ElementTree.Element'>
Instance:
<group xmlns="http://hl7.org/fhirpath/tests" name="Boolean">
</group>
Path: /tests/group[2]
✅ CqlArithmeticFunctionsTest.xml is valid
✅ CqlListOperatorsTest.xml is valid
✅ CqlErrorsAndMessagingOperatorsTest.xml is valid
✅ CqlTypeOperatorsTest.xml is valid
✅ CqlIntervalOperatorsTest.xml is valid
❌ ValueLiteralsAndSelectors.xml is NOT valid:
failed validating <Element '{http://hl7.org/fhirpath/tests}group' at 0x7d141f8c2f70> with XsdGroup(model='sequence', occurs=[1, 1]):
Reason: The content of element '{http://hl7.org/fhirpath/tests}group' is not complete. Tag '{http://hl7.org/fhirpath/tests}test' expected.
Schema component:
<xs:complexType xmlns:xs="http://www.w3.org/2001/XMLSchema" name="Group">
<xs:sequence>
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>Notes about the test group.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="test" type="Test" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="name" type="xs:string">
<xs:annotation>
<xs:documentation>The name of the test group. This should be a computer-friendly name and must be unique within the test suite.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="version" type="xs:string">
<xs:annotation>
<xs:documentation>The version of FHIRPath in which the features being tested were introduced. This should correspond to a published or planned published version of FHIRPath.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="description" type="xs:string">
...
...
</xs:complexType>
Instance type: <class 'xml.etree.ElementTree.Element'>
Instance:
<group xmlns="http://hl7.org/fhirpath/tests" name="String">
</group>
Path: /tests/group[5]
✅ CqlConditionalOperatorsTest.xml is valid
✅ CqlStringOperatorsTest.xml is valid
✅ CqlOverloadMatching.xml is valid
✅ CqlComparisonOperatorsTest.xml is valid
We should consider adding a GitHub action to auto-validate XMLs against our XSD. This will prevent unintentional drift. Of course additional more functional CI over time would also be useful.