File tree Expand file tree Collapse file tree 3 files changed +67
-1
lines changed
Expand file tree Collapse file tree 3 files changed +67
-1
lines changed Original file line number Diff line number Diff line change 1+ import sys
2+
3+ from lxml import etree
4+
5+
6+ if __name__ == '__main__' :
7+ assert len (sys .argv ) == 3
8+ xsd_filepath , xml_filepath = sys .argv [1 ], sys .argv [2 ]
9+ with open (xsd_filepath , 'rb' ) as xsd :
10+ schema_root = etree .XML (xsd .read ())
11+ with open (xml_filepath , 'rb' ) as xml :
12+ xml_doc = etree .XML (xml .read ())
13+
14+ schema = etree .XMLSchema (schema_root )
15+ if schema .validate (xml_doc ):
16+ print ('XML is valid.' )
17+ else :
18+ print ('! XML is invalid.' )
19+ for error in schema .error_log :
20+ print (' -' , error .message )
21+ exit (1 )
Original file line number Diff line number Diff line change 1+ name : Validate PVCollada XML examples
2+
3+ on :
4+ push :
5+ paths :
6+ - pvcollada20_schema/pvcollada_schema_0.1.xsd
7+ - pvcollada20_schema/collada_schema_1_5.xsd
8+ - .github/workflows/validate_xml_with_xsd.py
9+
10+ - pvcollada20_schema/04 - TrackersPVC2_with_basic_electrical_layout_v2.pvc
11+ pull_request :
12+ paths :
13+ - pvcollada20_schema/pvcollada_schema_0.1.xsd
14+ - pvcollada20_schema/collada_schema_1_5.xsd
15+ - .github/workflows/validate_xml_with_xsd.py
16+
17+ - pvcollada20_schema/04 - TrackersPVC2_with_basic_electrical_layout_v2.pvc
18+ workflow_dispatch :
19+
20+ jobs :
21+ validate-schema :
22+ strategy :
23+ matrix :
24+ xml_doc :
25+ - pvcollada20_schema/04 - TrackersPVC2_with_basic_electrical_layout_v2.pvc
26+ name : Validate XML
27+ runs-on : ubuntu-latest
28+ steps :
29+ - name : Install Python 3.10
30+ uses : actions/setup-python@v5
31+ with :
32+ python-version : ' 3.10'
33+ - name : Install lxml Python dependency
34+ run : pip3 install lxml==5.3.1
35+ - name : Checkout PVCollada and COLLADA schemas, the validation script, and the XML doc
36+ uses : actions/checkout@v4
37+ with :
38+ sparse-checkout : |
39+ pvcollada20_schema/pvcollada_schema_0.1.xsd
40+ pvcollada20_schema/collada_schema_1_5.xsd
41+ .github/workflows/validate_xml_with_xsd.py
42+ ${{ matrix.xml_doc }}
43+ sparse-checkout-cone-mode : false
44+ - name : Run validation
45+ run : python3 .github/workflows/validate_xml_with_xsd.py pvcollada20_schema/pvcollada_schema_0.1.xsd "${{ matrix.xml_doc }}"
Original file line number Diff line number Diff line change 66 xmlns : collada =" http://www.collada.org/2008/03/COLLADASchema" >
77
88 <xs : import namespace =" http://www.collada.org/2008/03/COLLADASchema"
9- schemaLocation =" collada_schema_1_5.xsd" />
9+ schemaLocation =" pvcollada20_schema/ collada_schema_1_5.xsd" />
1010
1111 <xs : simpleType name =" cell_type_enum" final =" restriction" >
1212 <xs : restriction base =" xs:string" >
You can’t perform that action at this time.
0 commit comments