pvcollada

Developer Guide: Using 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.


1. Schema Location

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.


2. What Does the Schema Define?

The schema:


3. Validating XML Files Against the Schema

Manually (using Python)

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)

Automatically (using GitHub Actions)

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:


4. Example XML File

Example XMLs are found in the Examples/ directory.
Example:
Examples/05 - VerySimpleFixedPVC2_with_electrical_layout_v3.pvc


5. Extending the Schema

If you need to add new enumerations or elements:


6. References


7. Troubleshooting


Note: This guide is based on a partial code search. For more details, explore the pvlib/pvcollada repository.