diff --git a/doc/XMLreference.rst b/doc/XMLreference.rst index 2de70ddfade..9c99af0cabd 100644 --- a/doc/XMLreference.rst +++ b/doc/XMLreference.rst @@ -89,6 +89,42 @@ will appear in the reference documentation as

+.. _CXSD: + +XSD schema +~~~~~~~~~~ + +The schema is also emitted as an `XML Schema `__ (XSD) document, generated from the +same source of truth and checked in as +`src/xml/generated/mjcf.xsd `__. +Editors use it to complete elements, attributes and keywords, and to report ill-formed values as you type: + +.. image:: images/XMLreference/xsd_editor.png + :width: 100% + :align: center + :class: only-light + +.. image:: images/XMLreference/xsd_editor_dark.png + :width: 100% + :align: center + :class: only-dark + +To enable this, reference the schema in the root element of the model: + +.. code-block:: xml + + + +This requires the Red Hat +`XML extension `__ in VS Code, or the same +extension from `Open VSX `__ in forks such as Cursor and VSCodium. + +The XSD is not a specification of model validity: it never rejects a model that MuJoCo accepts, but does accept models +that the compiler rejects. Constraints that XSD 1.0 cannot express -- child cardinality and presence constraints +between attributes -- are carried as annotations. + + .. _Reference: MJCF Reference diff --git a/doc/changelog.rst b/doc/changelog.rst index 25396fc127c..6b24da0f870 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -14,7 +14,8 @@ General and gated by tests, as are the schema's enum keywords and declared defaults against the C headers and default-constructors. - An XSD schema derived from the main schema is provided in - `model/mjcf.xsd `__. + `src/xml/generated/mjcf.xsd `__. + See :ref:`XSD schema` for how to use it for editor support. Actuation ^^^^^^^^^ diff --git a/doc/images/XMLreference/xsd_editor.png b/doc/images/XMLreference/xsd_editor.png new file mode 100644 index 00000000000..e1926a36c85 Binary files /dev/null and b/doc/images/XMLreference/xsd_editor.png differ diff --git a/doc/images/XMLreference/xsd_editor_dark.png b/doc/images/XMLreference/xsd_editor_dark.png new file mode 100644 index 00000000000..4b0297239dd Binary files /dev/null and b/doc/images/XMLreference/xsd_editor_dark.png differ