Click here to Skip to main content
15,888,610 members
Articles / DevOps / Unit Testing

Units of Measure Library for .NET

Rate me:
Please Sign up or sign in to vote.
4.93/5 (7 votes)
20 Jun 2012CPOL8 min read 60.4K   2K   35  
This article introduces a library for handling units of measure.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="UnitsOfMeasureLibrary"
    targetNamespace="http://www.hediet.de/xsd/unitlibrary/1.0" elementFormDefault="qualified"
    xmlns="http://www.hediet.de/xsd/unitlibrary/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:simpleType name="UnitAbbreviation">
    <xs:annotation>
      <xs:documentation xml:lang="en">The representation of a Unit abbreviation.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value="[\S]+"/>
    </xs:restriction>
  </xs:simpleType>


  <xs:element name="UnitLibrary">
    <xs:complexType>
      <xs:sequence>
        <xs:choice maxOccurs="unbounded">
          
          <xs:element name="BaseUnit">
            <xs:complexType>
              <xs:attribute name="Name" type="xs:string" />
              <xs:attribute name="Abbr" type="UnitAbbreviation" />
            </xs:complexType>
          </xs:element>
          
          <xs:element name="ScaledShiftedUnit">
            <xs:complexType>
              <xs:attribute name="Name" type="xs:string" />
              <xs:attribute name="Abbr" type="UnitAbbreviation" />
              <xs:attribute name="Factor" type="xs:double" />
              <xs:attribute name="Offset" use="optional" type="xs:double" />
              <xs:attribute name="UnderlayingUnit" type="UnitAbbreviation" />
            </xs:complexType>
          </xs:element>

          <xs:element name="DerivedUnit">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="UnitPart" minOccurs="1" maxOccurs="unbounded">
                  <xs:complexType>
                    <xs:attribute name="Unit" type="UnitAbbreviation" />
                    <xs:attribute name="Exponent" type="xs:byte" />
                  </xs:complexType>
                </xs:element>
              </xs:sequence>
              <xs:attribute name="Name" type="xs:string" />
              <xs:attribute name="Abbr" type="UnitAbbreviation" />
            </xs:complexType>
          </xs:element>
          
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Student
Germany Germany
Presently I am a student of computer science at the Karlsruhe Institute of Technology in Germany.

Comments and Discussions