Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Google deepmind Mujoco XML Util Header

From Leeroopedia
Knowledge Sources
Domains Physics Simulation, XML Parsing, Schema Validation
Last Updated 2026-02-15 04:00 GMT

Overview

Declares XML utility classes and functions including mjXError for error reporting, mjXSchema for XML validation, mjMap for key-value mappings, and mjXUtil for attribute reading.

Description

xml_util.h provides the foundational types used across the XML parsing subsystem. It declares mjCopyError for safe error string copying, FirstChildElement/NextSiblingElement wrappers for TinyXML2 traversal, the mjXError exception class with formatted error messages, and the mjXSchema class for declarative XML schema validation with support for printing schemas as plain text or HTML. The mjMap struct provides simple string-to-int mappings for enum lookups, and mjXUtil is declared as a utility class with static methods for reading typed XML attributes.

Usage

Included by all XML parsing files (native reader, native writer, URDF parser, and xml.cc) as the shared utility foundation for XML operations.

Code Reference

Source Location

Key Functions

void mjCopyError(char* dst, const char* src, int maxlen);

XMLElement* FirstChildElement(XMLElement* e, const char* name = nullptr);
XMLElement* NextSiblingElement(XMLElement* e, const char* name = nullptr);

class [[nodiscard]] mjXError {
 public:
  mjXError(const tinyxml2::XMLElement* elem = 0,
           const char* msg = 0, const char* str = 0, int pos = 0);
  char message[1000];
};

class mjXSchema {
 public:
  mjXSchema(std::vector<const char*> schema[], unsigned nrow);
  std::string GetError();
  tinyxml2::XMLElement* Check(tinyxml2::XMLElement* elem, int level);
};

struct _mjMap { const char* key; int value; };
typedef struct _mjMap mjMap;

Import

#include "xml/xml_util.h"

I/O Contract

Inputs

Name Type Required Description
elem tinyxml2::XMLElement* Yes XML element to validate or read attributes from
schema std::vector<const char*>[] Yes (for mjXSchema) Schema definition rows
nrow unsigned Yes (for mjXSchema) Number of schema rows

Outputs

Name Type Description
std::string std::string Error message from schema validation
XMLElement* XMLElement* Validated element, or nullptr on validation failure

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment