Get Started
Everything you need to start using UnitsML in your projects — whether you're encoding units in XML, browsing schemas, or integrating the units database programmatically.
Choose your path
XML Encoding
Use UnitsML schemas to encode units in your XML documents.
Browse Schemas
Explore schema definitions interactively at schema.unitsml.org.
Programmatic Access
Use the unitsml-ruby gem to query UnitsDB from your applications.
XML Encoding
The UnitsML XML Schema defines how to encode units of measure in XML documents. Here's how to get started:
1. Reference the schema
Add the UnitsML namespace to your XML document:
<YourDocument
xmlns:unitsml="https://schema.unitsml.org/unitsml/1.0"
xsi:schemaLocation="https://schema.unitsml.org/unitsml/1.0
https://schema.unitsml.org/unitsml/unitsml-v1.0.xsd">2. Define a unit
<unitsml:UnitSet>
<unitsml:Unit xml:id="m" dimensionURL="#L">
<unitsml:UnitName>metre</unitsml:UnitName>
<unitsml:UnitSymbol>SI</unitsml:UnitSymbol>
</unitsml:Unit>
</unitsml:UnitSet>3. Use the unit in your data
<Measurement>
<Value unitsml:unit="#m">9.81</Value>
<Description>Gravitational acceleration</Description>
</Measurement>TIP
UnitsML is designed to be incorporated into other markup languages, not used standalone. The models work best when embedded in domain-specific formats like MatML, CML, or your own vocabulary — and can also be expressed in JSON, YAML, and other formats.
Browse Schemas
The interactive schema browser provides documentation for all UnitsML schema components:
schema.unitsml.org
Browse element definitions, type hierarchies, and schema documentation for all versions.
Programmatic Access
Use the unitsml-ruby gem to query UnitsDB from Ruby applications:
Install
gem install unitsml-rubyQuery units
require 'unitsml'
# Find a specific unit
unit = Unitsml::Units.find("m")
puts unit.name # => "metre"
puts unit.symbol # => "m"See the unitsml-ruby page for full API documentation.
Next steps
- Read the UnitsML Guide for in-depth usage patterns
- Learn how to incorporate UnitsML into other markup languages
- Understand what UnitsML is and the problems it solves
- Explore UnitsDB — the complete units database