On Fri, 28 Aug 2026 at 10:06, Denis Rykov via QGIS-Developer <[email protected]> wrote: > > Hi, > > I’m currently exploring how to use an LLM/AI to generate valid QGIS .qml > styles from natural-language prompts. One difficulty I’ve encountered is > that, as far as I know, there is no formal or exhaustive schema for the QML > format describing both the XML hierarchy and the semantics of all elements, > attributes, renderers, symbol layers, labeling settings, etc. I’m currently > investigating whether PyQGIS can be used to discover this information > programmatically. I can create QGIS objects, serialize them using QGIS > itself, and recursively inspect the resulting DOM. This provides information > about the actual XML hierarchy, attributes, default values, and property > definitions. Before going further, however, I wanted to ask the QGIS > developers whether there is a more canonical approach. > > In particular: > > Is there an existing source of truth for the QML structure/schema that I may > have missed?
No -- it's considered an internal private detail only, and changes many times throughout the release cycle (while maintaining compatibility with existing QML files!). > Is the QML format intentionally undocumented/non-schema-based, Yes > with the QGIS C++ serialization code effectively serving as the authoritative > specification? Kind of -- but again, it's intentionally NOT a fixed specification at all, but just a reflection of what QGIS internal classes need to store for any particular release. > Would using PyQGIS to instantiate the different renderers, symbol layers, > labeling configurations, etc., and then inspecting their QDomDocument > serialization be a reasonable way to generate a machine-readable schema? Possibly, yes, if you're just interested in generating XML that QGIS will consume. If you're attempting to READ xml that qgis produces then the recommended approach is always to just use QGIS api directly to read this, and then extract properties from the resulting symbols using the stable API. Nyall > Are there particular QGIS APIs or parts of the source tree that you would > recommend for this purpose? > > I’d appreciate any advice on whether this is the right direction, or whether > there is a more appropriate way to obtain or generate such a schema from QGIS > itself. > _______________________________________________ > QGIS-Developer mailing list > [email protected] > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer _______________________________________________ QGIS-Developer mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
