pvcollada_schema_0.1.xsd
This guide explains how to use the pvcollada_schema_0.1.xsd
XML schema file in the pvlib/pvcollada repository to validate PVCollada XML files. The schema ensures that your XML files conform to the structure and enumerated types expected by the PVCollada format.
The schema file is located at:
schema/pvcollada_schema_0.1.xsd
This schema imports the COLLADA schema (collada_schema_1_5.xsd
) and defines enumerations and types specific to photovoltaic (PV) system design.
The schema:
<xs:simpleType name="cell_material_enum">
<xs:restriction base="xs:string">
<xs:enumeration value="monoSi" />
<xs:enumeration value="polySi" />
...
</xs:restriction>
</xs:simpleType>
A Python script is provided at schema/validate.py
that uses lxml
to validate an XML file.
Example usage:
from lxml import etree
XML_FILE_PATH = "../Examples/05 - VerySimpleFixedPVC2_with_electrical_layout_v3.pvc"
XSD_FILE_PATH = "pvcollada_schema_0.1.xsd"
with open(XML_FILE_PATH, "rb") as xml:
xml_doc = etree.XML(xml.read())
with open(XSD_FILE_PATH, "rb") as xsd:
schema_root = etree.XML(xsd.read())
schema = etree.XMLSchema(schema_root)
if schema.validate(xml_doc):
print("XML is valid.")
else:
print("! XML is invalid.")
for error in schema.error_log:
print(" -", error.message)
lxml
installed:
pip install lxml
The repository includes a GitHub Actions workflow:
.github/workflows/validate_xml_with_xsd.yml
This workflow automatically validates example PVCollada XML files on every push or pull request affecting relevant files.
Key steps:
lxml
.Example XMLs are found in the Examples/
directory.
Example:
Examples/05 - VerySimpleFixedPVC2_with_electrical_layout_v3.pvc
If you need to add new enumerations or elements:
schema/pvcollada_schema_0.1.xsd
.<xs:enumeration value="..."/>
or new types as needed.Note: This guide is based on a partial code search. For more details, explore the pvlib/pvcollada repository.