Skip to content

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

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:

xml
<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

xml
<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

xml
<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.

Open browser

Programmatic Access

Use the unitsml-ruby gem to query UnitsDB from Ruby applications:

Install

bash
gem install unitsml-ruby

Query units

ruby
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