Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions doc/XMLreference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,42 @@ will appear in the reference documentation as
<p style="display: none"></p>


.. _CXSD:

XSD schema
~~~~~~~~~~

The schema is also emitted as an `XML Schema <https://www.w3.org/TR/xmlschema-1/>`__ (XSD) document, generated from the
same source of truth and checked in as
`src/xml/generated/mjcf.xsd <https://github.com/google-deepmind/mujoco/blob/main/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

<mujoco xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/google-deepmind/mujoco/refs/heads/main/src/xml/generated/mjcf.xsd">

This requires the Red Hat
`XML extension <https://marketplace.visualstudio.com/items?itemName=redhat.vscode-xml>`__ in VS Code, or the same
extension from `Open VSX <https://open-vsx.org/extension/redhat/vscode-xml>`__ 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
Expand Down
3 changes: 2 additions & 1 deletion doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/google-deepmind/mujoco/tree/main/src/xml/generated/mjcf.xsd>`__.
`src/xml/generated/mjcf.xsd <https://github.com/google-deepmind/mujoco/tree/main/src/xml/generated/mjcf.xsd>`__.
See :ref:`XSD schema<CXSD>` for how to use it for editor support.

Actuation
^^^^^^^^^
Expand Down
Binary file added doc/images/XMLreference/xsd_editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/XMLreference/xsd_editor_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.